Skip to content

Commit 8b88b5f

Browse files
GromNaNondrejmirtes
authored andcommitted
Deprecated parent constructor must not be called
1 parent 02277ce commit 8b88b5f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Rules/Classes/RequireParentConstructCallRule.php

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ private function getParentConstructorClass($classReflection)
113113
&& $constructor->getDeclaringClass()->getName() === $classReflection->getParentClass()->getName()
114114
&& !$constructor->isAbstract()
115115
&& !$constructor->isPrivate()
116+
&& !$constructor->isDeprecated()
116117
) || (
117118
$constructorWithClassName !== null
118119
&& $constructorWithClassName->getDeclaringClass()->getName() === $classReflection->getParentClass()->getName()

tests/Rules/Classes/data/call-to-parent-constructor.php

+19
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,22 @@ public function __construct()
181181
}
182182

183183
}
184+
185+
class DeprecatedConstructor
186+
{
187+
/** @deprecated */
188+
public function __construct()
189+
{
190+
191+
}
192+
193+
}
194+
195+
class ExtendsDeprecatedConstructor extends DeprecatedConstructor
196+
{
197+
public function __construct()
198+
{
199+
// should not call deprecated parent
200+
}
201+
202+
}

0 commit comments

Comments
 (0)