Gold/PHP 8 Scratchpad
From Mahara Wiki
Just a place to scratch out thoughts on how to measure progress on PHP8 compliance that will give us some confidence and a sense of progress.
How to start
We need to be able to measure what is not currently working.
Behat & PHPUnit testing
We currently use this quite a bit. I would propose that we start with these as the initial measurement tool.
This would mean that we first need to get the behat tests to test using the target version of PHP. Then run the tests and assume that all failures are related to PHP8 non-compliance.
All tools have an option to specifically test for PHP 8.1.
- Phan - Static analysis that prefers to prove incorrectness rather than correctness and minimize false-positives.
- PHPCompatibility is an extension for PHP_CodeSniffer.
- grumphp-php-compatibility is an extension of PHPCompatibility that allows it to word with GrumPHP (aka Bad Santa).
How to work
I'm going to maintain a single codebase to work from for this. I'll set up Apache to host 2 sites from it. One running on PHP 7.4 and the other on PHP 8.1. This will give the opportunity to test things in the browser in a very quick and simple manner. They will have a shared config so they'll have the same DB and maharadata area.
I want this to be a quick, rapid process. A large number of very small patchsets. Each resolving a single Behat test.
The commit message on a patchset will need to be small and concise. Ideally, just a reference to the behat test that this patchset fixes.
There will be edge cases. I see these being where a fix on one test cascades out to multiple other tests and/or areas of Mahara. In these cases the commit message will need to be more comprehensive.
Once we have an idea of the amount of work we will have an idea on what is needed.
If the number is large(ish) I'd like to add a dashboard or chatbot that reports on the progress.
A number of the Code Analysis tools have an option to output their findings in a machine readable format. These could be used in the reporting also.
Providing tags on patchsets are consistent we should be able to have a script search and scrape numbers from the Gerrit API. It is looking like this will be a simple thing. e.g. curl https://reviews.mahara.org/changes/?q=status:merged+topic:PHPStan
Having looked at search options it looks like 'intopic' is preferred over 'topic' as we have multiple tags in this field. I also see that 'PHP8' has been used a few times already. I would suggest 'PHP8Compat' as the tag to use to make filtering easier to spot for this task.