Skip to content
Closed
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
Expand Up @@ -49,6 +49,15 @@ public function processNode(Node $node, Scope $scope): array
return [];
}

if ($classReflection->hasConstructor()) {
$constructor = $classReflection->getConstructor();
if (
$constructor->isFinal()->yes()
) {
return [];
}
}

return [
RuleErrorBuilder::message(sprintf(
'Unsafe usage of new static() in abstract class %s in static method %s().',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,23 @@ public static function staticDoFoo(): void
}

}

abstract class FinalConstructFoo
{
final function __construct() {

}

public function doFoo(): void
{
new static();
}

public static function staticDoFoo(): void
{
new static();
}

}

class Subclass extends FinalConstructFoo {}
Loading