-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Remove deadcode after the bump to PHP >= 8.4 #60666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,11 +97,7 @@ | |
} | ||
}; | ||
|
||
if (\PHP_VERSION_ID >= 80000) { | ||
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '9.6') ?: '9.6'; | ||
} else { | ||
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.5') ?: '8.5'; | ||
} | ||
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '9.6') ?: '9.6'; | ||
|
||
$MAX_PHPUNIT_VERSION = $getEnvVar('SYMFONY_MAX_PHPUNIT_VERSION', false); | ||
|
||
|
@@ -178,7 +174,7 @@ | |
$prevCacheDir = false; | ||
} | ||
} | ||
$SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml' : '')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we really dropping support for older PHPUnit versions ? There is a difference between the default version and the supported versions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. older phpunit versions don't support PHP 8, but we bumped the bridge to PHP >= 8.1 (to keep using it when testing Symfony 6.4) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll need a proper cleanup to remove all code related to using older PHPUnit versions then. For instance, there is no need to remove the prophecy dependency in PHPUnit 9.6 anymore (as it is not installed by default anymore). |
||
$SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'); | ||
$SYMFONY_PHPUNIT_REQUIRE = $getEnvVar('SYMFONY_PHPUNIT_REQUIRE', ''); | ||
$configurationHash = md5(implode(\PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, $SYMFONY_PHPUNIT_REQUIRE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT])); | ||
$PHPUNIT_VERSION_DIR = sprintf('phpunit-%s-%d', $PHPUNIT_VERSION, $PHPUNIT_REMOVE_RETURN_TYPEHINT); | ||
|
@@ -240,9 +236,6 @@ | |
if ($SYMFONY_PHPUNIT_REQUIRE) { | ||
$passthruOrFail("$COMPOSER require --no-update ".$SYMFONY_PHPUNIT_REQUIRE); | ||
} | ||
if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) { | ||
$passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); | ||
} | ||
|
||
if (preg_match('{\^((\d++\.)\d++)[\d\.]*$}', $info['requires']['php'], $phpVersion) && version_compare($phpVersion[2].'99', \PHP_VERSION, '<')) { | ||
$passthruOrFail("$COMPOSER config platform.php \"$phpVersion[1].99\""); | ||
|
@@ -267,9 +260,8 @@ | |
} | ||
$prevRoot = getenv('COMPOSER_ROOT_VERSION'); | ||
putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99"); | ||
$q = '\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 80000 ? '"' : ''; | ||
// --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS | ||
$exit = proc_close(proc_open("$q$COMPOSER update --no-dev --prefer-dist --no-progress $q", [], $p, getcwd())); | ||
$exit = proc_close(proc_open("$COMPOSER update --no-dev --prefer-dist --no-progress", [], $p, getcwd())); | ||
putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : '')); | ||
if ($prevCacheDir) { | ||
putenv("COMPOSER_CACHE_DIR=$prevCacheDir"); | ||
|
@@ -340,16 +332,7 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla | |
} | ||
chdir($oldPwd); | ||
|
||
if ($PHPUNIT_VERSION < 8.0) { | ||
$argv = array_filter($argv, function ($v) use (&$argc) { | ||
if ('--do-not-cache-result' !== $v) { | ||
return true; | ||
} | ||
--$argc; | ||
|
||
return false; | ||
}); | ||
} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), \FILTER_VALIDATE_BOOLEAN)) { | ||
if (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), \FILTER_VALIDATE_BOOLEAN)) { | ||
$argv[] = '--do-not-cache-result'; | ||
++$argc; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,17 +30,8 @@ public function __construct(string $datetime = 'now', ?\DateTimeZone $timezone = | |
$now = static::createFromInterface($now); | ||
} | ||
|
||
if (\PHP_VERSION_ID < 80300) { | ||
try { | ||
$builtInDate = new parent($datetime, $timezone ?? $now->getTimezone()); | ||
$timezone = $builtInDate->getTimezone(); | ||
} catch (\Exception $e) { | ||
throw new \DateMalformedStringException($e->getMessage(), $e->getCode(), $e); | ||
} | ||
} else { | ||
$builtInDate = new parent($datetime, $timezone ?? $now->getTimezone()); | ||
$timezone = $builtInDate->getTimezone(); | ||
} | ||
$builtInDate = new parent($datetime, $timezone ?? $now->getTimezone()); | ||
$timezone = $builtInDate->getTimezone(); | ||
|
||
$now = $now->setTimezone($timezone)->modify($datetime); | ||
|
||
|
@@ -74,23 +65,7 @@ public static function createFromMutable(\DateTime $object): static | |
|
||
public static function createFromTimestamp(int|float $timestamp): static | ||
{ | ||
if (\PHP_VERSION_ID >= 80400) { | ||
return parent::createFromTimestamp($timestamp); | ||
} | ||
|
||
if (\is_int($timestamp) || !$ms = (int) $timestamp - $timestamp) { | ||
return static::createFromFormat('U', (string) $timestamp); | ||
} | ||
|
||
if (!is_finite($timestamp) || \PHP_INT_MAX + 1.0 <= $timestamp || \PHP_INT_MIN > $timestamp) { | ||
throw new \DateRangeError(\sprintf('DateTimeImmutable::createFromTimestamp(): Argument #1 ($timestamp) must be a finite number between %s and %s.999999, %s given', \PHP_INT_MIN, \PHP_INT_MAX, $timestamp)); | ||
} | ||
|
||
if ($timestamp < 0) { | ||
$timestamp = (int) $timestamp - 2.0 + $ms; | ||
} | ||
|
||
return static::createFromFormat('U.u', \sprintf('%.6F', $timestamp)); | ||
return parent::createFromTimestamp($timestamp); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we drop the method override entirely now that we don't need to polyfill it ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the decoration remains for the |
||
} | ||
|
||
public function add(\DateInterval $interval): static | ||
|
@@ -108,10 +83,6 @@ public function sub(\DateInterval $interval): static | |
*/ | ||
public function modify(string $modifier): static | ||
{ | ||
if (\PHP_VERSION_ID < 80300) { | ||
return @parent::modify($modifier) ?: throw new \DateMalformedStringException(error_get_last()['message'] ?? \sprintf('Invalid modifier: "%s".', $modifier)); | ||
} | ||
|
||
return parent::modify($modifier); | ||
} | ||
|
||
|
@@ -151,19 +122,6 @@ public function setMicrosecond(int $microsecond): static | |
throw new \DateRangeError('DatePoint::setMicrosecond(): Argument #1 ($microsecond) must be between 0 and 999999, '.$microsecond.' given'); | ||
} | ||
|
||
if (\PHP_VERSION_ID < 80400) { | ||
return $this->setTime(...explode('.', $this->format('H.i.s.'.$microsecond))); | ||
} | ||
|
||
return parent::setMicrosecond($microsecond); | ||
} | ||
|
||
public function getMicrosecond(): int | ||
{ | ||
if (\PHP_VERSION_ID >= 80400) { | ||
return parent::getMicrosecond(); | ||
} | ||
|
||
return $this->format('u'); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the
if ($manager instanceof LazyObjectInterface) {
above also dead code ? Or is there still a case where we use a LazyObjectInterface of var-exporter instead of a native lazy object on PHP 8.4+ ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LazyObjectInterface is not deprecated, it's still used for lazy decorators, which is the remaining feature on the topic.