Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions easy-coding-standard.neon
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ parameters:
- src/Types/Static_.php
- src/Types/String_.php
- src/Types/Void_.php
PhpCsFixer\Fixer\Import\OrderedImportsFixer:
- *tests/unit/Types/ContextFactoryTest.php
PhpCsFixer\Fixer\Import\SingleImportPerStatementFixer:
- *tests/unit/Types/ContextFactoryTest.php
PhpCsFixer\Fixer\Import\SingleLineAfterImportsFixer:
- *tests/unit/Types/ContextFactoryTest.php
15 changes: 7 additions & 8 deletions src/Types/ContextFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private function extractUseStatements(\ArrayIterator $tokens)
$groupedNs = '';
$currentNs = '';
$currentAlias = null;
$state = "start";
$state = 'start';

$i = 0;
while ($tokens->valid()) {
Expand All @@ -233,7 +233,7 @@ private function extractUseStatements(\ArrayIterator $tokens)
$tokenId = is_string($currentToken) ? $currentToken : $currentToken[0];
$tokenValue = is_string($currentToken) ? null : $currentToken[1];
switch ($state) {
case "start":
case 'start':
switch ($tokenId) {
case T_STRING:
case T_NS_SEPARATOR:
Expand All @@ -255,7 +255,7 @@ private function extractUseStatements(\ArrayIterator $tokens)
break;
}
break;
case "start-alias":
case 'start-alias':
switch ($tokenId) {
case T_STRING:
$currentAlias .= $tokenValue;
Expand All @@ -268,7 +268,7 @@ private function extractUseStatements(\ArrayIterator $tokens)
break;
}
break;
case "grouped":
case 'grouped':
switch ($tokenId) {
case T_STRING:
case T_NS_SEPARATOR:
Expand All @@ -290,7 +290,7 @@ private function extractUseStatements(\ArrayIterator $tokens)
break;
}
break;
case "grouped-alias":
case 'grouped-alias':
switch ($tokenId) {
case T_STRING:
$currentAlias .= $tokenValue;
Expand All @@ -309,18 +309,17 @@ private function extractUseStatements(\ArrayIterator $tokens)
}
}

if ($state == "end") {
if ($state === 'end') {
break;
}

$tokens->next();
}

if ($groupedNs != $currentNs) {
if ($groupedNs !== $currentNs) {
$extractedUseStatements[$currentAlias ?: $currentNs] = $currentNs;
}


return $extractedUseStatements;
}
}