-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Migrate function nodes to PHP 8 syntax #10214
Conversation
@@ -19,16 +19,14 @@ class AbsFunction extends FunctionNode | |||
/** @var SimpleArithmeticExpression */ | |||
public $simpleArithmeticExpression; |
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.
🤔 public properties are not migrated it seems
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 is best because that would not even pass the test suite:
1) Doctrine\Tests\ORM\Functional\QueryDqlFunctionTest::testFunctionAbs
TypeError: Cannot assign Doctrine\ORM\Query\AST\ArithmeticTerm to property Doctrine\ORM\Query\AST\Functions\AbsFunction::$simpleArithmeticExpression of type Doctrine\ORM\Query\AST\SimpleArithmeticExpression
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php:33
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:3531
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:3475
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:2282
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:1238
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:927
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:896
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:306
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:406
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query.php:244
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query.php:253
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/AbstractQuery.php:931
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/AbstractQuery.php:887
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/AbstractQuery.php:687
/home/greg/dev/doctrine-orm-split/major/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php:72
2) Doctrine\Tests\ORM\Functional\Ticket\GH7941Test::typesShouldBeConvertedForDQLFunctions
TypeError: Cannot assign Doctrine\ORM\Query\AST\PathExpression to property Doctrine\ORM\Query\AST\Functions\AbsFunction::$simpleArithmeticExpression of type Doctrine\ORM\Query\AST\SimpleArithmeticExpression
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php:33
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:3531
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:3475
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:2282
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:1233
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:927
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:896
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:306
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query/Parser.php:406
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query.php:244
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/Query.php:253
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/AbstractQuery.php:931
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/AbstractQuery.php:887
/home/greg/dev/doctrine-orm-split/major/lib/Doctrine/ORM/AbstractQuery.php:687
/home/greg/dev/doctrine-orm-split/major/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php:75
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 migrated all properties having Node
as a type hint, and left most other properties alone. I think this will deserve a separate PR if we decide to do something about it.
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.
That was a good call, I think. Many property types in the AST
namespace are inaccurate. Migrating the straightforward ones first is probably the best we can do.
9e67844
to
049e4b8
Compare
049e4b8
to
0d42e5e
Compare
@@ -13,8 +13,7 @@ | |||
*/ | |||
final class AvgFunction extends FunctionNode | |||
{ | |||
/** @var AggregateExpression */ | |||
private $aggregateExpression; | |||
private AggregateExpression $aggregateExpression; |
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.
Here I elected not to use AggregateExpression|null
+ assert inside getSql
: although the property is not set in the constructor, it is always set in parse()
. Otherwise, it can IMO stay uninitialized.
<code>null</code> | ||
<code>null</code> | ||
</PossiblyNullPropertyAssignmentValue> | ||
<PropertyNotSetInConstructor occurrences="3"> |
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.
Should we just ignore PropertyNotSetInConstructor
for the whole Functions
directory? After all, we deliberately work with the uninitialized state.
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.
Functions
and maybe more, I will check.
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 description provided.