-
-
Notifications
You must be signed in to change notification settings - Fork 333
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
Add support for PHP 8 #1064
Add support for PHP 8 #1064
Conversation
Error in build PHP 8.0: Blocked by: |
alice/src/Throwable/Exception/FixtureBuilder/Denormalizer/DenormalizerExceptionFactory.php Line 33 in 25e127f
= null to throwable so required param is not after optional one.
Edit: #1068 |
Thanks for the PR @Yozhef, but I think it will require a migration to GitHub Actions as Travis CI kinda gave up on OSS support :( |
@theofidry ok I will do it |
fd357d1
to
2af9929
Compare
@theofidry File -> SimpleReferenceTokenParserTest.php:56 -> SimpleReferenceTokenParser -> FixtureReferenceValue
|
@@ -48,7 +48,7 @@ public function testStaticValues(): void | |||
|
|||
$reflProp = $reflClass->getProperty('values'); | |||
$reflProp->setAccessible(true); | |||
$values = $reflProp->getValue(TokenType::class); | |||
$values = $reflProp->getValue((object) TokenType::class); |
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.
??
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.
If run in PHP 8
1) Nelmio\Alice\FixtureBuilder\ExpressionLanguage\TokenTypeTest::testStaticValues
TypeError: ReflectionProperty::getValue(): Argument #1 ($object) must be of type ?object, string given
/home/runner/work/alice/alice/tests/FixtureBuilder/ExpressionLanguage/TokenTypeTest.php:50
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.
Maybe the reflection API changed for a static value, but the change does not look correct, (object) TokenType::class === stdClass{ #scalar: TokenType::class }
which is most likely not what we want
@Yozhef sorry I'm not following, what's the issue? |
b5f0b42
to
145d319
Compare
@Yozhef Congrats on making the CI green. 😃 |
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.
👍 looks good to me overall aside a few notes; thanks a lot for the work
@@ -41,7 +41,9 @@ public function parse(Token $token): FixtureReferenceValue | |||
$value = $token->getValue(); | |||
|
|||
try { | |||
return new FixtureReferenceValue(substr($value, 1)); | |||
$elements = empty($value) ? false : substr($value, 1); |
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.
Is this necessary? IIRC this parser can only parse SIMPLE_REFERENCE_TYPE
tokens which have the form @.+
, i.e. $value
is a non-empty string here and starts with @
. Anything else IMO should go with the exception.
Looking at it again though it might be clearer to throw the exception if $value
is not a string and $elements
an empty string rather than relying on an exception to be thrown and catch it:
$value = $token->getValue();
if (!is_string($value) || '' === $value) {
throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token);
}
return new FixtureReferenceValue(substr($value, 1));
@@ -45,7 +45,9 @@ public function canParse(Token $token): bool | |||
*/ | |||
public function parse(Token $token) | |||
{ | |||
$variable = substr($token->getValue(), 1); | |||
$variable = empty($token->getValue()) |
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.
likewise here; also general note empty()
should be avoided at all cost because is unreliable: empty('0') = true
static::fail('Expected exception to be thrown.'); | ||
|
||
if (PHP_VERSION_ID < 80000) { | ||
static::fail('Expected exception to be thrown.'); |
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.
why is it no longer the case here in PHP8?
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.
Because PHP8.0 function substr return only string -therefore, the parameter error typehint will never fall.
👌 |
Did they added some limitations for open source? I found this article and it's not very clear: https://devclass.com/2020/11/25/travis-ci-open-source-engagement/ |
they change of ownership and the direction is not clear. In the short run it's effectively very limited support and it's unlikely to change. They claim to still be able to offer support for popular OSS projects but I heard they won't decide anything there before another 2-3 months. TL:DR; Travis is indeed dead for OSS |
Ok, thanks for the report. |
No description provided.