Motivation
As PHP evolves and the SDK targets PHP 8.0+, there are patterns that could be automatically modernised: constructor promotion, match expressions, named arguments, and more.
Example
Current code in src/Client.php:
public function __construct(?string $token = null, ...)
{
$this->token = $token ?? getenv('OPEN_API_TOKEN');
...
}
With Rector + constructor promotion this could become:
public function __construct(
private ?string $token = null,
...
) {
$this->token ??= getenv('OPEN_API_TOKEN');
}
Proposal
- Add
rector/rector to require-dev
- Configure a
rector.php with the LevelSetList::UP_TO_PHP_81 preset
- Add a
composer run rector script for dry-run and composer run rector-fix to apply
Open questions
- Should Rector run in CI as a check-only step, or only locally?
- Which rule sets are safe to apply without risking breaking changes for consumers on PHP 8.0?
Motivation
As PHP evolves and the SDK targets PHP 8.0+, there are patterns that could be automatically modernised: constructor promotion, match expressions, named arguments, and more.
Example
Current code in
src/Client.php:With Rector + constructor promotion this could become:
Proposal
rector/rectortorequire-devrector.phpwith theLevelSetList::UP_TO_PHP_81presetcomposer run rectorscript for dry-run andcomposer run rector-fixto applyOpen questions