Skip to content

Commit

Permalink
make use of Symfony 5.2 requried attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed May 10, 2021
1 parent ba21830 commit b003e60
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 20 deletions.
9 changes: 4 additions & 5 deletions config/set/php80.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Rector\Arguments\ValueObject\ArgumentAdder;
use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector;
use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\Class_\StringableForToStringRector;
use Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector;
Expand Down Expand Up @@ -37,10 +36,10 @@
$services->set(StaticCallToFuncCallRector::class)
->call('configure', [
StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => ValueObjectInliner::inline([
new StaticCallToFuncCall('Nette\Utils\Strings', 'startsWith', 'str_starts_with'),
new StaticCallToFuncCall('Nette\Utils\Strings', 'endsWith', 'str_ends_with'),
new StaticCallToFuncCall('Nette\Utils\Strings', 'contains', 'str_contains'),
])
new StaticCallToFuncCall('Nette\Utils\Strings', 'startsWith', 'str_starts_with'),
new StaticCallToFuncCall('Nette\Utils\Strings', 'endsWith', 'str_ends_with'),
new StaticCallToFuncCall('Nette\Utils\Strings', 'contains', 'str_contains'),
]),
]);

$services->set(StringableForToStringRector::class);
Expand Down
12 changes: 0 additions & 12 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -494,23 +494,11 @@ parameters:
-
message: '#Function "function_exists\(\)" cannot be used/left in the code#'
path: src/functions/node_helper.php
<<<<<<< HEAD
<<<<<<< HEAD

# temporary out of order after rector-src extract
- '#Class like namespace "Rector\\(.*?)" does not follow PSR\-4 configuration in composer\.json#'
<<<<<<< HEAD
=======
>>>>>>> 5288d92bc (bump workflow version to PHP 8)
=======

# temporary out of order after rector-src extract
- '#Class like namespace "Rector\\(.*?)" does not follow PSR\-4 configuration in composer\.json#'
>>>>>>> 8f4d07170 (skip static error)
=======

# bug in PHP 8, fix in dev-main
-
message: '#Do not call parent method if parent method is empty#'
path: packages/BetterPhpDocParser/PhpDoc/DoctrineAnnotationTagValueNode.php
>>>>>>> 83f18a5ac (fixup! [PHP 8] Use promoted properties)
4 changes: 3 additions & 1 deletion rules/CodingStyle/ClassNameImport/ShortNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
use ReflectionClass;
use Symfony\Contracts\Service\Attribute\Required;
use Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;

final class ShortNameResolver
Expand Down Expand Up @@ -89,8 +90,9 @@ public function __construct(

/**
* Avoids circular reference
* @required
*/

#[Required]
public function autowireShortNameResolver(PhpDocInfoFactory $phpDocInfoFactory): void
{
$this->phpDocInfoFactory = $phpDocInfoFactory;
Expand Down
3 changes: 3 additions & 0 deletions rules/DependencyInjection/NodeFactory/InjectMethodFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public function createFromTypes(array $objectTypes, string $className, string $f

if ($framework === FrameworkName::SYMFONY) {
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod);

// @todo depends on PHP version
// add attribute on PHP 8+ and Symfony 5.2+
$phpDocInfo->addPhpDocTagNode(new PhpDocTagNode('@required', new GenericTagValueNode('')));
}

Expand Down
1 change: 0 additions & 1 deletion rules/Naming/NamespaceMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Rector\Naming;

use Nette\Utils\Strings;
use Rector\Renaming\ValueObject\RenamedNamespace;

final class NamespaceMatcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Rector\NodeTypeResolver\NodeTypeResolver;
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
use Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface;
use Symfony\Contracts\Service\Attribute\Required;

final class PHPUnitDataProviderParamTypeInferer implements ParamTypeInfererInterface
{
Expand Down Expand Up @@ -67,8 +68,9 @@ public function __construct(

/**
* Prevents circular reference
* @required
*/

#[Required]
public function autowirePHPUnitDataProviderParamTypeInferer(NodeTypeResolver $nodeTypeResolver): void
{
$this->nodeTypeResolver = $nodeTypeResolver;
Expand Down

0 comments on commit b003e60

Please sign in to comment.