Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[WIP][Routing] Fix the annotation loader taking a class constant as a beginning of a class name #18634

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

Closed
wants to merge 1 commit into from

Conversation

jakzal
Copy link
Contributor

@jakzal jakzal commented Apr 25, 2016

Q A
Branch? 2.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #18633
License MIT
Doc PR -

Hold on with the merge. I'd like to see if there should be more test cases added first.

@@ -96,6 +96,8 @@ protected function findClass($file)
$token = $tokens[$i];

if (!isset($token[1])) {
$class = false;
Copy link

@mkruk-u2 mkruk-u2 Apr 26, 2016

Choose a reason for hiding this comment

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

I'm not sure if this really fixes the problem.

Example:

public function doBar()
{
    $isAbc = MyClass::class === ABC;
}

I'll find "ABC" as a class name.

It seems that the problm is on line 114/116, i.e. the condition:

if (T_CLASS === $token[0]) {

because having T_CLASS token doesn't really mean that we've found a class definition.
Until PHP token_get_all() function can differentiate between class MyClass { ... (which is really a class definition), and MyClass::class (which isn't), I think this condition needs to be extended, e.g.:

$previousTokenIsPaamayimNekudotayim = isset($tokens[$i - 1]) && T_PAAMAYIM_NEKUDOTAYIM === $tokens[$i - 1][0];
if (T_CLASS === $token[0] && !$previousTokenIsPaamayimNekudotayim) {
    $class = true;
}

Copy link
Contributor Author

@jakzal jakzal Apr 26, 2016

Choose a reason for hiding this comment

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

As I said this is not ready yet. Thanks for feedback so far!

@jakzal
Copy link
Contributor Author

jakzal commented May 13, 2016

I'm offline till June. If anyone wants to take over this PR, feel free to do so. Otherwise I'll finish this off when I'm back.

@nicolas-grekas
Copy link
Member

Continued in #18907
Thank you @jakzal

@jakzal jakzal deleted the routing-annotation-file-loader branch June 28, 2016 08:27
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.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.