Skip to content
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

Merged
merged 1 commit into from
Nov 11, 2022

Conversation

greg0ire
Copy link
Member

No description provided.

@@ -19,16 +19,14 @@ class AbsFunction extends FunctionNode
/** @var SimpleArithmeticExpression */
public $simpleArithmeticExpression;
Copy link
Member Author

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

Copy link
Member Author

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

Copy link
Member Author

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.

Copy link
Member

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.

@greg0ire greg0ire force-pushed the php8-migration branch 2 times, most recently from 9e67844 to 049e4b8 Compare November 10, 2022 20:49
@@ -13,8 +13,7 @@
*/
final class AvgFunction extends FunctionNode
{
/** @var AggregateExpression */
private $aggregateExpression;
private AggregateExpression $aggregateExpression;
Copy link
Member Author

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.

@greg0ire greg0ire marked this pull request as ready for review November 10, 2022 21:03
<code>null</code>
<code>null</code>
</PossiblyNullPropertyAssignmentValue>
<PropertyNotSetInConstructor occurrences="3">
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derrabus derrabus merged commit a8445c9 into doctrine:3.0.x Nov 11, 2022
@greg0ire greg0ire deleted the php8-migration branch November 11, 2022 10:23
@derrabus derrabus added this to the 3.0.0 milestone Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants