mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 00:40:52 +00:00
Merge pull request #35 from TomasVotruba/nette-trigger-error
[TriggerExtractor] add simple check for the other message
This commit is contained in:
commit
cce616b641
|
@ -66,17 +66,30 @@ final class TriggerMessageResolver
|
|||
$words = explode(' ', $message);
|
||||
|
||||
foreach ($words as $word) {
|
||||
// is method()
|
||||
if (Strings::endsWith($word, '()') && strlen($word) > 2) {
|
||||
// doesn't include class in the beggning
|
||||
if (! Strings::startsWith($word, $class)) {
|
||||
$word = $class . '::' . $word;
|
||||
}
|
||||
}
|
||||
|
||||
$completeMessage .= ' ' . $word;
|
||||
$completeMessage .= ' ' . $this->prependClassToMethodCallIfNeeded($word, $class);
|
||||
}
|
||||
|
||||
return trim($completeMessage);
|
||||
}
|
||||
|
||||
private function prependClassToMethodCallIfNeeded(string $word, string $class): string
|
||||
{
|
||||
// is method()
|
||||
if (Strings::endsWith($word, '()') && strlen($word) > 2) {
|
||||
// doesn't include class in the beggning
|
||||
if (! Strings::startsWith($word, $class)) {
|
||||
return $class . '::' . $word;
|
||||
}
|
||||
}
|
||||
|
||||
// is method('...')
|
||||
if (Strings::endsWith($word, '\')')) {
|
||||
// doesn't include class in the beggning
|
||||
if (! Strings::startsWith($word, $class)) {
|
||||
return $class . '::' . $word;
|
||||
}
|
||||
}
|
||||
|
||||
return $word;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,11 +32,17 @@ final class TriggerExtractorTest extends AbstractContainerAwareTestCase
|
|||
$this->assertCount(2, $deprecations);
|
||||
|
||||
$setClassToSetFacoryDeprecation = $deprecations[0];
|
||||
$injectMethodToTagDeprecation = $deprecations[1];
|
||||
|
||||
$this->assertSame(
|
||||
'Nette\DI\Definition::setClass() second parameter $args is deprecated,'
|
||||
. ' use Nette\DI\Definition::setFactory()',
|
||||
$setClassToSetFacoryDeprecation
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'Nette\DI\Definition::setInject() is deprecated, use Nette\DI\Definition::addTag(\'inject\')',
|
||||
$injectMethodToTagDeprecation
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user