@@ -88,15 +88,23 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
88
88
new AccessoryNonFalsyStringType (),
89
89
]);
90
90
}
91
+
92
+ $ minPhpVersion = null ;
93
+ $ maxPhpVersion = null ;
94
+ if (in_array ($ resolvedConstantName , ['PHP_VERSION_ID ' , 'PHP_MAJOR_VERSION ' , 'PHP_MINOR_VERSION ' , 'PHP_RELEASE_VERSION ' ], true )) {
95
+ $ minPhpVersion = $ this ->getMinPhpVersion ();
96
+ $ maxPhpVersion = $ this ->getMaxPhpVersion ();
97
+ }
98
+
91
99
if ($ resolvedConstantName === 'PHP_MAJOR_VERSION ' ) {
92
100
$ minMajor = 5 ;
93
101
$ maxMajor = null ;
94
102
95
- if ($ this -> getMinPhpVersion () !== null ) {
96
- $ minMajor = max ($ minMajor , $ this -> getMinPhpVersion () ->getMajorVersionId ());
103
+ if ($ minPhpVersion !== null ) {
104
+ $ minMajor = max ($ minMajor , $ minPhpVersion ->getMajorVersionId ());
97
105
}
98
- if ($ this -> getMaxPhpVersion () !== null ) {
99
- $ maxMajor = $ this -> getMaxPhpVersion () ->getMajorVersionId ();
106
+ if ($ maxPhpVersion !== null ) {
107
+ $ maxMajor = $ maxPhpVersion ->getMajorVersionId ();
100
108
}
101
109
102
110
return $ this ->createInteger ($ minMajor , $ maxMajor );
@@ -106,12 +114,12 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
106
114
$ maxMinor = null ;
107
115
108
116
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 ()
112
120
) {
113
- $ minMinor = $ this -> getMinPhpVersion () ->getMinorVersionId ();
114
- $ maxMinor = $ this -> getMaxPhpVersion () ->getMinorVersionId ();
121
+ $ minMinor = $ minPhpVersion ->getMinorVersionId ();
122
+ $ maxMinor = $ maxPhpVersion ->getMinorVersionId ();
115
123
}
116
124
117
125
return $ this ->createInteger ($ minMinor , $ maxMinor );
@@ -121,25 +129,25 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
121
129
$ maxRelease = null ;
122
130
123
131
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 ()
128
136
) {
129
- $ minRelease = $ this -> getMinPhpVersion () ->getPatchVersionId ();
130
- $ maxRelease = $ this -> getMaxPhpVersion () ->getPatchVersionId ();
137
+ $ minRelease = $ minPhpVersion ->getPatchVersionId ();
138
+ $ maxRelease = $ maxPhpVersion ->getPatchVersionId ();
131
139
}
132
140
133
141
return $ this ->createInteger ($ minRelease , $ maxRelease );
134
142
}
135
143
if ($ resolvedConstantName === 'PHP_VERSION_ID ' ) {
136
144
$ minVersion = 50207 ;
137
145
$ maxVersion = null ;
138
- if ($ this -> getMinPhpVersion () !== null ) {
139
- $ minVersion = max ($ minVersion , $ this -> getMinPhpVersion () ->getVersionId ());
146
+ if ($ minPhpVersion !== null ) {
147
+ $ minVersion = max ($ minVersion , $ minPhpVersion ->getVersionId ());
140
148
}
141
- if ($ this -> getMaxPhpVersion () !== null ) {
142
- $ maxVersion = $ this -> getMaxPhpVersion () ->getVersionId ();
149
+ if ($ maxPhpVersion !== null ) {
150
+ $ maxVersion = $ maxPhpVersion ->getVersionId ();
143
151
}
144
152
145
153
return $ this ->createInteger ($ minVersion , $ maxVersion );
0 commit comments