Skip to content

Commit

Permalink
fix failing tests for rector 0.18.3
Browse files Browse the repository at this point in the history
  • Loading branch information
wernerkrauss committed Sep 19, 2023
1 parent 9e80577 commit 0685eb9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 12 additions & 6 deletions src/Rector/Misc/AddConfigPropertiesRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode;
use PHPStan\Type\ObjectType;
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use SilverStripe\Admin\LeftAndMain;
use SilverStripe\Admin\ModelAdmin;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Extensible;
use SilverStripe\ORM\DataObject;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

Expand All @@ -22,6 +22,12 @@ class AddConfigPropertiesRector extends \Rector\Core\Rector\AbstractRector imple

private PhpDocTypeChanger $phpDocTypeChanger;

/**
* @readonly
* @var \Rector\Comments\NodeDocBlock\DocBlockUpdater
*/
private $docBlockUpdater;

/**
* @var array|mixed[]
*/
Expand Down Expand Up @@ -109,9 +115,10 @@ class AddConfigPropertiesRector extends \Rector\Core\Rector\AbstractRector imple
],
];

public function __construct(PhpDocTypeChanger $phpDocTypeChanger)
public function __construct(PhpDocTypeChanger $phpDocTypeChanger, DocBlockUpdater $docBlockUpdater)
{
$this->phpDocTypeChanger = $phpDocTypeChanger;
$this->docBlockUpdater = $docBlockUpdater;
}

/**
Expand Down Expand Up @@ -161,7 +168,7 @@ public function getNodeTypes(): array
public function refactor(Node $node): ?Node
{
$config = $this->getConfig();
$this->nodeIsChanged = false;
$this->nodeIsChanged = \false;

foreach ($config as $className => $configProperties) {
if (!$this->isObjectType($node, new ObjectType($className))) {
Expand Down Expand Up @@ -195,10 +202,9 @@ private function checkConfigProperties(Node $node, array $configProperties): Nod
}

$phpDocInfo->addPhpDocTagNode(new PhpDocTextNode('@config'));
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($property);

if ($phpDocInfo->hasChanged()) {
$this->nodeIsChanged = true;
}
$this->nodeIsChanged = \true;
}

return $node;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Netwerkstatt\SilverstripeRector\Tests\Misc\AddConfigPropertiesRector\Fixture;

class SomeGoodClass extends \SilverStripe\ORM\DataObject
class ClassWithAnnotations extends \SilverStripe\ORM\DataObject
{
/**
* @config
Expand All @@ -23,7 +23,7 @@ class SomeGoodClass extends \SilverStripe\ORM\DataObject

namespace Netwerkstatt\SilverstripeRector\Tests\Misc\AddConfigPropertiesRector\Fixture;

class SomeGoodClass extends \SilverStripe\ORM\DataObject
class ClassWithAnnotations extends \SilverStripe\ORM\DataObject
{
/**
* @config
Expand Down

0 comments on commit 0685eb9

Please sign in to comment.