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

LowercaseStaticReferenceFixer - Fix "Parent" word in namespace #3937

Merged
merged 1 commit into from Jul 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Fixer/Casing/LowercaseStaticReferenceFixer.php
Expand Up @@ -86,7 +86,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
}

$prevIndex = $tokens->getPrevMeaningfulToken($index);
if ($tokens[$prevIndex]->isGivenKind([T_CONST, T_DOUBLE_COLON, T_FUNCTION, T_OBJECT_OPERATOR, T_PRIVATE, T_PROTECTED, T_PUBLIC])) {
if ($tokens[$prevIndex]->isGivenKind([T_CONST, T_DOUBLE_COLON, T_FUNCTION, T_NAMESPACE, T_NS_SEPARATOR, T_OBJECT_OPERATOR, T_PRIVATE, T_PROTECTED, T_PUBLIC])) {
Copy link
Member

Choose a reason for hiding this comment

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

why T_NAMESPACE? I don't see test for it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will handle <?php namespace Foo\Parent; case, but it wold be handed by T_NS_SEPARATOR in next token search, so you're right - I've added one more test.

continue;
}

Expand Down
9 changes: 9 additions & 0 deletions tests/Fixer/Casing/LowercaseStaticReferenceFixerTest.php
Expand Up @@ -137,6 +137,12 @@ public function provideFixCases()
[
'<?php class A { const PARENT = 42; }',
],
[
'<?php namespace Foo\Parent;',
],
[
'<?php namespace Parent\Foo;',
],
];
}

Expand Down Expand Up @@ -169,6 +175,9 @@ public function provideFix70Cases()
[
'<?php class Foo extends Bar { public function baz() : Self\Qux {} }',
],
[
'<?php namespace Parent;',
],
];
}

Expand Down