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

PSR12.Classes.ClassInstantiation false positive when instantiating class from array index #2047

Closed
TomasVotruba opened this issue Jun 7, 2018 · 2 comments
Milestone

Comments

@TomasVotruba
Copy link
Contributor

TomasVotruba commented Jun 7, 2018

Version: 3.3.0

Sniff: PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\ClassInstantiationSniff.MissingParenthesis

             $configuration['layout'],
             $configuration['route_prefix'],
             $configuration['object'] ?? File::class,
-            isset($configuration['object_sorter']) ? new $configuration['object_sorter']() : new FileNameObjectSorter()
+            isset($configuration['object_sorter']) ? new $configuration()['object_sorter']() : new FileNameObjectSorter()
@gsherwood gsherwood added this to the 3.3.1 milestone Jun 7, 2018
@gsherwood gsherwood changed the title False positive on new $variable PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\ClassInstantiationSniff.MissingParenthesis PSR12.Classes.ClassInstantiation false positive when instantiating class from array index Jun 7, 2018
gsherwood added a commit that referenced this issue Jun 7, 2018
@gsherwood
Copy link
Member

Thanks for reporting this. The sniff now supports array indexes properly.

@TomasVotruba
Copy link
Contributor Author

Thanks for fast fix 🥇

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

No branches or pull requests

2 participants