Closed soullivaneuh closed 5 years ago
So i removed this three fixer causing the issue:
<exclude name="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<exclude name="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<exclude name="SlevomatCodingStandard.Namespaces.UseSpacing"/>
Now I have:
Processing UsernameChangeListener.php [PHP => 255 tokens in 38 lines]... DONE in 4ms (1 fixable violations)
=> Fixing file: 84/1 violations remaining [made 1 pass]... [PHP => 235 tokens in 40 lines]...
Fatal error: Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: Undefined index: scope_closer in /home/developer/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php on line 207 in /home/developer/.composer/vendor/squizlabs/php_codesniffer/src/Runner.php:600
Stack trace:
#0 /home/developer/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php(207): PHP_CodeSniffer\Runner->handleErrors(8, 'Undefined index...', '/home/developer...', 207, Array)
#1 /home/developer/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php(149): SlevomatCodingStandard\Helpers\UseStatementHelper::getUseStatementPointers(Object(PHP_CodeSniffer\Files\LocalFile), 0)
#2 /home/developer/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php(111): SlevomatCodingStandard\Helpers\UseStatementHelper::getFileUseStatements(Object(PHP_CodeSniffer\Files\LocalFile))
#3 /home/developer/.composer in /home/developer/.composer/vendor/squizlabs/php_codesniffer/src/Runner.php on line 600
Related file:
<?php
declare(strict_types=1);
namespace AppBundle\Listener;
use AppBundle\Entity\User;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\OnFlushEventArgs;
final class UsernameChangeListener implements EventSubscriber
{
/**
* {@inheritdoc}
*/
public function getSubscribedEvents()
{
return [
'onFlush',
];
}
public function onFlush(OnFlushEventArgs $eventArgs): void
{
$em = $eventArgs->getEntityManager();
$uow = $em->getUnitOfWork();
foreach ($uow->getScheduledEntityUpdates() as $entity) {
if ($entity instanceof User && \array_key_exists('username', $uow->getEntityChangeSet($entity))) {
[$oldUsername, $newUsername] = $uow->getEntityChangeSet($entity)['username'];
$queryFormat = <<<'SQL'
UPDATE revisions SET username = '%s' WHERE username = '%s'
SQL;
$em->getConnection()->exec(\sprintf($queryFormat, $newUsername, $oldUsername));
}
}
}
}
I'm sorry I'm not able to reproduce the error. Please provide failing test and then reopen the issue.
@theofidry I see you had a similar problem in #526.
Did you find any clue?
Nope, couldn't find the time to dig into it at all :/
@soullivaneuh @theofidry It's probably bug in PHPCS itself.
Here is a dump of $token
when the exception occur:
array(8) {
["code"]=>
int(361)
["type"]=>
string(7) "T_CLASS"
["content"]=>
string(5) "class"
["line"]=>
int(11)
["column"]=>
int(7)
["length"]=>
int(5)
["level"]=>
int(0)
["conditions"]=>
array(0) {
}
}
Yes, it's really bug in PHPCS itself. T_CLASS
token should have scope attributes.
It's probably bug in PHPCS itself.
@kukulich Maybe. The scope_closer
existence is not checked on the failing source file. Do you expect to always have it?
Yes, because you cannot write class definition without {
and }
Right, I think I found the related issue: https://github.com/squizlabs/PHP_CodeSniffer/issues/2142#issuecomment-476140225
Thanks for your time @kukulich!
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
The file crashing the fixer: