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

Mark SqlWalker methods as not deprecated #10540

Merged
merged 1 commit into from
Feb 26, 2023

Conversation

stof
Copy link
Member

@stof stof commented Feb 24, 2023

phpstan treats implementations of deprecated methods of an interface as being deprecated themselves by default. However, SqlWalker does not intend to deprecate all those methods that are deprecated in TreeWalker, as they are moved down. Marking them as not deprecated will avoid reporting usages of deprecated APIs when implementing custom DQL functions for instance.

See phpstan/phpstan#7422 for the discussion about that kind of cases in the phpstan repository, which contains links justifying the current behavior of phpstan.
Without this @not-deprecated (or with it but without the dev version of phpstan as support for it is merged but not released yet), I get such error in my project when implementing custom DQL functions (which work with the SqlWalker API to generate the SQL):

 ------ --------------------------------------------------------------------------------------- 
  Line   src/Incenteev/WebBundle/Doctrine/Query/AnyUuid.php                                     
 ------ --------------------------------------------------------------------------------------- 
  32     Call to deprecated method walkInputParameter() of class Doctrine\ORM\Query\SqlWalker:  
         This method will be removed from the interface in 3.0.                                 
 ------ --------------------------------------------------------------------------------------- 

But while it will indeed be removed from the TreeWalker interface in 3.0, it won't be removed from SqlWalker.

@mpdude
Copy link
Contributor

mpdude commented Feb 24, 2023

Would it make sense to have a dedicated sub-interface for the concept that SqlWalker implements, which seems to be more specific than being a tree walker?

If so, would that solve the issue as well?

@stof
Copy link
Member Author

stof commented Feb 24, 2023

As long as that new interface extends TreeWalker (which is needed for BC) which contains the deprecated methods, the issue of having a non-deprecated method overriding/implementing a deprecated method would still be there.

And introducing an interface for the SqlWalker would be a bad idea. If AST nodes were written against a SqlWalkerInterface instead of the SqlWalker for their conversion to SQL, adding new features in DQL would be a BC break any time it would require adding a new method in the SqlWalker to handle some new kind of AST node.
If you look at SqlWalker vs TreeWalker deprecated methods, you will see that SqlWalker has additional walk* methods (the ones added later that doctrine/orm 2.0)

@derrabus
Copy link
Member

Interesting, I didn't know about that annotation.

@stof Can you make PHPCS happy please?


Would it make sense to have a dedicated sub-interface for the concept that SqlWalker implements, which seems to be more specific than being a tree walker?

No, we have no use for a SqlWalker interface.

@derrabus derrabus added this to the 2.14.2 milestone Feb 24, 2023
@mpdude
Copy link
Contributor

mpdude commented Feb 24, 2023

@stof thank you for the explanations, makes sense

@stof
Copy link
Member Author

stof commented Feb 24, 2023

@derrabus this annotation is quite new (the solution was suggested by Ondrej a while ago but the implementation was done today)

phpstan treats implementations of deprecated methods of an interface as being deprecated themselves by default.
However, SqlWalker does not intend to deprecate all those methods that are deprecated in TreeWalker, as they are
moved down. Marking them as not deprecated will avoid reporting usages of deprecated APIs when implementing
custom DQL functions for instance.
@stof stof force-pushed the stof-sqlwalker-not-deprecated branch from 27d8331 to 8838564 Compare February 24, 2023 20:10
@stof
Copy link
Member Author

stof commented Feb 24, 2023

@derrabus I fixed the order of phpdoc annotations to make phpcs happy.

@derrabus derrabus merged commit 9485d4d into 2.14.x Feb 26, 2023
@derrabus derrabus deleted the stof-sqlwalker-not-deprecated branch February 26, 2023 14:21
derrabus added a commit to derrabus/orm that referenced this pull request Feb 28, 2023
* 2.14.x:
  Ignore the cache dir of PHPUnit 10 (doctrine#10546)
  Make data providers static (doctrine#10544)
  Bump dev tools (doctrine#10541)
  Mark SqlWalker methods as not deprecated (doctrine#10540)
  docs: consistency order for docblock in association mapping (doctrine#10534)
  Correct use of PHP attribute
  fix typo in faq.rst (doctrine#10526)
  fix: use executeStatement in SchemaTool (doctrine#10516)
  Write a test in a more specific way
  Put up a warning sign that mapping may not be inherited from transient classes (doctrine#10392)
  Avoid unnecessary information in query hints to improve query cache hit ratio
derrabus added a commit that referenced this pull request Feb 28, 2023
* 2.14.x:
  Ignore the cache dir of PHPUnit 10 (#10546)
  Make data providers static (#10544)
  Bump dev tools (#10541)
  Mark SqlWalker methods as not deprecated (#10540)
  docs: consistency order for docblock in association mapping (#10534)
  Correct use of PHP attribute
  fix typo in faq.rst (#10526)
  fix: use executeStatement in SchemaTool (#10516)
  Write a test in a more specific way
  Put up a warning sign that mapping may not be inherited from transient classes (#10392)
  Avoid unnecessary information in query hints to improve query cache hit ratio
derrabus added a commit to derrabus/orm that referenced this pull request Feb 28, 2023
* 2.15.x:
  Ignore the cache dir of PHPUnit 10 (doctrine#10546)
  Make data providers static (doctrine#10545)
  Make data providers static (doctrine#10544)
  Bump dev tools (doctrine#10541)
  Mark SqlWalker methods as not deprecated (doctrine#10540)
  docs: consistency order for docblock in association mapping (doctrine#10534)
  Correct use of PHP attribute
  fix typo in faq.rst (doctrine#10526)
  fix: use executeStatement in SchemaTool (doctrine#10516)
  Write a test in a more specific way
  Put up a warning sign that mapping may not be inherited from transient classes (doctrine#10392)
  Avoid unnecessary information in query hints to improve query cache hit ratio
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.

3 participants