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
2 changes: 1 addition & 1 deletion .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
-
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
php-version: 8.4
coverage: none

- uses: "ramsey/composer-install@v2"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
-
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
php-version: 8.4
coverage: none

- uses: "ramsey/composer-install@v2"
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"description": "Rector upgrades rules for Doctrine",
"require": {
"php": ">=8.3",
"php": ">=8.4",
"symfony/yaml": "^7.4|8.0.*"
},
"require-dev": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
Expand Down Expand Up @@ -205,13 +206,7 @@ private function addClassAttribute(Class_ $class, array $arguments): void

private function hasImplements(Class_ $class, string $interfaceFQN): bool
{
foreach ($class->implements as $implement) {
if ($this->isName($implement, $interfaceFQN)) {
return true;
}
}

return false;
return array_any($class->implements, fn (Name $name): bool => $this->isName($name, $interfaceFQN));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions rules/CodeQuality/Enum/DoctrineClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace Rector\Doctrine\CodeQuality\Enum;

use Deprecated;

/**
* @deprecated Switch to @see \Rector\Doctrine\Enum\DoctrineClass instead
* @api
*/
final readonly class DoctrineClass
{
/**
* @deprecated BC only
*/
#[Deprecated(message: 'BC only')]
public const string COLLECTION = \Rector\Doctrine\Enum\DoctrineClass::COLLECTION;
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,10 @@ private function processIterableAndUnionTypeNode(

private function hasCollectionDocblockType(UnionTypeNode|IntersectionTypeNode $complexTypeNode): bool
{
foreach ($complexTypeNode->types as $singleType) {
if ($this->isCollectionIdentifierTypeNode($singleType)) {
return true;
}
}

return false;
return array_any(
$complexTypeNode->types,
fn (TypeNode $typeNode): bool => $this->isCollectionIdentifierTypeNode($typeNode)
);
}

private function processNullableTypeNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
namespace Rector\Doctrine\TypedCollections\Rector\ClassMethod;

use PhpParser\Node;
use PhpParser\Node\Identifier;
use PhpParser\Node\IntersectionType;
use PhpParser\Node\Name;
use PhpParser\Node\NullableType;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\UnionType;
Expand Down Expand Up @@ -162,12 +165,9 @@ private function refactorNativeReturn(ClassMethod $classMethod): bool

private function hasNativeReturnCollectionType(UnionType $unionType): bool
{
foreach ($unionType->types as $unionedType) {
if ($this->isName($unionedType, DoctrineClass::COLLECTION)) {
return true;
}
}

return false;
return array_any(
$unionType->types,
fn (Identifier|IntersectionType|Name $unionedType): bool => $this->isName($unionedType, DoctrineClass::COLLECTION)
);
}
}
6 changes: 3 additions & 3 deletions src/PhpDocParser/DoctrineDocBlockResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

namespace Rector\Doctrine\PhpDocParser;

use Deprecated;
use PhpParser\Node\Stmt\Class_;
use Rector\Doctrine\Enum\MappingClass;
use Rector\Doctrine\Enum\OdmMappingClass;
use Rector\Doctrine\NodeAnalyzer\AttrinationFinder;
use Rector\Doctrine\TypedCollections\NodeAnalyzer\EntityLikeClassDetector;

/**
* @api
Expand All @@ -20,9 +22,7 @@ public function __construct(
) {
}

/**
* @deprecated Use \Rector\Doctrine\TypedCollections\NodeAnalyzer\EntityLikeClassDetector::detect() instead
*/
#[Deprecated(message: 'Use ' . EntityLikeClassDetector::class . '::detect() instead')]
public function isDoctrineEntityClass(Class_ $class): bool
{
return $this->attrinationFinder->hasByMany($class, [
Expand Down
86 changes: 44 additions & 42 deletions src/Set/DoctrineSetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Rector\Doctrine\Set;

use Deprecated;

/**
* @api
*/
Expand All @@ -17,74 +19,74 @@ final class DoctrineSetList

public const string YAML_TO_ANNOTATIONS = __DIR__ . '/../../config/yaml-to-annotations.php';

/**
* @deprecated Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets
*/
#[Deprecated(
message: 'Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets'
)]
public const string DOCTRINE_COMMON_20 = __DIR__ . '/../../config/sets/doctrine-common-20.php';

/**
* @deprecated Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets
*/
#[Deprecated(
message: 'Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets'
)]
public const string DOCTRINE_COLLECTION_22 = __DIR__ . '/../../config/sets/doctrine-collection-22.php';

/**
* @deprecated Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets
*/
#[Deprecated(
message: 'Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets'
)]
public const string DOCTRINE_DBAL_211 = __DIR__ . '/../../config/sets/doctrine-dbal-211.php';

/**
* @deprecated Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets
*/
#[Deprecated(
message: 'Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets'
)]
public const string DOCTRINE_DBAL_30 = __DIR__ . '/../../config/sets/doctrine-dbal-30.php';

/**
* @deprecated Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets
*/
#[Deprecated(
message: 'Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets'
)]
public const string DOCTRINE_DBAL_38 = __DIR__ . '/../../config/sets/doctrine-dbal-38.php';

/**
* @deprecated Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets
*/
#[Deprecated(
message: 'Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets'
)]
public const string DOCTRINE_DBAL_40 = __DIR__ . '/../../config/sets/doctrine-dbal-40.php';

/**
* @deprecated Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets
*/
#[Deprecated(
message: 'Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets'
)]
public const string DOCTRINE_ORM_25 = __DIR__ . '/../../config/sets/doctrine-orm-25.php';

/**
* @deprecated Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets
*/
#[Deprecated(
message: 'Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets'
)]
public const string DOCTRINE_ORM_28 = __DIR__ . '/../../config/sets/doctrine-orm-28.php';

/**
* @deprecated Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets
*/
#[Deprecated(
message: 'Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets'
)]
public const string DOCTRINE_ORM_213 = __DIR__ . '/../../config/sets/doctrine-orm-213.php';

/**
* @deprecated Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets
*/
#[Deprecated(
message: 'Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets'
)]
public const string DOCTRINE_ORM_214 = __DIR__ . '/../../config/sets/doctrine-orm-214.php';

/**
* @deprecated Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets
*/
#[Deprecated(
message: 'Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets'
)]
public const string DOCTRINE_ORM_219 = __DIR__ . '/../../config/sets/doctrine-orm-219.php';

/**
* @deprecated Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets
*/
#[Deprecated(
message: 'Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets'
)]
public const string DOCTRINE_ORM_300 = __DIR__ . '/../../config/sets/doctrine-orm-300.php';

/**
* @deprecated Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets
*/
#[Deprecated(
message: 'Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets'
)]
public const string DOCTRINE_BUNDLE_210 = __DIR__ . '/../../config/sets/doctrine-bundle-210.php';

/**
* @deprecated Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets
*/
#[Deprecated(
message: 'Use withComposerBased() instead, see https://getrector.com/blog/introducing-composer-version-based-sets'
)]
public const string DOCTRINE_BUNDLE_230 = __DIR__ . '/../../config/sets/doctrine-bundle-23.php';

public const string ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/attributes/doctrine.php';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Doctrine\Tests\NodeAnalyzer\DoctrineEntityDetector;

use Override;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Doctrine\NodeAnalyzer\DoctrineEntityDetector;
Expand All @@ -13,6 +14,7 @@ final class DoctrineEntityDetectorTest extends AbstractLazyTestCase
{
private DoctrineEntityDetector $doctrineEntityDetector;

#[Override]
protected function setUp(): void
{
parent::setUp();
Expand Down
Loading