Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #4355 GlobalNamespaceImportFixer - Introduction (gharlan)
This PR was squashed before being merged into the 2.16-dev branch (closes #4355). Discussion ---------- GlobalNamespaceImportFixer - Introduction * closes #1309 * refs #2166 (this pr does not differientiate between native/non-native elements, only between global/non-global) * closes #2739 * closes #4347 --- The fixer can import global classes/functions/constants: Input: ```php <?php namespace Foo; if (\count($x)) { /** @var \DateTimeImmutable $d */ $d = new \DateTimeImmutable(); $p = \M_PI; } ``` Output: ```php <?php namespace Foo; use DateTimeImmutable; use function count; use const M_PI; if (count($x)) { /** @var DateTimeImmutable $d */ $d = new DateTimeImmutable(); $p = M_PI; } ``` Global functions/constants without leading `\` are not imported. The slash can be added by `Native(Constant|Function)InvocationFixer` before. The fixer can also do the reverse fix, adding the backslash to imported global classes/functions/constants. But the fixer does not remove the imports, this can be done by `NoUnusedImportsFixer`. Commits ------- 41fe1f4 GlobalNamespaceImportFixer - Introduction
- Loading branch information