Skip to content

Commit

Permalink
[PHP 8.0 ] No space annotatation and attributes (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jun 16, 2021
1 parent 2418778 commit 8665534
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
4 changes: 3 additions & 1 deletion packages/NodeCollector/NodeCollector/NodeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,9 @@ private function collectArray(Array_ $array): void
return;
}

$this->arrayCallablesByTypeAndMethod[$arrayCallable->getClass()][strtolower($arrayCallable->getMethod())][] = $arrayCallable;
$this->arrayCallablesByTypeAndMethod[$arrayCallable->getClass()][strtolower(
$arrayCallable->getMethod()
)][] = $arrayCallable;
}

private function addMethod(ClassMethod $classMethod): void
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Fixture;

final class AnnotationConvertedAndKeepDocblock
{
/**
* @inject
* @AlternativeApproach
* @var SomeType
*/
public $someDependency;
}

?>
-----
<?php

namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Fixture;

final class AnnotationConvertedAndKeepDocblock
{
/**
* @AlternativeApproach
* @var SomeType
*/
#[\Nette\DI\Attributes\Inject]
public $someDependency;
}

?>
2 changes: 1 addition & 1 deletion rules/Php80/NodeResolver/SwitchExprsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class SwitchExprsResolver
*/
public function resolve(Switch_ $switch): array
{
$condAndExpr = [];
$condAndExpr = [];
$collectionEmptyCasesCond = [];

foreach ($switch->cases as $key => $case) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,23 @@ public function process(ContainerBuilder $containerBuilder): void
continue;
}

if (!class_exists($class)) {
if (! class_exists($class)) {
throw new ShouldNotHappenException(
sprintf('Rector rule "%s" not found, please verify that the class exists and is autoloadable.', $class)
sprintf(
'Rector rule "%s" not found, please verify that the class exists and is autoloadable.',
$class
)
);
}

if (! is_a($class, RectorInterface::class, true)) {
throw new ShouldNotHappenException(
sprintf('Rector rule "%s" should extend "%s" or implement "%s".', $class, AbstractRector::class, RectorInterface::class)
sprintf(
'Rector rule "%s" should extend "%s" or implement "%s".',
$class,
AbstractRector::class,
RectorInterface::class
)
);
}
}
Expand Down

0 comments on commit 8665534

Please sign in to comment.