Skip to content

DynamicMethodReturnTypeExtension: Array shapes from SQL queries #4395

Answered by ondrejmirtes
voku asked this question in Support
Discussion options

You must be logged in to vote

Is there a better way to fetch strings from the code? I quick&ditry hacked this with via "file()" + "preg_match()" because there is only this one SQL string in the "ViewFactory::fetchByFilterArray"-method. :-/

You should use the power of the AST. MethodReflection will tell you the declaring class, which in turn will tell you the file name. You should then parse the file with PHPStan\Parser\Parser (ask for it in the constructor) and traverse the AST with PHP-Parser's NodeTraverser.

use this "fetchByFilterArray"-methods in "DataTable"-classes

I don't get it, are you asking about array shapes? https://phpstan.org/writing-php-code/phpdoc-types#array-shapes

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@voku
Comment options

@ondrejmirtes
Comment options

@ondrejmirtes
Comment options

@voku
Comment options

@ondrejmirtes
Comment options

Answer selected by ondrejmirtes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
2 participants