Skip to content
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

PHP 7.4 compatibility #1113

Merged
merged 9 commits into from
Aug 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ composer.lock
phpcs.xml
.phpcs-cache
/doc/_build/*
/.phpunit.result.cache
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ matrix:
include:
- php: 7.2
- php: 7.3
- php: "7.4snapshot"
- php: 7.2
env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable'
- php: 7.2
env: TARGET=docs
- php: 7.2
env: TARGET=cs
fast_finish: true

install:
Expand Down
9 changes: 9 additions & 0 deletions .travis/install_cs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -ex

composer self-update

phpenv config-rm xdebug.ini

composer update -n
7 changes: 5 additions & 2 deletions .travis/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

set -ex

if [[ $TRAVIS_PHP_VERSION = '7.2' ]]; then PHPUNIT_FLAGS="--coverage-clover clover"; else PHPUNIT_FLAGS=""; fi
if [[ $TRAVIS_PHP_VERSION != '7.2' ]]; then phpenv config-rm xdebug.ini; fi
composer self-update

if [[ $TRAVIS_PHP_VERSION = '7.2' ]]; then PHPUNIT_FLAGS="--coverage-clover clover"; else PHPUNIT_FLAGS=""; fi
if [[ $TRAVIS_PHP_VERSION != '7.2' ]]; then phpenv config-rm xdebug.ini || true; fi
if [[ $TRAVIS_PHP_VERSION == '7.4'* ]]; then composer require --dev --no-update "symfony/cache:^4.4@dev"; fi

composer update $COMPOSER_FLAGS -n
6 changes: 6 additions & 0 deletions .travis/script_cs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -ex

vendor/bin/phpcs

2 changes: 1 addition & 1 deletion .travis/script_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ vendor/bin/phpunit $PHPUNIT_FLAGS
phpenv config-rm xdebug.ini || true
php tests/benchmark.php json 3
php tests/benchmark.php xml 3
vendor/bin/phpcs

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"symfony/form": "^3.0|^4.0",
"symfony/filesystem": "^3.0|^4.0",
"symfony/expression-language": "^3.0|^4.0",
"phpunit/phpunit": "^7.5",
"phpunit/phpunit": "^7.5||^8.0",
"doctrine/coding-standard": "^5.0"
},
"conflict": {
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
failOnWarning="false"
bootstrap="tests/bootstrap.php"
>
<php>
Expand Down
2 changes: 1 addition & 1 deletion src/SerializationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,6 @@ public function getInitialType(): ?string
{
return $this->initialType
? $this->initialType
: $this->hasAttribute('initial_type') ? $this->getAttribute('initial_type') : null;
: ($this->hasAttribute('initial_type') ? $this->getAttribute('initial_type') : null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ExpressionLanguageExclusionStrategyTest extends TestCase
private $expressionEvaluator;
private $exclusionStrategy;

public function setUp()
protected function setUp(): void
{
$this->visitedObject = new \stdClass();

Expand Down
2 changes: 1 addition & 1 deletion tests/Expression/ExpressionEvaluatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ExpressionEvaluatorTest extends TestCase
*/
private $evaluator;

public function setUp()
protected function setUp(): void
{
$this->evaluator = new ExpressionEvaluator(new ExpressionLanguage());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Handler/ArrayCollectionDepthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ArrayCollectionDepthTest extends TestCase
/** @var JMSSerializer */
private $serializer;

public function setUp()
protected function setUp(): void
{
$this->serializer = SerializerBuilder::create()->build();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Handler/DateHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DateHandlerTest extends TestCase
*/
private $timezone;

public function setUp()
protected function setUp(): void
{
$this->handler = new DateHandler();
$this->timezone = new \DateTimeZone('UTC');
Expand Down
4 changes: 2 additions & 2 deletions tests/Handler/FormErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FormErrorHandlerTest extends TestCase
*/
protected $factory;

public function setUp()
protected function setUp(): void
{
$this->handler = new FormErrorHandler(new Translator('en'));
$navigator = $this->getMockBuilder(GraphNavigatorInterface::class)->getMock();
Expand All @@ -55,7 +55,7 @@ public function setUp()
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
}

protected function tearDown()
protected function tearDown(): void
{
$this->handler = null;
$this->visitor = null;
Expand Down
2 changes: 1 addition & 1 deletion tests/Handler/HandlerRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class HandlerRegistryTest extends TestCase
{
protected $handlerRegistry;

protected function setUp()
protected function setUp(): void
{
$this->handlerRegistry = $this->createHandlerRegistry();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Handler/LazyHandlerRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ abstract class LazyHandlerRegistryTest extends HandlerRegistryTest
{
protected $container;

protected function setUp()
protected function setUp(): void
{
$this->container = $this->createContainer();

Expand Down
2 changes: 1 addition & 1 deletion tests/Serializer/ArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ArrayTest extends TestCase
{
protected $serializer;

public function setUp()
protected function setUp(): void
{
$builder = SerializerBuilder::create();
$this->serializer = $builder->build();
Expand Down
2 changes: 1 addition & 1 deletion tests/Serializer/BaseSerializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,7 @@ protected function deserialize($content, $type, ?Context $context = null)
return $this->serializer->deserialize($content, $type, $this->getFormat(), $context);
}

protected function setUp()
protected function setUp(): void
{
$this->handlerRegistry = new HandlerRegistry();
$this->handlerRegistry->registerSubscribingHandler(new ConstraintViolationHandler());
Expand Down
2 changes: 1 addition & 1 deletion tests/Serializer/Doctrine/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function testDiscriminatorIsInferredFromDoctrine()
self::assertEquals('{"id":1,"teacher":{"id":1,"type":"teacher"},"students":[{"id":2,"type":"student"},{"id":3,"type":"student"}]}', $json);
}

protected function setUp()
protected function setUp(): void
{
$connection = $this->createConnection();
$entityManager = $this->createEntityManager($connection);
Expand Down
2 changes: 1 addition & 1 deletion tests/Serializer/Doctrine/ObjectConstructorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static function ($id) use ($connection, $entityManager) {
$constructor->construct($this->visitor, $class, ['metaTitle' => 'test'], $type, $this->context);
}

protected function setUp()
protected function setUp(): void
{
$this->visitor = $this->getMockBuilder(DeserializationVisitorInterface::class)->getMock();
$this->context = $this->getMockBuilder('JMS\Serializer\DeserializationContext')->getMock();
Expand Down
2 changes: 1 addition & 1 deletion tests/Serializer/EventDispatcher/EventDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function testAddSubscriber()
], 'listeners', $this->dispatcher);
}

protected function setUp()
protected function setUp(): void
{
$this->context = $this->getMockBuilder(Context::class)->getMock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract class LazyEventDispatcherTest extends EventDispatcherTest
{
protected $container;

protected function setUp()
protected function setUp(): void
{
$this->container = $this->createContainer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function testOnPreSerializeMaintainsParams()
self::assertSame(['name' => SimpleObject::class, 'params' => ['baz']], $event->getType());
}

protected function setUp()
protected function setUp(): void
{
$this->subscriber = new DoctrineProxySubscriber();
$this->context = $this->getMockBuilder(Context::class)->getMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testValidationIsOnlyPerformedOnRootObject()
self::assertCount(2, $list);
}

protected function setUp()
protected function setUp(): void
{
$this->validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock();
$this->subscriber = new SymfonyValidatorValidatorSubscriber($this->validator);
Expand Down
2 changes: 1 addition & 1 deletion tests/Serializer/GraphNavigatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function testNavigatorChangeTypeOnSerialization()
$navigator->accept($object, null);
}

protected function setUp()
protected function setUp(): void
{
$this->deserializationVisitor = $this->getMockBuilder(DeserializationVisitorInterface::class)->getMock();
$this->serializationVisitor = $this->getMockBuilder(SerializationVisitorInterface::class)->getMock();
Expand Down
2 changes: 1 addition & 1 deletion tests/Serializer/SerializationContextFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SerializationContextFactoryTest extends TestCase
protected $serializationVisitors;
protected $deserializationVisitors;

public function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
4 changes: 2 additions & 2 deletions tests/SerializerBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public function testExpressionEngineWhenDeserializing()
self::assertEquals($person, $object);
}

protected function setUp()
protected function setUp(): void
{
$this->builder = SerializerBuilder::create();
$this->fs = new Filesystem();
Expand All @@ -264,7 +264,7 @@ protected function setUp()
clearstatcache();
}

protected function tearDown()
protected function tearDown(): void
{
$this->fs->remove($this->tmpDir);
}
Expand Down