8000 Make PHP 8 green on Travis · symfony/symfony@571d46c · GitHub
[go: up one dir, main page]

Skip to content

Commit 571d46c

Browse files
Make PHP 8 green on Travis
1 parent 896b69c commit 571d46c

File tree

14 files changed

+64
-25
lines changed

14 files changed

+64
-25
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ matrix:
3232
- php: nightly
3333
services: [memcached]
3434
fast_finish: true
35-
allow_failures:
36-
- php: nightly
3735

3836
cache:
3937
directories:
@@ -264,6 +262,7 @@ install:
264262
# Set composer's platform to php 7.4 if we're on php 8.
265263
if [[ $PHP = nightly ]]; then
266264
composer config platform.php 7.4.99
265+
export SYMFONY_DEPRECATIONS_HELPER=weak
267266
fi
268267
269268
- |

src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Symfony\Component\DependencyInjection\Reference;
2424
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
2525
use Symfony\Component\DependencyInjection\Tests\Fixtures\includes\FooVariadic;
26+
use Symfony\Component\DependencyInjection\Tests\Fixtures\includes\MultipleArgumentsOptionalScalarNotReallyOptional;
2627
use Symfony\Component\DependencyInjection\TypedReference;
2728

2829
require_once __DIR__.'/../Fixtures/includes/autowiring_classes.php';
@@ -473,6 +474,9 @@ public function testNoTypeArgsCannotBeAutowired()
473474
(new AutowirePass())->process($container);
474475
}
475476

477+
/**
478+
* @requires PHP < 8
479+
*/
476480
public function testOptionalScalarNotReallyOptionalUsesDefaultValue()
477481
{
478482
$container = new ContainerBuilder();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\includes;
4+
5+
use Symfony\Component\DependencyInjection\Tests\Compiler\A;
6+
use Symfony\Component\DependencyInjection\Tests\Compiler\Lille;
7+
8+
class MultipleArgumentsOptionalScalarNotReallyOptional
9+
{
10+
public function __construct(A $a, $foo = 'default_val', Lille $lille)
11+
{
12+
}
13+
}
14+

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,6 @@ public function __construct(A $a, Lille $lille, $foo = 'some_val')
184184
{
185185
}
186186
}
187-
class MultipleArgumentsOptionalScalarNotReallyOptional
188-
{
189-
public function __construct(A $a, $foo = 'default_val', Lille $lille)
190-
{
191-
}
192-
}
193187

194188
/*
195189
* Classes used for testing createResourceForClass

src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ public function testGetNullableArguments()
216216
$request = Request::create('/');
217217
$request->attributes->set('foo', 'foo');
218218
$request->attributes->set('bar', new \stdClass());
219-
$request->attributes->set('mandatory', 'mandatory');
219+
$request->attributes->set('last', 'last');
220220
$controller = [new NullableController(), 'action'];
221221

222-
$this->assertEquals(['foo', new \stdClass(), 'value', 'mandatory'], self::$resolver->getArguments($request, $controller));
222+
$this->assertEquals(['foo', new \stdClass(), 'value', 'last'], self::$resolver->getArguments($request, $controller));
223223
}
103C6
224224

225225
/**
@@ -228,10 +228,10 @@ public function testGetNullableArguments()
228228
public function testGetNullableArgumentsWithDefaults()
229229
{
230230
$request = Request::create('/');
231-
$request->attributes->set('mandatory', 'mandatory');
231+
$request->attributes->set('last', 'last');
232232
$controller = [new NullableController(), 'action'];
233233

234-
$this->assertEquals([null, null, 'value', 'mandatory'], self::$resolver->getArguments($request, $controller));
234+
$this->assertEquals([null, null, 'value', 'last'], self::$resolver->getArguments($request, $controller));
235235
}
236236

237237
public function testGetSessionArguments()

src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Psr\Log\LoggerInterface;
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
18-
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\NullableController;
18+
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\LegacyNullableController;
1919
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController;
2020

2121
class ControllerResolverTest extends TestCase
@@ -243,6 +243,7 @@ public function testIfExceptionIsThrownWhenMissingAnArgument()
243243

244244
/**
245245
* @requires PHP 7.1
246+
* @requires PHP < 8
246247
* @group legacy
247248
*/
248249
public function testGetNullableArguments()
@@ -253,12 +254,13 @@ public function testGetNullableArguments()
253254
$request->attributes->set('foo', 'foo');
254255
$request->attributes->set('bar', new \stdClass());
255256
$request->attributes->set('mandatory', 'mandatory');
256-
$controller = [new NullableController(), 'action'];
257+
$controller = [new LegacyNullableController(), 'action'];
257258
$this->assertEquals(['foo', new \stdClass(), 'value', 'mandatory'], $resolver->getArguments($request, $controller));
258259
}
259260

260261
/**
261262
* @requires PHP 7.1
263+
* @requires PHP < 8
262264
* @group legacy
263265
*/
264266
public function testGetNullableArgumentsWithDefaults()
@@ -267,7 +269,7 @@ public function testGetNullableArgumentsWithDefaults()
267269

268270
$request = Request::create('/');
269271
$request->attributes->set('mandatory', 'mandatory');
270-
$controller = [new NullableController(), 'action'];
272+
$controller = [new LegacyNullableController(), 'action'];
271273
$this->assertEquals([null, null, 'value', 'mandatory'], $resolver->getArguments($request, $controller));
272274
}
273275

src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function testSignature5()
8080

8181
$this->assertEquals([
8282
new ArgumentMetadata('foo', 'array', false, true, null, true),
83-
new ArgumentMetadata('bar', null, false, false, null),
83+
new ArgumentMetadata('bar', null, false, true, null, true),
8484
], $arguments);
8585
}
8686

@@ -122,7 +122,7 @@ public function testNullableTypesSignature()
122122
new ArgumentMetadata('foo', 'string', false, false, null, true),
123123
new ArgumentMetadata('bar', \stdClass::class, false, false, null, true),
124124
new ArgumentMetadata('baz', 'string', false, true, 'value', true),
125-
new ArgumentMetadata('mandatory', null, false, false, null, true),
125+
new ArgumentMetadata('last', 'string', false, true, '', false),
126126
], $arguments);
127127
}
128128

@@ -142,7 +142,7 @@ private function signature4($foo = 'default', $bar = 500, $baz = [])
142142
{
143143
}
144144

145-
private function signature5(array $foo = null, $bar)
145+
private function signature5(array $foo = null, $bar = null)
146146
{
147147
}
148148
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller;
13+
14+
class LegacyNullableController
15+
{
16+
public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', $mandatory)
17+
{
18+
}
19+
}

src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/NullableController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class NullableController
1515
{
16-
public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', $mandatory)
16+
public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', string $last = '')
1717
{
1818
}
1919
}

src/Symfony/Component/Process/Pipes/UnixPipes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function readAndWrite($blocking, $close = false)
118118
$read[$type = array_search($pipe, $this->pipes, true)] = '';
119119

120120
do {
121-
$data = fread($pipe, self::CHUNK_SIZE);
121+
$data = @fread($pipe, self::CHUNK_SIZE);
122122
$read[$type] .= $data;
123123
} while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
124124

src/Symfony/Component/Process/Tests/ProcessTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,16 +987,23 @@ public function provideMethodsThatNeedATerminatedProcess()
987987
*/
988988
public function testWrongSignal($signal)
989989
{
990-
$this->expectException('Symfony\Component\Process\Exception\RuntimeException');
991990
if ('\\' === \DIRECTORY_SEPARATOR) {
992991
$this->markTestSkipped('POSIX signals do not work on Windows');
993992
}
994993

994+
if (\PHP_VERSION_ID < 80000 || \is_int($signal)) {
995+
$this->expectException(RuntimeException::class);
996+
} else {
997+
$this->expectException('TypeError');
998+
}
999+
9951000
$process = $this->getProcessForCode('sleep(38);');
9961001
$process->start();
9971002
try {
9981003
$process->signal($signal);
9991004
$this->fail('A RuntimeException must have been thrown');
1005+
} catch (\TypeError $e) {
1006+
$process->stop(0);
10001007
} catch (RuntimeException $e) {
10011008
$process->stop(0);
10021009
}

src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function normalize($object, $format = null, array $context = [])
108108
*
109109
* @return string[]
110110
*/
111-
protected function getAttributes($object, $format = null, array $context)
111+
protected function getAttributes($object, $format, array $context)
112112
{
113113
$class = \get_class($object);
114114
$key = $class.'-'.$context['cache_key'];

src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ class GetConstructorArgsWithDefaultValueDummy
728728
protected $foo;
729729
protected $bar;
730730

731-
public function __construct($foo = [], $bar)
731+
public function __construct($foo = [], $bar = null)
732732
{
733733
$this->foo = $foo;
734734
$this->bar = $bar;

src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ class ObjectConstructorArgsWithDefaultValueDummy
925925
protected $foo;
926926
protected $bar;
927927

928-
public function __construct($foo = [], $bar)
928+
public function __construct($foo = [], $bar = null)
929929
{
930930
$this->foo = $foo;
931931
$this->bar = $bar;
@@ -1075,7 +1075,7 @@ class DummyWithConstructorObjectAndDefaultValue
10751075
private $foo;
10761076
private $inner;
10771077

1078-
public function __construct($foo = 'a', ObjectInner $inner)
1078+
public function __construct($foo = 'a', ObjectInner $inner = null)
10791079
{
10801080
$this->foo = $foo;
10811081
$this->inner = $inner;

0 commit comments

Comments
 (0)
0