8000 Merge branch '3.4' into 4.4 · symfony/symfony@8de1091 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8de1091

Browse files
Merge branch '3.4' into 4.4
* 3.4: Skip Doctrine DBAL on php 8 until we have a compatible version. [DomCrawler] Catch expected ValueError. [Validator] Catch expected ValueError. [VarDumper] ReflectionFunction::isDisabled() is deprecated. [PropertyAccess] Parse php 8 TypeErrors correctly. [Intl] Fix call to ReflectionProperty::getValue() for static properties. [HttpKernel] Prevent calling method_exists() with non-string values. [Debug] php 8 does not pass $context to error handlers. [Config] Removed implicit cast of ReflectionProperty to string. [Debug] Undefined variables raise a warning in php 8. [Debug] Skip test that would trigger a fatal error on php 8. Address deprecation of ReflectionType::getClass(). Properties $originalName and $mimeType are never null in UploadedFile
2 parents f32c2c1 + 2799d55 commit 8de1091

File tree

13 files changed

+95
-24
lines changed

13 files changed

+95
-24
lines changed

src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ class EntityTypeTest extends BaseTypeTest
6060

6161
protected static $supportedFeatureSetVersion = 404;
6262

63+
public static function setUpBeforeClass(): void
64+
{
65+
if (\PHP_VERSION_ID >= 80000) {
66+
self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.');
67+
}
68+
}
69+
6370
protected function setUp(): void
6471
{
6572
$this->em = DoctrineTestHelper::createTestEntityManager();

src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424

2525
class EntityUserProviderTest extends TestCase
2626
{
27+
public static function setUpBeforeClass(): void
28+
{
29+
if (\PHP_VERSION_ID >= 80000) {
30+
self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.');
31+
}
32+
}
33+
2734
public function testRefreshUserGetsUserByPrimaryKey()
2835
{
2936
$em = DoctrineTestHelper::createTestEntityManager();

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
5959

6060
protected $repositoryFactory;
6161

62+
public static function setUpBeforeClass(): void
63+
{
64+
if (\PHP_VERSION_ID >= 80000) {
65+
self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.');
66+
}
67+
}
68+
6269
protected function setUp(): void
6370
{
6471
$this->repositoryFactory = new TestRepositoryFactory();

src/Symfony/Component/Cache/composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
},
3131
"require-dev": {
3232
"cache/integration-tests": "dev-master",
33-
"doctrine/cache": "~1.6",
34-
"doctrine/dbal": "~2.5",
35-
"predis/predis": "~1.1",
33+
"doctrine/cache": "^1.6",
34+
"doctrine/dbal": "^2.5|^3.0",
35+
"predis/predis": "^1.1",
3636
"psr/simple-cache": "^1.0",
3737
"symfony/config": "^4.2|^5.0",
3838
"symfony/dependency-injection": "^3.4|^4.1|^5.0",

src/Symfony/Component/Config/Resource/ReflectionClassResource.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ private function generateSignature(\ReflectionClass $class): iterable
135135
$defaults = $class->getDefaultProperties();
136136

137137
foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) {
138-
yield $p->getDocComment().$p;
138+
yield $p->getDocComment();
139+
yield $p->isDefault() ? '<default>' : '';
140+
yield $p->isPublic() ? 'public' : 'protected';
141+
yield $p->isStatic() ? 'static' : '';
142+
yield '$'.$p->name;
139143
yield print_r(isset($defaults[$p->name]) && !\is_object($defaults[$p->name]) ? $defaults[$p->name] : null, true);
140144
}
141145
}

src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,14 @@ public function testNotice()
103103
$this->fail('ErrorException expected');
104104
} catch (\ErrorException $exception) {
105105
// if an exception is thrown, the test passed
106-
$this->assertEquals(E_NOTICE, $exception->getSeverity());
106+
if (\PHP_VERSION_ID < 80000) {
107+
$this->assertEquals(E_NOTICE, $exception->getSeverity());
108+
$this->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage());
109+
} else {
110+
$this->assertEquals(E_WARNING, $exception->getSeverity());
111+
$this->assertRegExp('/^Warning: Undefined variable \$(foo|bar)/', $exception->getMessage());
112+
}
107113
$this->assertEquals(__FILE__, $exception->getFile());
108-
$this->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage());
109114

110115
$trace = $exception->getTrace();
111116

@@ -249,11 +254,17 @@ public function testHandleError()
249254

250255
$line = null;
251256
$logArgCheck = function ($level, $message, $context) use (&$line) {
252-
$this->assertEquals('Notice: Undefined variable: undefVar', $message);
253257
$this->assertArrayHasKey('exception', $context);
254258
$exception = $context['exception'];
259+
260+
if (\PHP_VERSION_ID < 80000) {
261+
$this->assertEquals('Notice: Undefined variable: undefVar', $message);
262+
$this->assertSame(E_NOTICE, $exception->getSeverity());
263+
} else {
264+
$this->assertEquals('Warning: Undefined variable $undefVar', $message);
265+
$this->assertSame(E_WARNING, $exception->getSeverity());
266+
}
255267
$this->assertInstanceOf(SilencedErrorContext::class, $exception);
256-
$this->assertSame(E_NOTICE, $exception->getSeverity());
257268
$this->assertSame(__FILE__, $exception->getFile());
258269
$this->assertSame($line, $exception->getLine());
259270
$this->assertNotEmpty($exception->getTrace());
@@ -267,8 +278,13 @@ public function testHandleError()
267278
;
268279

269280
$handler = ErrorHandler::register();
270-
$handler->setDefaultLogger($logger, E_NOTICE);
271-
$handler->screamAt(E_NOTICE);
281+
if (\PHP_VERSION_ID < 80000) {
282+
$handler->setDefaultLogger($logger, E_NOTICE);
283+
$handler->screamAt(E_NOTICE);
284+
} else {
285+
$handler->setDefaultLogger($logger, E_WARNING);
286+
$handler->screamAt(E_WARNING);
287+
}
272288
unset($undefVar);
273289
$line = __LINE__ + 1;
274290
@$undefVar++;

src/Symfony/Component/Debug/Tests/Fixtures/ErrorHandlerThatUsesThePreviousOne.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public static function register()
1515
return $handler;
1616
}
1717

18-
public function handleError($type, $message, $file, $line, $context)
18+
public function handleError()
1919
{
20-
return \call_user_func(self::$previous, $type, $message, $file, $line, $context);
20+
return \call_user_func_array(self::$previous, \func_get_args());
2121
}
2222
}

src/Symfony/Component/HttpFoundation/File/UploadedFile.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232
class UploadedFile extends File
3333
{
34-
private $test = false;
34+
private $test;
3535
private $originalName;
3636
private $mimeType;
3737
private $error;
@@ -83,7 +83,7 @@ public function __construct(string $path, string $originalName, string $mimeType
8383
* It is extracted from the request from which the file has been uploaded.
8484
* Then it should not be considered as a safe value.
8585
*
86-
* @return string|null The original name
86+
* @return string The original name
8787
*/
8888
public function getClientOriginalName()
8989
{
@@ -112,7 +112,7 @@ public function getClientOriginalExtension()
112112
* For a trusted mime type, use getMimeType() instead (which guesses the mime
113113
* type based on the file content).
114114
*
115-
* @return string|null The mime type
115+
* @return string The mime type
116116
*
117117
* @see getMimeType()
118118
*/

src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ public function testGetSymbol()
602602

603603
$r = new \ReflectionProperty('Symfony\Component\Intl\NumberFormatter\NumberFormatter', 'enSymbols');
604604
$r->setAccessible(true);
605-
$expected = $r->getValue('Symfony\Component\Intl\NumberFormatter\NumberFormatter');
605+
$expected = $r->getValue();
606606

607607
for ($i = 0; $i <= 17; ++$i) {
608608
$this->assertSame($expected[1][$i], $decimalFormatter->getSymbol($i));
@@ -619,7 +619,7 @@ public function testGetTextAttribute()
619619

620620
$r = new \ReflectionProperty('Symfony\Component\Intl\NumberFormatter\NumberFormatter', 'enTextAttributes');
621621
$r->setAccessible(true);
622-
$expected = $r->getValue('Symfony\Component\Intl\NumberFormatter\NumberFormatter');
622+
$expected = $r->getValue();
623623

624624
for ($i = 0; $i <= 5; ++$i) {
625625
$this->assertSame($expected[1][$i], $decimalFormatter->getTextAttribute($i));

src/Symfony/Component/OptionsResolver/OptionsResolver.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function setDefault($option, $value)
180180
$reflClosure = new \ReflectionFunction($value);
181181
$params = $reflClosure->getParameters();
182182

183-
if (isset($params[0]) && null !== ($class = $params[0]->getClass()) && Options::class === $class->name) {
183+
if (isset($params[0]) && Options::class === $this->getParameterClassName($params[0])) {
184184
// Initialize the option if no previous value exists
185185
if (!isset($this->defaults[$option])) {
186186
$this->defaults[$option] = null;
@@ -1217,4 +1217,13 @@ private function formatOptions(array $options): string
12171217

12181218
return implode('", "', $options);
12191219
}
1220+
1221+
private function getParameterClassName(\ReflectionParameter $parameter): ?string
1222+
{
1223+
if (!($type = $parameter->getType()) || $type->isBuiltin()) {
1224+
return null;
1225+
}
1226+
1227+
return $type->getName();
1228+
}
12201229
}

0 commit comments

Comments
 (0)
0