Skip to content

Commit

Permalink
Deprecated parent constructor must not be called
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN authored and ondrejmirtes committed Jan 21, 2025
1 parent 02277ce commit 8b88b5f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Rules/Classes/RequireParentConstructCallRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private function getParentConstructorClass($classReflection)
&& $constructor->getDeclaringClass()->getName() === $classReflection->getParentClass()->getName()
&& !$constructor->isAbstract()
&& !$constructor->isPrivate()
&& !$constructor->isDeprecated()
) || (
$constructorWithClassName !== null
&& $constructorWithClassName->getDeclaringClass()->getName() === $classReflection->getParentClass()->getName()
Expand Down
19 changes: 19 additions & 0 deletions tests/Rules/Classes/data/call-to-parent-constructor.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,22 @@ public function __construct()
}

}

class DeprecatedConstructor
{
/** @deprecated */
public function __construct()
{

}

}

class ExtendsDeprecatedConstructor extends DeprecatedConstructor
{
public function __construct()
{
// should not call deprecated parent
}

}

0 comments on commit 8b88b5f

Please sign in to comment.