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

Improper formatting of PHP function namespaces #2887

Closed
danon opened this issue May 3, 2021 · 0 comments · Fixed by #2889
Closed

Improper formatting of PHP function namespaces #2887

danon opened this issue May 3, 2021 · 0 comments · Fixed by #2889

Comments

@danon
Copy link
Contributor

danon commented May 3, 2021

Information:

  • Prism version: Newest

Description
While prism understands namespace declaration (namespace Hello), namespace definition (use Hello) and using classes with namespaces (new \Hello\Hi(); and \Hello\Hi::class), it doesn't understand function namespaces. In PHP, functions can be namespaced as well.

mb_string(); // call to a global function
\mb_string(); // namespace \ is global
\a\b\c\mb_string(); // function in \a\b\c namespace

In Prism.js, the namespace parts \a\b\c are makred as .token.plain, which I don't believe they are.

Technical tips:
Only calls to methods need this checks - so it must be \w+\\\w+\(\). Namespaces and functions cannot start with letter. There can't be a space between namespaces and functions as well as between namespaces and backslashes.

Example
https://prismjs.com/test.html#language=php&text=%3Cphp%0A%0Aecho%20%5Cmy%5Chello%5Cmy_function()%3B%0A

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

Successfully merging a pull request may close this issue.

2 participants