minor #36930 Make PHP 8 green on Travis (nicolas-grekas)
This PR was merged into the 3.4 branch.
Discussion
----------
Make PHP 8 green on Travis
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | #36872
| License | MIT
| Doc PR | -
See #36872 for preparatory work and remaining steps.
Commits
-------
571d46cf01
Make PHP 8 green on Travis
This commit is contained in:
commit
d6902039c4
@ -32,8 +32,6 @@ matrix:
|
||||
- php: nightly
|
||||
services: [memcached]
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
|
||||
cache:
|
||||
directories:
|
||||
@ -264,6 +262,7 @@ install:
|
||||
# Set composer's platform to php 7.4 if we're on php 8.
|
||||
if [[ $PHP = nightly ]]; then
|
||||
composer config platform.php 7.4.99
|
||||
export SYMFONY_DEPRECATIONS_HELPER=weak
|
||||
fi
|
||||
|
||||
- |
|
||||
|
@ -23,6 +23,7 @@ use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
|
||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\includes\FooVariadic;
|
||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\includes\MultipleArgumentsOptionalScalarNotReallyOptional;
|
||||
use Symfony\Component\DependencyInjection\TypedReference;
|
||||
|
||||
require_once __DIR__.'/../Fixtures/includes/autowiring_classes.php';
|
||||
@ -473,6 +474,9 @@ class AutowirePassTest extends TestCase
|
||||
(new AutowirePass())->process($container);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP < 8
|
||||
*/
|
||||
public function testOptionalScalarNotReallyOptionalUsesDefaultValue()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\includes;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Tests\Compiler\A;
|
||||
use Symfony\Component\DependencyInjection\Tests\Compiler\Lille;
|
||||
|
||||
class MultipleArgumentsOptionalScalarNotReallyOptional
|
||||
{
|
||||
public function __construct(A $a, $foo = 'default_val', Lille $lille)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -184,12 +184,6 @@ class MultipleArgumentsOptionalScalarLast
|
||||
{
|
||||
}
|
||||
}
|
||||
class MultipleArgumentsOptionalScalarNotReallyOptional
|
||||
{
|
||||
public function __construct(A $a, $foo = 'default_val', Lille $lille)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Classes used for testing createResourceForClass
|
||||
|
@ -216,10 +216,10 @@ class ArgumentResolverTest extends TestCase
|
||||
$request = Request::create('/');
|
||||
$request->attributes->set('foo', 'foo');
|
||||
$request->attributes->set('bar', new \stdClass());
|
||||
$request->attributes->set('mandatory', 'mandatory');
|
||||
$request->attributes->set('last', 'last');
|
||||
$controller = [new NullableController(), 'action'];
|
||||
|
||||
$this->assertEquals(['foo', new \stdClass(), 'value', 'mandatory'], self::$resolver->getArguments($request, $controller));
|
||||
$this->assertEquals(['foo', new \stdClass(), 'value', 'last'], self::$resolver->getArguments($request, $controller));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -228,10 +228,10 @@ class ArgumentResolverTest extends TestCase
|
||||
public function testGetNullableArgumentsWithDefaults()
|
||||
{
|
||||
$request = Request::create('/');
|
||||
$request->attributes->set('mandatory', 'mandatory');
|
||||
$request->attributes->set('last', 'last');
|
||||
$controller = [new NullableController(), 'action'];
|
||||
|
||||
$this->assertEquals([null, null, 'value', 'mandatory'], self::$resolver->getArguments($request, $controller));
|
||||
$this->assertEquals([null, null, 'value', 'last'], self::$resolver->getArguments($request, $controller));
|
||||
}
|
||||
|
||||
public function testGetSessionArguments()
|
||||
|
@ -15,7 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
|
||||
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\NullableController;
|
||||
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\LegacyNullableController;
|
||||
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController;
|
||||
|
||||
class ControllerResolverTest extends TestCase
|
||||
@ -243,6 +243,7 @@ class ControllerResolverTest extends TestCase
|
||||
|
||||
/**
|
||||
* @requires PHP 7.1
|
||||
* @requires PHP < 8
|
||||
* @group legacy
|
||||
*/
|
||||
public function testGetNullableArguments()
|
||||
@ -253,12 +254,13 @@ class ControllerResolverTest extends TestCase
|
||||
$request->attributes->set('foo', 'foo');
|
||||
$request->attributes->set('bar', new \stdClass());
|
||||
$request->attributes->set('mandatory', 'mandatory');
|
||||
$controller = [new NullableController(), 'action'];
|
||||
$controller = [new LegacyNullableController(), 'action'];
|
||||
$this->assertEquals(['foo', new \stdClass(), 'value', 'mandatory'], $resolver->getArguments($request, $controller));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7.1
|
||||
* @requires PHP < 8
|
||||
* @group legacy
|
||||
*/
|
||||
public function testGetNullableArgumentsWithDefaults()
|
||||
@ -267,7 +269,7 @@ class ControllerResolverTest extends TestCase
|
||||
|
||||
$request = Request::create('/');
|
||||
$request->attributes->set('mandatory', 'mandatory');
|
||||
$controller = [new NullableController(), 'action'];
|
||||
$controller = [new LegacyNullableController(), 'action'];
|
||||
$this->assertEquals([null, null, 'value', 'mandatory'], $resolver->getArguments($request, $controller));
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ class ArgumentMetadataFactoryTest extends TestCase
|
||||
|
||||
$this->assertEquals([
|
||||
new ArgumentMetadata('foo', 'array', false, true, null, true),
|
||||
new ArgumentMetadata('bar', null, false, false, null),
|
||||
new ArgumentMetadata('bar', null, false, true, null, true),
|
||||
], $arguments);
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ class ArgumentMetadataFactoryTest extends TestCase
|
||||
new ArgumentMetadata('foo', 'string', false, false, null, true),
|
||||
new ArgumentMetadata('bar', \stdClass::class, false, false, null, true),
|
||||
new ArgumentMetadata('baz', 'string', false, true, 'value', true),
|
||||
new ArgumentMetadata('mandatory', null, false, false, null, true),
|
||||
new ArgumentMetadata('last', 'string', false, true, '', false),
|
||||
], $arguments);
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ class ArgumentMetadataFactoryTest extends TestCase
|
||||
{
|
||||
}
|
||||
|
||||
private function signature5(array $foo = null, $bar)
|
||||
private function signature5(array $foo = null, $bar = null)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller;
|
||||
|
||||
class LegacyNullableController
|
||||
{
|
||||
public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', $mandatory)
|
||||
{
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller;
|
||||
|
||||
class NullableController
|
||||
{
|
||||
public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', $mandatory)
|
||||
public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', string $last = '')
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ class UnixPipes extends AbstractPipes
|
||||
$read[$type = array_search($pipe, $this->pipes, true)] = '';
|
||||
|
||||
do {
|
||||
$data = fread($pipe, self::CHUNK_SIZE);
|
||||
$data = @fread($pipe, self::CHUNK_SIZE);
|
||||
$read[$type] .= $data;
|
||||
} while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
|
||||
|
||||
|
@ -987,16 +987,23 @@ class ProcessTest extends TestCase
|
||||
*/
|
||||
public function testWrongSignal($signal)
|
||||
{
|
||||
$this->expectException('Symfony\Component\Process\Exception\RuntimeException');
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('POSIX signals do not work on Windows');
|
||||
}
|
||||
|
||||
if (\PHP_VERSION_ID < 80000 || \is_int($signal)) {
|
||||
$this->expectException(RuntimeException::class);
|
||||
} else {
|
||||
$this->expectException('TypeError');
|
||||
}
|
||||
|
||||
$process = $this->getProcessForCode('sleep(38);');
|
||||
$process->start();
|
||||
try {
|
||||
$process->signal($signal);
|
||||
$this->fail('A RuntimeException must have been thrown');
|
||||
} catch (\TypeError $e) {
|
||||
$process->stop(0);
|
||||
} catch (RuntimeException $e) {
|
||||
$process->stop(0);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getAttributes($object, $format = null, array $context)
|
||||
protected function getAttributes($object, $format, array $context)
|
||||
{
|
||||
$class = \get_class($object);
|
||||
$key = $class.'-'.$context['cache_key'];
|
||||
|
@ -728,7 +728,7 @@ class GetConstructorArgsWithDefaultValueDummy
|
||||
protected $foo;
|
||||
protected $bar;
|
||||
|
||||
public function __construct($foo = [], $bar)
|
||||
public function __construct($foo = [], $bar = null)
|
||||
{
|
||||
$this->foo = $foo;
|
||||
$this->bar = $bar;
|
||||
|
@ -925,7 +925,7 @@ class ObjectConstructorArgsWithDefaultValueDummy
|
||||
protected $foo;
|
||||
protected $bar;
|
||||
|
||||
public function __construct($foo = [], $bar)
|
||||
public function __construct($foo = [], $bar = null)
|
||||
{
|
||||
$this->foo = $foo;
|
||||
$this->bar = $bar;
|
||||
@ -1075,7 +1075,7 @@ class DummyWithConstructorObjectAndDefaultValue
|
||||
private $foo;
|
||||
private $inner;
|
||||
|
||||
public function __construct($foo = 'a', ObjectInner $inner)
|
||||
public function __construct($foo = 'a', ObjectInner $inner = null)
|
||||
{
|
||||
$this->foo = $foo;
|
||||
$this->inner = $inner;
|
||||
|
Reference in New Issue
Block a user