@@ -1996,7 +1996,7 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
1996
1996
$ scope = $ result ->getScope ();
1997
1997
if ($ methodReflection !== null ) {
1998
1998
$ hasSideEffects = $ methodReflection ->hasSideEffects ();
1999
- if ($ hasSideEffects ->yes ()) {
1999
+ if ($ hasSideEffects ->yes () || $ methodReflection -> getName () === ' __construct ' ) {
2000
2000
$ scope = $ scope ->invalidateExpression ($ expr ->var , true );
2001
2001
foreach ($ expr ->getArgs () as $ arg ) {
2002
2002
$ scope = $ scope ->invalidateExpression ($ arg ->value , true );
@@ -2118,7 +2118,10 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
2118
2118
if (
2119
2119
$ methodReflection !== null
2120
2120
&& !$ methodReflection ->isStatic ()
2121
- && $ methodReflection ->hasSideEffects ()->yes ()
2121
+ && (
2122
+ $ methodReflection ->hasSideEffects ()->yes ()
2123
+ || $ methodReflection ->getName () === '__construct '
2124
+ )
2122
2125
&& $ scopeFunction instanceof MethodReflection
2123
2126
&& !$ scopeFunction ->isStatic ()
2124
2127
&& $ scope ->isInClass ()
@@ -2131,7 +2134,7 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
2131
2134
}
2132
2135
2133
2136
if ($ methodReflection !== null ) {
2134
- if ($ methodReflection ->hasSideEffects ()->yes ()) {
2137
+ if ($ methodReflection ->hasSideEffects ()->yes () || $ methodReflection -> getName () === ' __construct ' ) {
2135
2138
foreach ($ expr ->getArgs () as $ arg ) {
2136
2139
$ scope = $ scope ->invalidateExpression ($ arg ->value , true );
2137
2140
}
0 commit comments