-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
TASK: Support PHP8 types and class property promotion #2404
Conversation
Apparently StyleCI does not yet support PHP 8 syntax 🤷♂️ |
Neos.Flow/Tests/Functional/ObjectManagement/Fixtures/ClassWithUnionTypes.php
Outdated
Show resolved
Hide resolved
if (count($attribute->getArguments()) > 0) { | ||
$argumentsAsString = []; | ||
foreach ($attribute->getArguments() as $argumentName => $argumentValue) { | ||
$renderedArgumentValue = var_export($argumentValue, true); |
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.
Wondering why we didn't use var_export()
in the other method where we render an array(x => y, ...)
manually?
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.
Which "other method" do you mean?
Neos.Flow/Classes/Persistence/Doctrine/Mapping/Driver/FlowAnnotationDriver.php
Show resolved
Hide resolved
'@\Neos\Flow\Annotations\Validate(type="bar1", argumentName="foo1")' | ||
], | ||
[ | ||
new Validate(['type' => 'bar1', 'options' => ['minimum' => 2]]), | ||
new Validate(null, 'bar1', ['minimum' => 2]), |
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.
This shows that the choice to have argumentName
as the anonymous argument was probably suboptimal. I would rather consider the validate type to be anonmyous - maybe something to consider for next major?
Question basically is: Are Validate annotations more commonly used on method arguments, or on properties? If on method arguments, is more straightforward to use @Flow\Validate("NotEmpty", argumentName="$myArg")
rather than @Flow\Validate("$myArg", type="NotEmpty")
?
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 idea on where validation is used more. But I have no issue with @Flow\Validate("$myArg", type="NotEmpty")
, TBH. What is not straighforward with that?
I generally like this but consider it a bit breaky especially since the annotation api changed. Also it would be great to be able to convert the doctrine annotations at the same time. Not sure about how fast Doctrine will be to support annotations but imho this would be great for Flow8. |
As of doctrine/orm 2.9.x PHP attributes are supported, BUT their changes are breaking for us - see doctrine/orm#8753 |
Update: As of doctrine/orm 2.9.3+ - which is allowed now in 7.0+ as of #2496 - PHP 8 attributes work now |
Neos.Flow/Tests/Functional/ObjectManagement/Fixtures/PHP8/ClassWithPhpAttributes.php
Outdated
Show resolved
Hide resolved
Neos.Flow/Tests/Functional/ObjectManagement/Fixtures/PHP8/SampleAttribute.php
Outdated
Show resolved
Hide resolved
Note: I should propably rebase this PR to clean up the commit history in relation to #2468 and then start with a clean review cycle |
Also avoids registering those classes if not on PHP8 or later.
b96eb37
to
78818d8
Compare
Rebased cleanly now and also extracted the docblock-preserving commit into #2533 |
Given the psalm tests fail with the PHP8 methods - maybe it makes more sense to run psalm with latest PHP version, rather than lowest? Regarding the lowest-deps build:
After some digging it seems to be due to doctrine/annotations and the newly used |
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 fine to me. Wondering a bit if any of the new features will have impact on eg AOP and if we need to do something about it. but I guess it should be fine for now.
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.
From reading it looks fine to me.
I am a bit/very much in doubt how to properly test it deeper, to give valuable feedback
We should have both in optimally, but it only is an issue if you can't install latest doctrine/annotations in your setup for some reason. In that case you will see an error like above (in DocParser) instead of composer rejecting to install things in the worst case.
Unless you have some code base using PHP8 types (union / nullable) and/or classes with property promotion, it's impossible to test deeper really :) So no worries. If you have some idea for test fixtures, i.e. exactly such classes (like https://github.com/neos/flow-development-collection/pull/2404/files#diff-d7acfbcf9e4274f911c5c5f5f23ae6f8c8cecf4d64ebcc52d40b04bc050779b3), then that would be a great addition to cover potential cases that break compilation Edit: PS: the open TODO actually belongs to the PHP8 Attributes issue... PPS: Created #2537 |
7.3 / lowest fails due to Guzzle vs. Behat… |
This change makes sure that PHP8 union types, nullable types and promoted properties can be used with proxied classes.
Depends on #2287
Related to #2468
Related to #2233