@@ -1996,7 +1996,7 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
19961996 $ scope = $ result ->getScope ();
19971997 if ($ methodReflection !== null ) {
19981998 $ hasSideEffects = $ methodReflection ->hasSideEffects ();
1999- if ($ hasSideEffects ->yes ()) {
1999+ if ($ hasSideEffects ->yes () || $ methodReflection -> getName () === ' __construct ' ) {
20002000 $ scope = $ scope ->invalidateExpression ($ expr ->var , true );
20012001 foreach ($ expr ->getArgs () as $ arg ) {
20022002 $ scope = $ scope ->invalidateExpression ($ arg ->value , true );
@@ -2118,7 +2118,10 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
21182118 if (
21192119 $ methodReflection !== null
21202120 && !$ methodReflection ->isStatic ()
2121- && $ methodReflection ->hasSideEffects ()->yes ()
2121+ && (
2122+ $ methodReflection ->hasSideEffects ()->yes ()
2123+ || $ methodReflection ->getName () === '__construct '
2124+ )
21222125 && $ scopeFunction instanceof MethodReflection
21232126 && !$ scopeFunction ->isStatic ()
21242127 && $ scope ->isInClass ()
@@ -2131,7 +2134,7 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
21312134 }
21322135
21332136 if ($ methodReflection !== null ) {
2134- if ($ methodReflection ->hasSideEffects ()->yes ()) {
2137+ if ($ methodReflection ->hasSideEffects ()->yes () || $ methodReflection -> getName () === ' __construct ' ) {
21352138 foreach ($ expr ->getArgs () as $ arg ) {
21362139 $ scope = $ scope ->invalidateExpression ($ arg ->value , true );
21372140 }
0 commit comments