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
7 changes: 3 additions & 4 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3164,8 +3164,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
$scope = $result->getScope();

if ($methodReflection !== null) {
$hasSideEffects = $methodReflection->hasSideEffects();
if ($hasSideEffects->yes() || $methodReflection->getName() === '__construct') {
if ($methodReflection->getName() === '__construct' || $methodReflection->hasSideEffects()->yes()) {
$this->callNodeCallback($nodeCallback, new InvalidateExprNode($normalizedExpr->var), $scope, $storage);
$scope = $scope->invalidateExpression($normalizedExpr->var, true);
}
Expand Down Expand Up @@ -3376,11 +3375,11 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
if (
$methodReflection !== null
&& (
$methodReflection->hasSideEffects()->yes()
|| (
(
!$methodReflection->isStatic()
&& $methodReflection->getName() === '__construct'
)
|| $methodReflection->hasSideEffects()->yes()
)
&& $scope->isInClass()
&& $scope->getClassReflection()->is($methodReflection->getDeclaringClass()->getName())
Expand Down
3 changes: 1 addition & 2 deletions src/Reflection/Native/NativeMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,9 @@ public function getThrowType(): ?Type
public function hasSideEffects(): TrinaryLogic
{
$name = strtolower($this->getName());
$isVoid = $this->isVoid();
if (
$name !== '__construct'
&& $isVoid
&& $this->isVoid()
) {
return TrinaryLogic::createYes();
}
Expand Down
14 changes: 8 additions & 6 deletions src/Rules/Api/ApiStaticCallRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ public function processNode(Node $node, Scope $scope): array
private function isCovered(MethodReflection $methodReflection): bool
{
$declaringClass = $methodReflection->getDeclaringClass();
$classDocBlock = $declaringClass->getResolvedPhpDoc();
if ($methodReflection->getName() !== '__construct' && $classDocBlock !== null) {
foreach ($classDocBlock->getPhpDocNodes() as $phpDocNode) {
$apiTags = $phpDocNode->getTagsByName('@api');
if (count($apiTags) > 0) {
return true;
if ($methodReflection->getName() !== '__construct') {
$classDocBlock = $declaringClass->getResolvedPhpDoc();
if ($classDocBlock !== null) {
foreach ($classDocBlock->getPhpDocNodes() as $phpDocNode) {
$apiTags = $phpDocNode->getTagsByName('@api');
if (count($apiTags) > 0) {
return true;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Rules/Methods/FinalPrivateMethodRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public function getNodeType(): string
public function processNode(Node $node, Scope $scope): array
{
$method = $node->getMethodReflection();
if ($scope->getPhpVersion()->producesWarningForFinalPrivateMethods()->no()) {
if ($method->getName() === '__construct') {
return [];
}

if ($method->getName() === '__construct') {
if ($scope->getPhpVersion()->producesWarningForFinalPrivateMethods()->no()) {
return [];
}

Expand Down
Loading