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

Unhandled native identifiers #113

Closed
mgrip opened this issue Feb 14, 2018 · 4 comments
Closed

Unhandled native identifiers #113

mgrip opened this issue Feb 14, 2018 · 4 comments
Assignees
Labels

Comments

@mgrip
Copy link

mgrip commented Feb 14, 2018

The list of valid php type for type hinting function calls is here: http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration.types

It appears the parser currently handles everything except for array and callable (it interprets these as user-defined fully qualified names

@mgrip
Copy link
Author

mgrip commented Feb 14, 2018

Hm looks like this might actually be intentional? https://github.com/glayzzle/php-parser/blob/master/src/parser/function.js#L242

I might just not understand how name is supposed to be interpreted here. For array and callable the value of name is \array and \callable, as opposed the other types which just end up as int, string, etc

@ichiriac
Copy link
Member

sorry, I did not have time to check on this issue, I'll be back on it later, but I think it was intentional because an array should be seen as a typing, and the FQN fully qualified name force to search the class from the root namespace, that's why the \array name. The int and string are forget classes.

image

My first approach was to make an interpreter so this interpretation was in order to make easier the implementation of an interpreter, but in this case it's breaking the file representation - I may certainly introduce a new AST nody type like a ScalarType

@ichiriac ichiriac self-assigned this Feb 26, 2018
@ichiriac ichiriac added this to the 3.0.0 milestone Mar 6, 2018
@alexander-akait
Copy link
Collaborator

@ichiriac also we have problem with

function int(int $var) {}
function int(iNt $test) {}

It is hard to detect when people use classiNt when int scalar. I think introduce new nod will be great and solve the problem.

@ichiriac ichiriac added the high-pri High Priority bug label Sep 30, 2018
@ichiriac ichiriac reopened this Oct 21, 2018
@ichiriac ichiriac added the RELEASE-READY Waiting to release label Oct 21, 2018
@ichiriac
Copy link
Member

released under php-parser@3.0.0-prerelease.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants