Skip to content

Commit a1b507f

Browse files
Merge branch '4.4' into 5.0
* 4.4: Parse and render anonymous classes correctly on php 8 Enable APCu for the php 8 build. [Process] Fix failing test on php 8. [HttpKernel] fix test Make PHP 8 green on Travis Revert "[Cache] allow DBAL v3" [PropertyAccessor] Added missing property path on php 8. Don't execute tests with DBAL 2.x on php 8.
2 parents dc9df58 + 6b456a7 commit a1b507f

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

Application.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -774,17 +774,16 @@ protected function doRenderThrowable(\Throwable $e, OutputInterface $output): vo
774774
do {
775775
$message = trim($e->getMessage());
776776
if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
777-
$class = \get_class($e);
778-
$class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class;
777+
$class = get_debug_type($e);
779778
$title = sprintf(' [%s%s] ', $class, 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
780779
$len = Helper::strlen($title);
781780
} else {
782781
$len = 0;
783782
}
784783

785-
if (false !== strpos($message, "class@anonymous\0")) {
786-
$message = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) {
787-
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
784+
if (false !== strpos($message, "@anonymous\0")) {
785+
$message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) {
786+
return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0];
788787
}, $message);
789788
}
790789

Tests/ApplicationTest.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,8 @@ public function testRenderAnonymousException()
883883
$application = new Application();
884884
$application->setAutoExit(false);
885885
$application->register('foo')->setCode(function () {
886-
throw new class('') extends \InvalidArgumentException { };
886+
throw new class('') extends \InvalidArgumentException {
887+
};
887888
});
888889
$tester = new ApplicationTester($application);
889890

@@ -893,20 +894,22 @@ public function testRenderAnonymousException()
893894
$application = new Application();
894895
$application->setAutoExit(false);
895896
$application->register('foo')->setCode(function () {
896-
throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', \get_class(new class() { })));
897+
throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', \get_class(new class() {
898+
})));
897899
});
898900
$tester = new ApplicationTester($application);
899901

900902
$tester->run(['command' => 'foo'], ['decorated' => false]);
901-
$this->assertStringContainsString('Dummy type "@anonymous" is invalid.', $tester->getDisplay(true));
903+
$this->assertStringContainsString('Dummy type "class@anonymous" is invalid.', $tester->getDisplay(true));
902904
}
903905

904906
public function testRenderExceptionStackTraceContainsRootException()
905907
{
906908
$application = new Application();
907909
$application->setAutoExit(false);
908910
$application->register('foo')->setCode(function () {
909-
throw new class('') extends \InvalidArgumentException { };
911+
throw new class('') extends \InvalidArgumentException {
912+
};
910913
});
911914
$tester = new ApplicationTester($application);
912915

@@ -916,12 +919,13 @@ public function testRenderExceptionStackTraceContainsRootException()
916919
$application = new Application();
917920
$application->setAutoExit(false);
918921
$application->register('foo')->setCode(function () {
919-
throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', \get_class(new class() { })));
922+
throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', \get_class(new class() {
923+
})));
920924
});
921925
$tester = new ApplicationTester($application);
922926

923927
$tester->run(['command' => 'foo'], ['decorated' => false]);
924-
$this->assertStringContainsString('Dummy type "@anonymous" is invalid.', $tester->getDisplay(true));
928+
$this->assertStringContainsString('Dummy type "class@anonymous" is invalid.', $tester->getDisplay(true));
925929
}
926930

927931
public function testRun()

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"php": ">=7.2.5",
2020
"symfony/polyfill-mbstring": "~1.0",
2121
"symfony/polyfill-php73": "^1.8",
22+
"symfony/polyfill-php80": "^1.15",
2223
"symfony/service-contracts": "^1.1|^2"
2324
},
2425
"require-dev": {

0 commit comments

Comments
 (0)