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

php8 attributes are enabled by default on php8 or higher #1338

Merged
merged 1 commit into from
Aug 3, 2021
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
5 changes: 2 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ jobs:
- "lowest"
- "highest"
include:
- { php-version: '8.0', dependencies: 'highest', enable-attributes: '1' }
- { php-version: '8.0', dependencies: 'highest' }
- { php-version: '8.1', dependencies: 'highest', composer-options: '--ignore-platform-req=php' }
- { php-version: '8.1', dependencies: 'highest', composer-options: '--ignore-platform-req=php' }
- { php-version: '8.1', dependencies: 'highest', composer-options: '--ignore-platform-req=php', enable-attributes: '1' }

env:
ENABLE_ATTRIBUTES: "${{matrix.enable-attributes}}"
JMS_TESTS_SHOW_DEPRECATIONS: 1

steps:
Expand Down
6 changes: 3 additions & 3 deletions tests/Deserializer/BaseDeserializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

use JMS\Serializer\DeserializationContext;
use JMS\Serializer\Exception\NonCastableTypeException;
use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\Tests\Fixtures\Discriminator\Car;
use JMS\Serializer\Tests\Fixtures\GroupsObject;
use JMS\Serializer\Tests\Fixtures\Price;
use JMS\Serializer\Tests\Fixtures\Publisher;
use JMS\Serializer\Tests\SerializerBuilderStrategy;
use PHPUnit\Framework\TestCase;

class BaseDeserializationTest extends TestCase
Expand All @@ -20,7 +20,7 @@ class BaseDeserializationTest extends TestCase
*/
public function testDeserializationInvalidDataCausesException($data, string $type): void
{
$serializer = SerializerBuilderStrategy::create()->build();
$serializer = SerializerBuilder::create()->build();

$this->expectException(NonCastableTypeException::class);

Expand Down Expand Up @@ -50,7 +50,7 @@ public function dataTypeCannotBeCasted(): iterable
*/
public function testDeserializerGroupExclusion(array $data, array $groups, array $expected): void
{
$serializer = SerializerBuilderStrategy::create()->build();
$serializer = SerializerBuilder::create()->build();
$context = DeserializationContext::create()->setGroups($groups);
$object = $serializer->fromArray($data, GroupsObject::class, $context);
self::assertSame($expected, $serializer->toArray($object));
Expand Down
4 changes: 2 additions & 2 deletions tests/Handler/ArrayCollectionDepthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use JMS\Serializer\Exclusion\DepthExclusionStrategy;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\Serializer as JMSSerializer;
use JMS\Serializer\Tests\SerializerBuilderStrategy;
use JMS\Serializer\SerializerBuilder;
use PHPUnit\Framework\TestCase;

class ArrayCollectionDepthTest extends TestCase
Expand All @@ -20,7 +20,7 @@ class ArrayCollectionDepthTest extends TestCase

protected function setUp(): void
{
$this->serializer = SerializerBuilderStrategy::create()->build();
$this->serializer = SerializerBuilder::create()->build();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Serializer/ArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace JMS\Serializer\Tests\Serializer;

use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\Tests\Fixtures\Author;
use JMS\Serializer\Tests\Fixtures\AuthorList;
use JMS\Serializer\Tests\Fixtures\Order;
use JMS\Serializer\Tests\Fixtures\Price;
use JMS\Serializer\Tests\SerializerBuilderStrategy;
use PHPUnit\Framework\TestCase;

class ArrayTest extends TestCase
Expand All @@ -17,7 +17,7 @@ class ArrayTest extends TestCase

protected function setUp(): void
{
$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$this->serializer = $builder->build();
}

Expand Down
28 changes: 14 additions & 14 deletions tests/Serializer/BaseSerializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use JMS\Serializer\Handler\StdClassHandler;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\Serializer;
use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\Tests\Fixtures\AccessorOrderChild;
use JMS\Serializer\Tests\Fixtures\AccessorOrderMethod;
use JMS\Serializer\Tests\Fixtures\AccessorOrderParent;
Expand Down Expand Up @@ -110,7 +111,6 @@
use JMS\Serializer\Tests\Fixtures\Tree;
use JMS\Serializer\Tests\Fixtures\TypedProperties;
use JMS\Serializer\Tests\Fixtures\VehicleInterfaceGarage;
use JMS\Serializer\Tests\SerializerBuilderStrategy;
use JMS\Serializer\Visitor\DeserializationVisitorInterface;
use JMS\Serializer\Visitor\SerializationVisitorInterface;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -308,7 +308,7 @@ public function testExcludeIfOnClass()

$language = new ExpressionLanguage();

$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$builder->setExpressionEvaluator(new ExpressionEvaluator($language));
$serializer = $builder->build();

Expand All @@ -333,7 +333,7 @@ public function testExcludeIfOnClassWithParent()

$language = new ExpressionLanguage();

$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$builder->setExpressionEvaluator(new ExpressionEvaluator($language));
$serializer = $builder->build();

Expand All @@ -358,7 +358,7 @@ public function testExcludeIfOnParentClass()

$language = new ExpressionLanguage();

$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$builder->setExpressionEvaluator(new ExpressionEvaluator($language));
$serializer = $builder->build();

Expand Down Expand Up @@ -394,7 +394,7 @@ public function testExpressionExclusionConfiguredWithDisjunctStrategy()
return true;
}));

$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$builder->setExpressionEvaluator(new ExpressionEvaluator($language));
$serializer = $builder->build();

Expand Down Expand Up @@ -487,7 +487,7 @@ public function testExpressionExclusion($person, ExpressionFunction $function, $
$language = new ExpressionLanguage();
$language->addFunction($function);

$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$builder->setExpressionEvaluator(new ExpressionEvaluator($language));
$serializer = $builder->build();

Expand Down Expand Up @@ -536,7 +536,7 @@ public function getNumerics()

public function testSimpleInternalObject()
{
$builder = SerializerBuilderStrategy::create($this->handlerRegistry, $this->dispatcher);
$builder = SerializerBuilder::create($this->handlerRegistry, $this->dispatcher);
$builder->setMetadataDirs([
'JMS\Serializer\Tests\Fixtures' => __DIR__ . '/metadata/SimpleInternalObject',
'' => __DIR__ . '/metadata/SimpleInternalObject',
Expand Down Expand Up @@ -845,7 +845,7 @@ public function testDeserializingNull()
{
$objectConstructor = new InitializedBlogPostConstructor();

$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$builder->setObjectConstructor($objectConstructor);
$this->serializer = $builder->build();

Expand All @@ -872,7 +872,7 @@ public function testExpressionAuthor()
{
$evaluator = new ExpressionEvaluator(new ExpressionLanguage());

$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$builder->setExpressionEvaluator($evaluator);
$serializer = $builder->build();

Expand All @@ -884,7 +884,7 @@ public function testExpressionAuthorWithContextVars()
{
$evaluator = new ExpressionEvaluator(new ExpressionLanguage());

$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$builder->setExpressionEvaluator($evaluator);
$serializer = $builder->build();

Expand Down Expand Up @@ -1313,7 +1313,7 @@ public function testVirtualVersions()
{
$evaluator = new ExpressionEvaluator(new ExpressionLanguage());

$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$builder->setExpressionEvaluator($evaluator);
$serializer = $builder->build();

Expand Down Expand Up @@ -1356,7 +1356,7 @@ public function testTypedProperties()
$this->markTestSkipped(sprintf('%s requires PHP 7.4', __METHOD__));
}

$builder = SerializerBuilderStrategy::create($this->handlerRegistry, $this->dispatcher);
$builder = SerializerBuilder::create($this->handlerRegistry, $this->dispatcher);
$builder->includeInterfaceMetadata(true);
$this->serializer = $builder->build();

Expand Down Expand Up @@ -1640,7 +1640,7 @@ public function testDeserializingIntoExistingObject()

$objectConstructor = new InitializedObjectConstructor(new UnserializeObjectConstructor());

$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$builder->setObjectConstructor($objectConstructor);
$serializer = $builder->build();

Expand Down Expand Up @@ -1886,7 +1886,7 @@ static function (DeserializationVisitorInterface $visitor, $data, $type, Context
$this->dispatcher = new EventDispatcher();
$this->dispatcher->addSubscriber(new DoctrineProxySubscriber());

$builder = SerializerBuilderStrategy::create($this->handlerRegistry, $this->dispatcher);
$builder = SerializerBuilder::create($this->handlerRegistry, $this->dispatcher);
$this->serializer = $builder->build();
}

Expand Down
10 changes: 5 additions & 5 deletions tests/Serializer/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
use JMS\Serializer\Metadata\ClassMetadata;
use JMS\Serializer\Metadata\PropertyMetadata;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\Tests\Fixtures\Author;
use JMS\Serializer\Tests\Fixtures\BlogPost;
use JMS\Serializer\Tests\Fixtures\InlineChild;
use JMS\Serializer\Tests\Fixtures\Node;
use JMS\Serializer\Tests\Fixtures\Publisher;
use JMS\Serializer\Tests\Fixtures\VersionedObject;
use JMS\Serializer\Tests\SerializerBuilderStrategy;
use JMS\Serializer\VisitorInterface;
use Metadata\MetadataFactoryInterface;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -85,7 +85,7 @@ public function testSerializationContextPathAndDepth()
}))
->will($this->returnValue(false));

$serializer = SerializerBuilderStrategy::create()->build();
$serializer = SerializerBuilder::create()->build();

$serializer->serialize($object, 'json', SerializationContext::create()->addExclusionStrategy($exclusionStrategy));
}
Expand Down Expand Up @@ -136,7 +136,7 @@ public function testSerializationMetadataStack()
return false;
}));

$serializer = SerializerBuilderStrategy::create()->build();
$serializer = SerializerBuilder::create()->build();
$serializer->serialize($object, 'json', SerializationContext::create()->addExclusionStrategy($exclusionStrategy));
}

Expand Down Expand Up @@ -176,7 +176,7 @@ public function testInitialTypeCompatibility()

public function testMultipleCallsOnGroupsDoNotCreateMultipleExclusionStrategies()
{
$serializer = SerializerBuilderStrategy::create()->build();
$serializer = SerializerBuilder::create()->build();

$context = SerializationContext::create();
$context->setGroups(['foo', 'Default']);
Expand All @@ -193,7 +193,7 @@ public function testMultipleCallsOnGroupsDoNotCreateMultipleExclusionStrategies(

public function testMultipleCallsOnVersionDoNotCreateMultipleExclusionStrategies()
{
$serializer = SerializerBuilderStrategy::create()->build();
$serializer = SerializerBuilder::create()->build();

$context = SerializationContext::create();
$context->setVersion('1.0.1');
Expand Down
4 changes: 2 additions & 2 deletions tests/Serializer/Doctrine/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
use JMS\Serializer\Metadata\Driver\DoctrineTypeDriver;
use JMS\Serializer\Naming\IdenticalPropertyNamingStrategy;
use JMS\Serializer\Serializer;
use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Clazz;
use JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Organization;
use JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Person;
use JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\School;
use JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Student;
use JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Teacher;
use JMS\Serializer\Tests\SerializerBuilderStrategy;
use PHPUnit\Framework\TestCase;

class IntegrationTest extends TestCase
Expand Down Expand Up @@ -101,7 +101,7 @@ static function ($id) use ($connection, $entityManager) {
}
);

$this->serializer = SerializerBuilderStrategy::create()
$this->serializer = SerializerBuilder::create()
->setMetadataDriverFactory(new CallbackDriverFactory(
static function (array $metadataDirs, Reader $annotationReader) use ($registry) {
$defaultFactory = new DefaultDriverFactory(new IdenticalPropertyNamingStrategy());
Expand Down
6 changes: 3 additions & 3 deletions tests/Serializer/Doctrine/ObjectConstructorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
use JMS\Serializer\Metadata\PropertyMetadata;
use JMS\Serializer\Naming\IdenticalPropertyNamingStrategy;
use JMS\Serializer\Serializer;
use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\SerializerInterface;
use JMS\Serializer\Tests\Fixtures\Doctrine\Embeddable\BlogPostSeo;
use JMS\Serializer\Tests\Fixtures\Doctrine\Entity\Author;
use JMS\Serializer\Tests\Fixtures\Doctrine\Entity\AuthorExcludedId;
use JMS\Serializer\Tests\Fixtures\Doctrine\IdentityFields\Server;
use JMS\Serializer\Tests\Fixtures\DoctrinePHPCR\Author as DoctrinePHPCRAuthor;
use JMS\Serializer\Tests\SerializerBuilderStrategy;
use JMS\Serializer\Visitor\DeserializationVisitorInterface;
use Metadata\Driver\AdvancedDriverInterface;
use Metadata\MetadataFactoryInterface;
Expand Down Expand Up @@ -408,7 +408,7 @@ static function ($id) use ($connection, $entityManager) {
);
$driver = null;
$this->driver = &$driver;
$this->serializer = SerializerBuilderStrategy::create()
$this->serializer = SerializerBuilder::create()
->setMetadataDriverFactory(new CallbackDriverFactory(
static function (array $metadataDirs, Reader $annotationReader) use ($registry, &$driver) {
$defaultFactory = new DefaultDriverFactory(new IdenticalPropertyNamingStrategy());
Expand Down Expand Up @@ -475,7 +475,7 @@ private function createXmlEntityManager(Connection $con)
*/
private function createSerializerWithDoctrineObjectConstructor()
{
return SerializerBuilderStrategy::create()
return SerializerBuilder::create()
->setObjectConstructor(
new DoctrineObjectConstructor(
$this->registry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use JMS\Serializer\EventDispatcher\ObjectEvent;
use JMS\Serializer\EventDispatcher\Subscriber\SymfonyValidatorValidatorSubscriber;
use JMS\Serializer\Exception\ValidationFailedException;
use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\Tests\Fixtures\AuthorList;
use JMS\Serializer\Tests\SerializerBuilderStrategy;
use PHPUnit\Framework\TestCase;
use stdClass;
use Symfony\Component\Validator\ConstraintViolation;
Expand Down Expand Up @@ -71,7 +71,7 @@ public function testValidationIsOnlyPerformedOnRootObject(): void
->willReturn(new ConstraintViolationList());

$subscriber = $this->subscriber;
$list = SerializerBuilderStrategy::create()
$list = SerializerBuilder::create()
->configureListeners(static function (EventDispatcher $dispatcher) use ($subscriber) {
$dispatcher->addSubscriber($subscriber);
})
Expand Down
10 changes: 5 additions & 5 deletions tests/Serializer/SerializationContextFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use JMS\Serializer\Naming\CamelCaseNamingStrategy;
use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\Tests\SerializerBuilderStrategy;
use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\Visitor\Factory\JsonDeserializationVisitorFactory;
use JMS\Serializer\Visitor\Factory\JsonSerializationVisitorFactory;
use Metadata\MetadataFactory;
Expand Down Expand Up @@ -51,7 +51,7 @@ public function testSerializeUseProvidedSerializationContext()
->method('createSerializationContext')
->will($this->returnValue($context));

$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$builder->setSerializationContextFactory($contextFactoryMock);
$serializer = $builder->build();

Expand All @@ -70,7 +70,7 @@ public function testDeserializeUseProvidedDeserializationContext()
->method('createDeserializationContext')
->will($this->returnValue($context));

$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$builder->setDeserializationContextFactory($contextFactoryMock);
$serializer = $builder->build();

Expand All @@ -90,7 +90,7 @@ public function testToArrayUseProvidedSerializationContext()
->method('createSerializationContext')
->will($this->returnValue($context));

$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$builder->setSerializationContextFactory($contextFactoryMock);
$serializer = $builder->build();

Expand All @@ -109,7 +109,7 @@ public function testFromArrayUseProvidedDeserializationContext()
->method('createDeserializationContext')
->will($this->returnValue($context));

$builder = SerializerBuilderStrategy::create();
$builder = SerializerBuilder::create();
$builder->setDeserializationContextFactory($contextFactoryMock);
$serializer = $builder->build();

Expand Down
Loading