-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eliminated Psalm baseline, migrated from webmozart/assert
to azjezz/psl
#564
base: 4.17.x
Are you sure you want to change the base?
Conversation
…z/psl` This change is quite massive, and rewrites most of the library so that it is more type-safe, especially when it comes to large JSON structure traversal. `composer/composer:^1` manifest parsing is now gone (not supported anyway, since we depend on `composer-runtime-api:^2`). We migrated from `webmozart/assert` to the incredibly more powerful `azjezz/psl` dependency, which gives us massive code reduction, and improved type guarantees. Most tests were also simplified a lot, and some (outdated, due to older PHP versions targeted) are gone. Test metadata has also been rewritten, and PHPUnit has been tuned to be much stricter. `symfony/console:^7.2.1` has also been bumped, meanwhile.
This leads to some minor tradeoffs between `non-empty-string` vs `string` declarations, and required us to remove an `@pure` declaration, but is otherwise a good improvement overall.
This type is relatively safe to keep inside this package (only), and its only responsibility is really behaving as anti-corruption layer with `composer.json`, `composer.lock` and `installed.json`, so this is a good fit.
These are minor dependency upgrades that are well worth having, for the reduced code complexity in our domain.
bfa36d6
to
2f87f49
Compare
These are slow and wasteful: not worth burning CPUs for no reason.
Many libraries, such as Symfony, don't understand semantic versioning well, and tend to release software that is incompatible with the next major version of a dependency (in this case `php`, which does not follow SemVer). This kind of botched architecture by Symfony leads to dependencies having broken behavior in oldstable releases. This is effectively a choice by the upstream maintainer (Symfony) to leave this sort of problem to the consumer (in this case, us), who then has to restrict ranges more aggressively. In this case, the failures are due to transitive dependencies leading to symfony, so introducing a `conflict` worsens the situation for our own consumers/
@maglnet since I'm touching a lot of the project, you might want to take a glance here, especially to see how I'm ripping out pieces to use |
$fileName = realpath($configFileArgument); | ||
if ($fileName === false) { | ||
$fileName = Filesystem\canonicalize($configFileArgument); | ||
if ($fileName === null) { | ||
throw new InvalidArgumentException( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be listed in the @throws
docblock?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly: I added @throws
in an age when the IDE was really pedantic about it.
I don't believe them to be as important anymore, but if you believe so, we can tweak SA tools to check these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should either use the tag or not. I'm happy with the tags going away / being removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say that they are relevant for things where we explicitly also test for them
$fileContent = file_get_contents(__DIR__ . '/../../../data/config.dist.json'); | ||
$this->assertNotFalse($fileContent); | ||
|
||
$optionsFromFile = new Options( | ||
json_decode($fileContent, true), | ||
); | ||
$optionsFromFile = new Options([ | ||
'symbol-whitelist' => [], | ||
'php-core-extensions' => [ | ||
'Core', | ||
'date', | ||
'json', | ||
'hash', | ||
'pcre', | ||
'Phar', | ||
'Reflection', | ||
'SPL', | ||
'random', | ||
'standard', | ||
], | ||
'scan-files' => [], | ||
]); | ||
|
||
$this->assertEquals($options, $optionsFromFile); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$fileContent
is no longer used in this test. We are now comparing new Options()
with new Options( $some_fixed_content )
. The file isn't used at all here any longer. Perhaps this test should be renamed or rewritten?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, renaming is a good idea
This change is quite massive, and rewrites most of the library so that it is more type-safe, especially when it comes to large JSON structure traversal.
composer/composer:^1
manifest parsing is now gone (not supported anyway, since we depend oncomposer-runtime-api:^2
).We migrated from
webmozart/assert
to the incredibly more powerfulazjezz/psl
dependency, which gives us massive code reduction, and improved type guarantees.Most tests were also simplified a lot, and some (outdated, due to older PHP versions targeted) are gone.
Test metadata has also been rewritten, and PHPUnit has been tuned to be much stricter.
symfony/console:^7.2.1
has also been bumped, meanwhile.