-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Fix syntax error when using readonly with dnf #9512
Conversation
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.
Other than the one question LGTM!
Thanks for helping this was really a head scratcher as I had forgotten the BC layer
readonly(); | ||
readonly (); |
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 using readonly ()
with the whitespace now break? Or is it unnecessary due to the move to the parser?
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's just unnecessary since this is no longer special-cased. This should still work. I can keep it if you prefer.
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.
No harm keeping it then :)
7a5aaba
to
00dde7e
Compare
I have absolutely no clue why the pipeline failed. I could run that script locally with no problem. Rebased to try again. |
Is there maybe some caching issue on Travis? |
Did you run ext/tokenizer/tokenizer_data_gen.php? |
No changes are generated as no token has been added/removed. This script works fine in the CI too. However, if ($node instanceof Node\NullableType) {
return new Type(
[
...Type::fromNode($node->type)->types, // <-- Here
SimpleType::null(),
],
false
);
}
Which is very strange because Edit: Yep, definitely cause by my changes 😅 |
9fbea74
to
8b18d05
Compare
Ultimately, the core problem here is that gen_stub.php is required to be PHP 7.1 compatible, and someone introduced PHP 7.4 syntax into it. It needs to be changed to either be PHP 7.1 compatible, or the build system needs to be adjusted to not run gen_stub.php if the host PHP version is older than PHP 7.4. |
@nikic Ah, thanks. I guess Travis caches the Edit: Ah, of course. The grammar just hasn't been changed since the |
8b18d05
to
00dde7e
Compare
I'd suggest bumping to 7.4 at this point. One must be two LTS versions behind to have something older. Though in that case we'd also want to make more thorough use of it (yay property types). |
Regardless of whether we bump the PHP version requirement for gen_stubs.php, it probably makes sense to add an explicit version check, and fail fast for too old PHP versions. |
My plan was to bump the version requirement of gen_stub.php only for master as soon as I finish the PHP 8.2 related changes. That's why my preference would be to just replace the
Very good idea, 100% agreed! |
00dde7e
to
f269ae3
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.
LG
Thank you all :) 🚀 |
readonly (B&C)|A $l; | ||
private readonly A|(B&C) $m; | ||
private readonly (B&C)|A $n; | ||
} |
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.
<?php
class A
{
readonly static (A&B)|C $b; // valid
static readonly (A&B)|C $a; // invalid
}
these more simple static
forms are not in the test, I haven't tested it on this PR, but just to let you know :)
… names PHP 8.0 introduced `match` as a new reserved keyword and `mixed` as a new "other" reserved keyword. PHP 8.1 introduced `readonly` as a new reserved keyword, `never` as an "other" reserved keyword and `enum` as a soft reserved keyword. Note: `readonly` has an exception for when it is used as a function declaration name. Includes regenerated test case files. Refs: * https://wiki.php.net/rfc/match_expression_v2 * https://wiki.php.net/rfc/mixed_type_v2#backward_incompatible_changes * https://wiki.php.net/rfc/readonly_properties_v2 * https://wiki.php.net/rfc/enumerations * https://wiki.php.net/rfc/noreturn_type#backwards_incompatible_changes * php/php-src#7468 (readonly exception in PHP 8.1) * php/php-src#9512 (readonly exception PHP 8.2 follow-up)
Fixes GH-9500