@@ -88,15 +88,23 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
8888 new AccessoryNonFalsyStringType (),
8989 ]);
9090 }
91+
92+ $ minPhpVersion = null ;
93+ $ maxPhpVersion = null ;
94+ if (in_array ($ resolvedConstantName , ['PHP_VERSION_ID ' , 'PHP_MAJOR_VERSION ' , 'PHP_MINOR_VERSION ' , 'PHP_RELEASE_VERSION ' ])) {
95+ $ minPhpVersion = $ this ->getMinPhpVersion ();
96+ $ maxPhpVersion = $ this ->getMaxPhpVersion ();
97+ }
98+
9199 if ($ resolvedConstantName === 'PHP_MAJOR_VERSION ' ) {
92100 $ minMajor = 5 ;
93101 $ maxMajor = null ;
94102
95- if ($ this -> getMinPhpVersion () !== null ) {
96- $ minMajor = max ($ minMajor , $ this -> getMinPhpVersion () ->getMajorVersionId ());
103+ if ($ minPhpVersion !== null ) {
104+ $ minMajor = max ($ minMajor , $ minPhpVersion ->getMajorVersionId ());
97105 }
98- if ($ this -> getMaxPhpVersion () !== null ) {
99- $ maxMajor = $ this -> getMaxPhpVersion () ->getMajorVersionId ();
106+ if ($ maxPhpVersion !== null ) {
107+ $ maxMajor = $ maxPhpVersion ->getMajorVersionId ();
100108 }
101109
102110 return $ this ->createInteger ($ minMajor , $ maxMajor );
@@ -106,12 +114,12 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
106114 $ maxMinor = null ;
107115
108116 if (
109- $ this -> getMinPhpVersion () !== null
110- && $ this -> getMaxPhpVersion () !== null
111- && $ this -> getMaxPhpVersion ()-> getMajorVersionId () === $ this -> getMinPhpVersion () ->getMajorVersionId ()
117+ $ minPhpVersion !== null
118+ && $ maxPhpVersion !== null
119+ && $ maxPhpVersion -> getMajorVersionId () === $ minPhpVersion ->getMajorVersionId ()
112120 ) {
113- $ minMinor = $ this -> getMinPhpVersion () ->getMinorVersionId ();
114- $ maxMinor = $ this -> getMaxPhpVersion () ->getMinorVersionId ();
121+ $ minMinor = $ minPhpVersion ->getMinorVersionId ();
122+ $ maxMinor = $ maxPhpVersion ->getMinorVersionId ();
115123 }
116124
117125 return $ this ->createInteger ($ minMinor , $ maxMinor );
@@ -121,25 +129,25 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
121129 $ maxRelease = null ;
122130
123131 if (
124- $ this -> getMinPhpVersion () !== null
125- && $ this -> getMaxPhpVersion () !== null
126- && $ this -> getMaxPhpVersion ()-> getMajorVersionId () === $ this -> getMinPhpVersion () ->getMajorVersionId ()
127- && $ this -> getMaxPhpVersion ()-> getMinorVersionId () === $ this -> getMinPhpVersion () ->getMinorVersionId ()
132+ $ minPhpVersion !== null
133+ && $ maxPhpVersion !== null
134+ && $ maxPhpVersion -> getMajorVersionId () === $ minPhpVersion ->getMajorVersionId ()
135+ && $ maxPhpVersion -> getMinorVersionId () === $ minPhpVersion ->getMinorVersionId ()
128136 ) {
129- $ minRelease = $ this -> getMinPhpVersion () ->getPatchVersionId ();
130- $ maxRelease = $ this -> getMaxPhpVersion () ->getPatchVersionId ();
137+ $ minRelease = $ minPhpVersion ->getPatchVersionId ();
138+ $ maxRelease = $ maxPhpVersion ->getPatchVersionId ();
131139 }
132140
133141 return $ this ->createInteger ($ minRelease , $ maxRelease );
134142 }
135143 if ($ resolvedConstantName === 'PHP_VERSION_ID ' ) {
136144 $ minVersion = 50207 ;
137145 $ maxVersion = null ;
138- if ($ this -> getMinPhpVersion () !== null ) {
139- $ minVersion = max ($ minVersion , $ this -> getMinPhpVersion () ->getVersionId ());
146+ if ($ minPhpVersion !== null ) {
147+ $ minVersion = max ($ minVersion , $ minPhpVersion ->getVersionId ());
140148 }
141- if ($ this -> getMaxPhpVersion () !== null ) {
142- $ maxVersion = $ this -> getMaxPhpVersion () ->getVersionId ();
149+ if ($ maxPhpVersion !== null ) {
150+ $ maxVersion = $ maxPhpVersion ->getVersionId ();
143151 }
144152
145153 return $ this ->createInteger ($ minVersion , $ maxVersion );
0 commit comments