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

permit FQN forms for the global function names #41

Merged
merged 1 commit into from
Dec 9, 2020

Conversation

quasilyte
Copy link
Contributor

Since FQN names always resolve to the name without leading '',
we can start with this and implement real function namespaces
support later (https://www.php.net/manual/en/language.namespaces.rules.php).

This change makes it possible to compile PHP projects that refer
to global functions using full qualified names.
Here is an example: https://github.com/symfony/polyfill-ctype/blob/main/Ctype.php#L36

compiler/gentree.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@eugene536 eugene536 left a comment

Choose a reason for hiding this comment

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

I think that supporting functions in namespaces is not a huge deal and we can implement it.
But if you don't consider it useful right now just left it as it is.

@quasilyte
Copy link
Contributor Author

@eugene536 I'm mostly concerned about unqualified function names resolution that can't be done in gentree correctly.
foo() call can refer to the global \foo function or foo function inside the current namespace. Until we have all functions of that namespace available, I don't think it's possible to resolve the foo() call properly in the context of namespaces. It would require more changes than the proposed small fix.

AlexK0
AlexK0 previously approved these changes Nov 28, 2020
@quasilyte quasilyte force-pushed the quasilyte/permit_fqn_global_func_names branch from 7db304d to 9c638ea Compare December 3, 2020 15:20
@quasilyte quasilyte changed the title permit FQN forms for the global function names WIP: permit FQN forms for the global function names Dec 3, 2020
@quasilyte quasilyte force-pushed the quasilyte/permit_fqn_global_func_names branch from 9c638ea to e711e7d Compare December 3, 2020 18:43
Since FQN names always resolve to the name without leading '\',
we can start with this and implement real function namespaces
support later (https://www.php.net/manual/en/language.namespaces.rules.php).

This change makes it possible to compile PHP projects that refer
to global functions using full qualified names.
Here is an example: https://github.com/symfony/polyfill-ctype/blob/main/Ctype.php#L36
@quasilyte quasilyte force-pushed the quasilyte/permit_fqn_global_func_names branch from e711e7d to 7eee2f2 Compare December 3, 2020 19:01
@quasilyte
Copy link
Contributor Author

Rebased, tested for diff.

@quasilyte quasilyte changed the title WIP: permit FQN forms for the global function names permit FQN forms for the global function names Dec 3, 2020
@quasilyte quasilyte added this to the 11/12/2020 milestone Dec 9, 2020
@eugene536 eugene536 merged commit f4e758f into master Dec 9, 2020
@eugene536 eugene536 deleted the quasilyte/permit_fqn_global_func_names branch December 9, 2020 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants