1
1
<?php
2
2
3
- // phpcs:ignoreFile
4
-
5
3
namespace Acquia \Orca \Domain \Composer \Version ;
6
4
7
5
use Acquia \Orca \Enum \DrupalCoreVersionEnum ;
@@ -198,19 +196,14 @@ public function resolveArbitrary(string $version, string $preferred_stability =
198
196
* @throws \Acquia\Orca\Exception\OrcaVersionNotFoundException
199
197
*/
200
198
private function findOldestSupported (): string {
201
- // @todo The dynamic functionality here has been temporarily replaced with
202
- // a hardcoded value to give us time before the Drupal 10 release takes
203
- // effect in our core version spread.
204
- // if ($this->oldestSupported) {
205
- // return $this->oldestSupported;
206
- // }
207
- //
208
- // $branch = $this->drupalDotOrgApiClient->getOldestSupportedDrupalCoreBranch();
209
- // $this->oldestSupported = $this->resolveArbitrary($branch, 'stable');
210
- //
211
- // return $this->oldestSupported;
212
-
213
- return '9.3.22 ' ;
199
+ if ($ this ->oldestSupported ) {
200
+ return $ this ->oldestSupported ;
201
+ }
202
+
203
+ $ branch = $ this ->drupalDotOrgApiClient ->getOldestSupportedDrupalCoreBranch ();
204
+ $ this ->oldestSupported = $ this ->resolveArbitrary ($ branch , 'stable ' );
205
+
206
+ return $ this ->oldestSupported ;
214
207
}
215
208
216
209
/**
@@ -222,28 +215,22 @@ private function findOldestSupported(): string {
222
215
* @throws \Acquia\Orca\Exception\OrcaVersionNotFoundException
223
216
*/
224
217
private function findLatestLts (): string {
225
- // @todo The dynamic functionality here has been temporarily replaced with
226
- // a hardcoded value to give us time before the Drupal 10 release takes
227
- // effect in our core version spread.
228
- // if ($this->latestLts) {
229
- // return $this->latestLts;
230
- // }
231
- //
232
- // $parts = explode('.', $this->findCurrent());
233
- // $current_major = array_shift($parts);
234
- //
235
- // // Gets the oldest supported version of Drupal Core.
236
- // $oldestSupported = $this->findOldestSupported();
237
- // // If oldest supported Drupal Core version is less than current major.
238
- // if ((int) $oldestSupported < (int) $current_major) {
239
- // $this->latestLts = $oldestSupported;
240
- // return $this->latestLts;
241
- // }
242
- //
243
- // $message = "No Drupal core version satisfies the given constraints: oldest supported ($oldestSupported) less than current major ($current_major)";
244
- // throw new OrcaVersionNotFoundException($message);
245
-
246
- $ message = 'No Drupal core version satisfies the given constraints: oldest supported (9.3.22) less than current major (9) ' ;
218
+ if ($ this ->latestLts ) {
219
+ return $ this ->latestLts ;
220
+ }
221
+
222
+ $ parts = explode ('. ' , $ this ->findCurrent ());
223
+ $ current_major = array_shift ($ parts );
224
+
225
+ // Gets the oldest supported version of Drupal Core.
226
+ $ oldestSupported = $ this ->findOldestSupported ();
227
+ // If oldest supported Drupal Core version is less than current major.
228
+ if ((int ) $ oldestSupported < (int ) $ current_major ) {
229
+ $ this ->latestLts = $ oldestSupported ;
230
+ return $ this ->latestLts ;
231
+ }
232
+
233
+ $ message = "No Drupal core version satisfies the given constraints: oldest supported ( $ oldestSupported) less than current major ( $ current_major) " ;
247
234
throw new OrcaVersionNotFoundException ($ message );
248
235
}
249
236
@@ -256,21 +243,16 @@ private function findLatestLts(): string {
256
243
* @throws \Acquia\Orca\Exception\OrcaVersionNotFoundException
257
244
*/
258
245
private function findPreviousMinor (): string {
259
- // @todo The dynamic functionality here has been temporarily replaced with
260
- // a hardcoded value to give us time before the Drupal 10 release takes
261
- // effect in our core version spread.
262
- // if ($this->previousMinor) {
263
- // return $this->previousMinor;
264
- // }
265
- //
266
- // $parts = explode('.', $this->findCurrent());
267
- // array_pop($parts);
268
- // $current_minor = implode('.', $parts);
269
- // $this->previousMinor = $this
270
- // ->resolveArbitrary("<{$current_minor}", 'stable');
271
- // return $this->previousMinor;
272
-
273
- return '9.3.22 ' ;
246
+ if ($ this ->previousMinor ) {
247
+ return $ this ->previousMinor ;
248
+ }
249
+
250
+ $ parts = explode ('. ' , $ this ->findCurrent ());
251
+ array_pop ($ parts );
252
+ $ current_minor = implode ('. ' , $ parts );
253
+ $ this ->previousMinor = $ this
254
+ ->resolveArbitrary ("< {$ current_minor }" , 'stable ' );
255
+ return $ this ->previousMinor ;
274
256
}
275
257
276
258
/**
@@ -280,24 +262,19 @@ private function findPreviousMinor(): string {
280
262
* The semver version string, e.g., 9.1.0.
281
263
*/
282
264
private function findCurrent (): string {
283
- // @todo The dynamic functionality here has been temporarily replaced with
284
- // a hardcoded value to give us time before the Drupal 10 release takes
285
- // effect in our core version spread.
286
- // if ($this->current) {
287
- // return $this->current;
288
- // }
289
- //
290
- // try {
291
- // $candidate = $this->resolveArbitrary('*', 'stable');
292
- // }
293
- // catch (OrcaVersionNotFoundException $e) {
294
- // throw new \LogicException('Could not find current version of Drupal core.');
295
- // }
296
- // $this->current = $candidate;
297
- //
298
- // return $this->current;
299
-
300
- return '9.4.9 ' ;
265
+ if ($ this ->current ) {
266
+ return $ this ->current ;
267
+ }
268
+
269
+ try {
270
+ $ candidate = $ this ->resolveArbitrary ('* ' , 'stable ' );
271
+ }
272
+ catch (OrcaVersionNotFoundException $ e ) {
273
+ throw new \LogicException ('Could not find current version of Drupal core. ' );
274
+ }
275
+ $ this ->current = $ candidate ;
276
+
277
+ return $ this ->current ;
301
278
}
302
279
303
280
/**
@@ -307,12 +284,7 @@ private function findCurrent(): string {
307
284
* The semver version string, e.g., 9.1.x-dev.
308
285
*/
309
286
private function findCurrentDev (): string {
310
- // @todo The dynamic functionality here has been temporarily replaced with
311
- // a hardcoded value to give us time before the Drupal 10 release takes
312
- // effect in our core version spread.
313
- // return $this->convertToDev($this->findCurrent());
314
-
315
- return '9.4.x-dev ' ;
287
+ return $ this ->convertToDev ($ this ->findCurrent ());
316
288
}
317
289
318
290
/**
@@ -324,19 +296,14 @@ private function findCurrentDev(): string {
324
296
* @throws \Acquia\Orca\Exception\OrcaVersionNotFoundException
325
297
*/
326
298
private function findNextMinor (): string {
327
- // @todo The dynamic functionality here has been temporarily replaced with
328
- // a hardcoded value to give us time before the Drupal 10 release takes
329
- // effect in our core version spread.
330
- // if ($this->nextMinor) {
331
- // return $this->nextMinor;
332
- // }
333
- //
334
- // $this->nextMinor = $this
335
- // ->resolveArbitrary("~{$this->findNextMinorUnresolved()}", 'alpha', FALSE);
336
- //
337
- // return $this->nextMinor;
338
-
339
- return '9.5.0-rc2 ' ;
299
+ if ($ this ->nextMinor ) {
300
+ return $ this ->nextMinor ;
301
+ }
302
+
303
+ $ this ->nextMinor = $ this
304
+ ->resolveArbitrary ("~ {$ this ->findNextMinorUnresolved ()}" , 'alpha ' , FALSE );
305
+
306
+ return $ this ->nextMinor ;
340
307
}
341
308
342
309
/**
@@ -360,19 +327,14 @@ private function findNextMinorUnresolved(): string {
360
327
* @throws \Acquia\Orca\Exception\OrcaVersionNotFoundException
361
328
*/
362
329
private function findNextMinorDev (): string {
363
- // @todo The dynamic functionality here has been temporarily replaced with
364
- // a hardcoded value to give us time before the Drupal 10 release takes
365
- // effect in our core version spread.
366
- // if ($this->nextMinorDev) {
367
- // return $this->nextMinorDev;
368
- // }
369
- //
370
- // $next_minor = $this->findNextMinorUnresolved();
371
- // $this->nextMinorDev = $this->convertToDev($next_minor);
372
- //
373
- // return $this->nextMinorDev;
374
-
375
- return '9.5.x-dev ' ;
330
+ if ($ this ->nextMinorDev ) {
331
+ return $ this ->nextMinorDev ;
332
+ }
333
+
334
+ $ next_minor = $ this ->findNextMinorUnresolved ();
335
+ $ this ->nextMinorDev = $ this ->convertToDev ($ next_minor );
336
+
337
+ return $ this ->nextMinorDev ;
376
338
}
377
339
378
340
/**
@@ -384,25 +346,20 @@ private function findNextMinorDev(): string {
384
346
* @throws \Acquia\Orca\Exception\OrcaVersionNotFoundException
385
347
*/
386
348
private function findNextMajorLatestMinorBetaOrLater (): string {
387
- // @todo The dynamic functionality here has been temporarily replaced with
388
- // a hardcoded value to give us time before the Drupal 10 release takes
389
- // effect in our core version spread.
390
- // if ($this->nextMajorLatestMinorBetaOrLater) {
391
- // return $this->nextMajorLatestMinorBetaOrLater;
392
- // }
393
- //
394
- // $parts = explode('.', $this->findCurrent());
395
- // $major = $parts[0];
396
- // $major++;
397
- //
398
- // $this->nextMajorLatestMinorBetaOrLater = $this
399
- // ->resolveArbitrary("^{$major}", 'beta');
400
- //
401
- // $this->assertNextMajorLatestMinorBetaOrLaterExists();
402
- //
403
- // return $this->nextMajorLatestMinorBetaOrLater;
404
-
405
- return '10.0.0-rc3 ' ;
349
+ if ($ this ->nextMajorLatestMinorBetaOrLater ) {
350
+ return $ this ->nextMajorLatestMinorBetaOrLater ;
351
+ }
352
+
353
+ $ parts = explode ('. ' , $ this ->findCurrent ());
354
+ $ major = $ parts [0 ];
355
+ $ major ++;
356
+
357
+ $ this ->nextMajorLatestMinorBetaOrLater = $ this
358
+ ->resolveArbitrary ("^ {$ major }" , 'beta ' );
359
+
360
+ $ this ->assertNextMajorLatestMinorBetaOrLaterExists ();
361
+
362
+ return $ this ->nextMajorLatestMinorBetaOrLater ;
406
363
}
407
364
408
365
/**
@@ -414,23 +371,18 @@ private function findNextMajorLatestMinorBetaOrLater(): string {
414
371
* @throws \Acquia\Orca\Exception\OrcaVersionNotFoundException
415
372
*/
416
373
private function findNextMajorLatestMinorDev (): string {
417
- // @todo The dynamic functionality here has been temporarily replaced with
418
- // a hardcoded value to give us time before the Drupal 10 release takes
419
- // effect in our core version spread.
420
- // if ($this->nextMajorLatestMinorDev) {
421
- // return $this->nextMajorLatestMinorDev;
422
- // }
423
- //
424
- // $parts = explode('.', $this->findCurrent());
425
- // $major = $parts[0];
426
- // $major++;
427
- //
428
- // $this->nextMajorLatestMinorDev = $this
429
- // ->resolveArbitrary("^{$major}", 'dev');
430
- //
431
- // return $this->nextMajorLatestMinorDev;
432
-
433
- return '10.1.x-dev ' ;
374
+ if ($ this ->nextMajorLatestMinorDev ) {
375
+ return $ this ->nextMajorLatestMinorDev ;
376
+ }
377
+
378
+ $ parts = explode ('. ' , $ this ->findCurrent ());
379
+ $ major = $ parts [0 ];
380
+ $ major ++;
381
+
382
+ $ this ->nextMajorLatestMinorDev = $ this
383
+ ->resolveArbitrary ("^ {$ major }" , 'dev ' );
384
+
385
+ return $ this ->nextMajorLatestMinorDev ;
434
386
}
435
387
436
388
/**
0 commit comments