There are few things that I really like about Phpactor, but its DI Container [link] is one of them.
In seven years it has hardly changed at all. It’s modular, supports tags, parameters (with schemas) and the has only 233 lines of code including comments and whitespace
There is no YAML, XML or compilation. No auto wiring, no property injection, factory modifiers, weird ways to extend services. All services are singletons.
Today I have tagged version 2022.10.11.
This is the first (and hopefully not the last) monthly release, the full changelog is on the release page. I’ll run through some of the highlights in this post.
Generate Decorator ¶ Thanks to the perserverance mamazu there is now a code action to generate a decorator:
Generate Decorator This is an LSP only action, and must be invoked in a file with an empty class which implements one or more interfaces.
Today I have tagged Phpactor 2022.09.11. The previous release was Phpactor 18 all the way back in January.
It has been a significant 8 months for Phpactor:
Conversion to a mono-repository. Completely refactored type system. Phpactor theme song. Numerous features and improvements (see highlights) Converting Phpactor to a monorepo has accelerated development significantly, it has been far easier to fix bugs and add features. It is imaginable to say that more progress has been made in these 8 months than in the past 3 years and it’s still awful.
Phpactor (it’s a Language Server) has a new type system, the most interesting features of which might be:
First Class Types Generics Type Combination Type Literals In the examples below the function wrAssertType is used. This is an assertion used in Phpactor’s tests.
History ¶ When I started Phpactor 7 years ago I had absolutely no clue about type systems (that’s only slightly less true today). As a consequence types were represented as a single class:
Phpactor is a monolith with some exceptions. Over 20 packages have been imported into the main repo and their github repositories abandoned.
This should make development far easier going forward.
Background ¶ You may have heard me tell this story before. Hopefully this will be the last time I tell it.
When I started Phpactor in 2015 I had just read “principles of package design”, and wanting to be a good developer, I decided to architect Phpactor as a set of decoupled packages, in general there would be four classes of package:
TL;DR;: Check the 0.18.0 release notes
Phpactor 17 was released 11 months ago. After some busy months working on Phpactor I switched focus to phpbench for better or for worse and because of that there has been very little development on Phpactor for the past 6 months. During which time PHP 8.1 has been released.
Phpactor 18 does not support PHP 8.1 features (e.g. Enum) currently, but thanks to tolerant-php-parser it supports the syntax and won’t crash if you use a readonly modifier.
TL;DR;: Check the 0.17.0 release notes
It’s been over 6 months since the release of Phpactor 16. Time really files! I planned to release Phpactor 17 last August - but, well. It didn’t happen and in the meantime there has been a huge amount of activity in develop.
PHP 8 Support and Github Actions ¶ Phpactor can now be installed with the PHP 8 runtime, some necessary fixes were made to support new PHP 8 syntax and some new features:
TL;DR; Maestro is a package maintenance automator which is in development.
It’s Christmas and Phpactor needs to be upgraded to PHP 8.0, but Phpactor has many packages:
$ composer show | grep phpactor | wc -l 42 Most of these packages were created almost 4 years ago, and have been updated little by little as necessary.
Even editing the composer.json file to allow PHP 8 for each repository is a big task - not to mention needing to migrate from Travis to Github Actions (as Travis has become unusable in the past months with build times sometimes taking an hour) - and that’s before I can even start manually editing all the test suites to be compatible with PHPUnit 9.
Release 16 (0.16.0).
In total 32 tickets / cards have been worked on.
Reference Finder ¶ Phpactor 15 introduced an indexer, which enabled a couple of new features. A major one is reference finding.
In Phpactor, reference finding refers to finding:
Class references Function references Class member (method,constant,property) references. The first two are straight-forward, the third requires additional static analysis and can be slower (we need to find all matching members, then perform some static analysis to see if the container type belongs to the class we are searching for).
It’s been two months since the last Phpactor release.
Release 15 (0.15.0) was intended to be the release that integrated the Language Server. It has been a huge amount of work, and at least 63 tickets have been worked on. But there have also been numerous other improvements.
New Documentation ¶ Phpactor now has new documentation hosted on readthedocs. The new docs can make use of the power of RST and should provide a better foundation for continuing documentation development.
TL;DR: See what’s new.
It’s time to make a new release! Which generally involves lots of waiting for composer. So a good time to make a blog post.
It’s been well over a year since I last blogged about 3 years of Phpactor.
So what’s new since then? What happened in 2019?
In January 2019 I really wanted to finish the Language Server implementation, and I spent lots of time working on a generic language server implementation, then the language server extension and quite a few other packages which added distinct capabilities to the server and finally it was working with completion, reference finding and hover.
Over the past month or so I have been gradually migrating Phpactor to use Extensions.
This started because I wanted to add Language Server capabilities to Phpactor, but having two RPC mechanisms in the same application seemed overkill, so I decided to extract everything into extensions in order that all of the components could be easily reused and recombined (so that a phpactor-language-server standalone application could be created).
In addition I wanted the ability to add framework and tool specific functionality, which doesn’t belong in the main distribution.
TL;DR ¶ Phpactor 1.0 will have no features at all, but it will provide a way to install extensions. All current Phpactor functionality will be extracted to extensions.
Background ¶ One problem with Phpactor has always been that it has not been extensible - it is not possible to, for example, install a Behat extension, or a Phpspec or Symfony extension.
It is not that the infrastructure isn’t there internally - it is and was based on the precedent set by Phpbench (which was in turn influenced by other things, notaby Behat, Symfony, Pimple, etc).
The first commit in Phpactor (pronounced “factor”) dates from almost three years ago:
commit 3677c5cb58a5b203fb658c8e2498e512cdef555a Author: dantleech <firstname.lastname@example.org> Date: Thu Sep 24 14:08:35 2015 +0200 Initial I had no idea about how to create such an ambitious project in a domain in which I knew nothing. But I had been using VIM for around 7 years (?), VIM is a great text editor, but the tooling around refactoring and auto-completion for PHP was sub-optimal, and instead of waiting more years, I decided to write my own tool.
1 of 1