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,16 @@
<?php

namespace Rector\Tests\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector\Fixture;

use Rector\Tests\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector\Source\ValidatedBase;

class SkipsParentConstructor extends ValidatedBase
{
private bool $validated = false;

public function __construct()
{
$this->validate();
$this->validated = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector\Source;

abstract class ValidatedBase
{
protected function validate(): void
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
// A child class may bypass the constructor and depend on the declared property default
if (! $node->isFinal()) {
return null;
}

$hasChanged = false;

$constructClassMethod = $node->getMethod(MethodName::CONSTRUCT);
Expand Down
5 changes: 3 additions & 2 deletions src/Bridge/SetProviderCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
/**
* @param SetProviderInterface[] $setProviders
*/
public function __construct(private array $setProviders = [])
{
public function __construct(
private array $setProviders = []
) {
}

/**
Expand Down
Loading