8
8
use Composer \Plugin \PluginInterface ;
9
9
use Composer \Script \Event ;
10
10
use Composer \Script \ScriptEvents ;
11
+ use Composer \Semver \Constraint \ConstraintInterface ;
11
12
use Composer \Semver \Constraint \MultiConstraint ;
12
13
use Composer \Semver \Intervals ;
13
14
use Composer \Util \Filesystem ;
@@ -165,7 +166,7 @@ public function process(Event $event): void
165
166
'relative_install_path ' => $ fs ->findShortestPath (dirname ($ generatedConfigFilePath ), $ absoluteInstallPath , true ),
166
167
'extra ' => $ package ->getExtra ()['phpstan ' ] ?? null ,
167
168
'version ' => $ package ->getFullPrettyVersion (),
168
- 'phpstanVersionConstraint ' => $ phpstanConstraint !== null ? ( string ) $ phpstanConstraint : null ,
169
+ 'phpstanVersionConstraint ' => $ phpstanConstraint !== null ? $ this -> constraintIntoString ( $ phpstanConstraint) : null ,
169
170
];
170
171
171
172
$ installedPackages [$ package ->getName ()] = true ;
@@ -178,14 +179,7 @@ public function process(Event $event): void
178
179
} else {
179
180
$ multiConstraint = new MultiConstraint ($ phpstanVersionConstraints );
180
181
}
181
- $ compactedConstraint = Intervals::compactConstraint ($ multiConstraint );
182
- $ phpstanVersionConstraint = sprintf (
183
- '%s%s && %s%s ' ,
184
- $ compactedConstraint ->getLowerBound ()->isInclusive () ? '>= ' : '> ' ,
185
- $ compactedConstraint ->getLowerBound ()->getVersion (),
186
- $ compactedConstraint ->getUpperBound ()->isInclusive () ? '<= ' : '< ' ,
187
- $ compactedConstraint ->getUpperBound ()->getVersion ()
188
- );
182
+ $ phpstanVersionConstraint = $ this ->constraintIntoString (Intervals::compactConstraint ($ multiConstraint ));
189
183
}
190
184
191
185
ksort ($ data );
@@ -214,4 +208,15 @@ public function process(Event $event): void
214
208
}
215
209
}
216
210
211
+ private function constraintIntoString (ConstraintInterface $ constraint ): string
212
+ {
213
+ return sprintf (
214
+ '%s%s && %s%s ' ,
215
+ $ constraint ->getLowerBound ()->isInclusive () ? '>= ' : '> ' ,
216
+ $ constraint ->getLowerBound ()->getVersion (),
217
+ $ constraint ->getUpperBound ()->isInclusive () ? '<= ' : '< ' ,
218
+ $ constraint ->getUpperBound ()->getVersion ()
219
+ );
220
+ }
221
+
217
222
}
0 commit comments