-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
replace thecodingmachine/safe
, webmozart/assert
, and symfony/process
by azjezz/psl
#138
Conversation
The number of dependent libraries is reduced, but the dependency to one library is increased. Because function calls that were previously based on classic PHP are replaced. (My statement refers only to this one argument and does not make any technical assessment!) |
Yes, but that's -3 vs +1. so we are still down 2.
see Roave/BackwardCompatibilityCheck#306 (comment) and Roave/BackwardCompatibilityCheck#306 (comment) on why builtin functions were replaced. |
Again: I have not made any technical assessment of the individual functions, I have only said that by replacing classical functions, the dependence to one library is increased. That is not a criticism or evaluation on |
daf2089
to
48a9108
Compare
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.
Stellar improvement! Very happy with the changes so far, so the comments are mostly about small details, and some type-related issues in the test suite.
6b861c8
to
89ecec8
Compare
Signed-off-by: azjezz <azjezz@protonmail.com>
test/unit/Changelog/BumpAndCommitChangelogVersionViaKeepAChangelogTest.php
Outdated
Show resolved
Hide resolved
Signed-off-by: azjezz <azjezz@protonmail.com>
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.
Excellent refactoring, thanks!
These tests were not present, and would have regressed in #13 Ref: #138 (comment) Ref: #138 (comment) Ref: #138 (comment) Thanks @zerkms!
|
||
Assert::stringNotEmpty($value, sprintf('Could not find a value for environment variable "%s"', $key)); | ||
Psl\invariant($value !== null && $value !== '', Str\format('Could not find a value for environment variable "%s"', $key)); |
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.
@azjezz why not Type\non_empty_string()->matches($value)
here?
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.
we, you can do that too, same thing
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.
it doesn't work actually, I found.
ERROR: MoreSpecificReturnType - The declared return type 'non-empty-string' for EnvironmentVariables::getenv is more specific than the inferred return type 'string' (see https://psalm.dev/070)
ERROR: LessSpecificReturnStatement -- The type 'string' is more general than the declared return type 'non-empty-string' for EnvironmentVariables::getenv (see https://psalm.dev/129)
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.
ah, yes it does. i was trying
Psl\invariant(
Type\non_empty_string()->assert($value),
Str\format('Could not find a value for environment variable "%s"', $key)
);
instead of just
Type\non_empty_string()->assert($value);
but i guess you then lose the custom invariant error message.
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.
yea, you lose the message with assert, maybe we could add a costume message as a second argument, not sure 🤔
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.
Sounds good!
Description
Similar to Roave/BackwardCompatibilityCheck#306, this PR replaces
thecodingmachine/safe
,webmozart/assert
, andsymfony/process
byazjezz/psl
.This reduces the amount of dependencies, and relies on a better type assertion component provided by PSL.
Psl also ships with functions that replace PHP builtin to provide a better error handling, and consistency.
symfony/process
is not made absolute byPsl\Shell\execute
, asexecute
function is created as a replacement forexec
builtin function, however, it provides enough functionality ( working directory, argument escaping, environment variables .. etc ) to replace the usage ofsymfony/process
within this library ( if more features are needed later on, it makes sense to bringsymfony/process
back ).