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
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector\Fixture;

use Doctrine\ORM\Mapping\ClassMetadata;

final class SkipStaticFunctionMapping
{
private $name;

public function __construct(string $name)
{
$this->name = $name;
}

public static function loadMetadata(ClassMetadata $metadata): void
{
$metadata->mapField([
'fieldName' => 'name',
'type' => 'string',
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
// skip Doctrine static function mapping, properties are mapped in loadMetadata() method
// @see https://www.doctrine-project.org/projects/doctrine-orm/en/3.6/reference/php-mapping.html#static-function
if ($node->getMethod('loadMetadata') instanceof ClassMethod) {
return null;
}

$constructClassMethod = $node->getMethod(MethodName::CONSTRUCT);
if (! $constructClassMethod instanceof ClassMethod) {
return null;
Expand Down
Loading