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

chore(composer): Update doctrine code standards to 12.x #1503

Merged
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"require-dev": {
"ext-pdo_sqlite": "*",
"doctrine/coding-standard": "^8.1",
"doctrine/coding-standard": "^12.0",
"doctrine/orm": "~2.1",
"doctrine/persistence": "^1.3.3|^2.0|^3.0",
"doctrine/phpcr-odm": "^1.3|^2.0",
Expand Down
17 changes: 12 additions & 5 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint"/>
</rule>

<rule ref="SlevomatCodingStandard.ControlStructures.RequireYodaComparison"/>

<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
Expand All @@ -60,6 +59,18 @@
</properties>
</rule>

<rule ref="SlevomatCodingStandard.Commenting.RequireOneLineDocComment.MultiLineDocComment">
<exclude name="SlevomatCodingStandard.Commenting.RequireOneLineDocComment.MultiLineDocComment"/>
</rule>
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectOrderOfAnnotationsInGroup">
<exclude name="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectOrderOfAnnotationsInGroup"/>
</rule>
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.InvalidFormat">
<exclude name="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.InvalidFormat"/>
</rule>
<rule ref="SlevomatCodingStandard.Commenting.AnnotationName.AnnotationNameIncorrect">
<exclude name="SlevomatCodingStandard.Commenting.AnnotationName.AnnotationNameIncorrect"/>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
Expand Down Expand Up @@ -96,10 +107,6 @@
<exclude-pattern>tests/*</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements">
<exclude-pattern>tests/*</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="annotationsGroups" type="array">
Expand Down
1 change: 1 addition & 0 deletions src/GraphNavigator/SerializationGraphNavigator.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public function initialize(VisitorInterface $visitor, Context $context): void
assert($context instanceof SerializationContext);

parent::initialize($visitor, $context);

$this->shouldSerializeNull = $context->shouldSerializeNull();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Handler/FormErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private function getErrorMessage(FormError $error): ?string

private function convertFormToArray(SerializationVisitorInterface $visitor, FormInterface $data): \ArrayObject
{
/** @var \ArrayObject{errors?: string[], children?: array<string, \ArrayObject>} $form */
/** @var \ArrayObject{errors?:array<string>,children?:array<string,\ArrayObject>} $form */
$form = new \ArrayObject();
$errors = [];
foreach ($data->getErrors() as $error) {
Expand Down
2 changes: 2 additions & 0 deletions src/Handler/LazyHandlerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function __construct($container, array $handlers = [])
}

parent::__construct($handlers);

$this->container = $container;
}

Expand All @@ -40,6 +41,7 @@ public function __construct($container, array $handlers = [])
public function registerHandler(int $direction, string $typeName, string $format, $handler): void
{
parent::registerHandler($direction, $typeName, $format, $handler);

unset($this->initializedHandlers[$direction][$typeName][$format]);
}

Expand Down
1 change: 1 addition & 0 deletions src/JsonDeserializationStrictVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function __construct(
public function setNavigator(GraphNavigatorInterface $navigator): void
{
parent::setNavigator($navigator);

$this->wrappedDeserializationVisitor->setNavigator($navigator);
}

Expand Down
1 change: 1 addition & 0 deletions src/Metadata/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public function setAccessorOrder(string $order, array $customOrder = []): void
public function addPropertyMetadata(BasePropertyMetadata $metadata): void
{
parent::addPropertyMetadata($metadata);

$this->sortProperties();
if ($metadata instanceof PropertyMetadata && $metadata->excludeIf) {
$this->usingExpression = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ final class DocBlockTypeResolver
{
/** resolve single use statements */
private const SINGLE_USE_STATEMENTS_REGEX = '/^[^\S\r\n]*use[\s]*([^;\n]*)[\s]*;$/m';

/** resolve group use statements */
private const GROUP_USE_STATEMENTS_REGEX = '/^[^\S\r\n]*use[[\s]*([^;\n]*)[\s]*{([a-zA-Z0-9\s\n\r,]*)};$/m';
private const GLOBAL_NAMESPACE_PREFIX = '\\';
Expand Down
1 change: 1 addition & 0 deletions src/Metadata/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class XmlDriver extends AbstractFileDriver
public function __construct(FileLocatorInterface $locator, PropertyNamingStrategyInterface $namingStrategy, ?ParserInterface $typeParser = null, ?CompilableExpressionEvaluatorInterface $expressionEvaluator = null)
{
parent::__construct($locator);

$this->typeParser = $typeParser ?? new Parser();
$this->namingStrategy = $namingStrategy;
$this->expressionEvaluator = $expressionEvaluator;
Expand Down
1 change: 1 addition & 0 deletions src/Twig/SerializerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class SerializerExtension extends SerializerBaseExtension
public function __construct(SerializerInterface $serializer, string $serializationFunctionsPrefix = '')
{
$this->serializer = $serializer;

parent::__construct($serializationFunctionsPrefix);
}

Expand Down
1 change: 1 addition & 0 deletions tests/Benchmark/Memory/JsonMultipleRunBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class JsonMultipleRunBench extends JsonSingleRunBench
public function __construct()
{
$this->iterations = 10000;

parent::__construct();
}
}
1 change: 1 addition & 0 deletions tests/Benchmark/Memory/JsonSingleRunBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function __construct()
{
$this->amountOfComments = 1;
$this->amountOfPosts = 1;

parent::__construct();
}

Expand Down
1 change: 1 addition & 0 deletions tests/Benchmark/Memory/XmlMutlipleRunBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class XmlMutlipleRunBench extends XmlSingleRunBench
public function __construct()
{
$this->iterations = 10000;

parent::__construct();
}

Expand Down
1 change: 1 addition & 0 deletions tests/Benchmark/Memory/XmlSingleRunBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function __construct()
{
$this->amountOfComments = 1;
$this->amountOfPosts = 1;

parent::__construct();
}

Expand Down
1 change: 0 additions & 1 deletion tests/Fixtures/AuthorDeprecatedReadOnly.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace JMS\Serializer\Tests\Fixtures;

use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\ReadOnly;
use JMS\Serializer\Annotation\SerializedName;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\XmlRoot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ExtendedUser extends User
public function __construct($id, $name, $description, $extendAttribute)
{
parent::__construct($id, $name, $description);

$this->extendAttribute = $extendAttribute;
}
}
1 change: 1 addition & 0 deletions tests/Fixtures/Discriminator/Serialization/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class User extends Entity
public function __construct(int $id, string $name, string $description)
{
parent::__construct($id);

$this->name = $name;
$this->description = $description;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace JMS\Serializer\Tests\Fixtures\DocBlockType\Collection;

use JMS\Serializer\Tests\Fixtures\DocBlockType\Collection\Details\ProductColor;

class CollectionOfInterfacesFromGlobalNamespace
{
/**
* phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName
* @var \JMS\Serializer\Tests\Fixtures\DocBlockType\Collection\Details\ProductColor[]
*
* @var ProductColor[]
*/
public array $productColors;
}
3 changes: 2 additions & 1 deletion tests/Fixtures/Doctrine/Entity/Author.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
class Author
{
/**
* @ORM\Id @ORM\Column(type="integer")
* @ORM\Id
* @ORM\Column(type="integer")
*
* @Groups({"id_group"})
*/
Expand Down
3 changes: 2 additions & 1 deletion tests/Fixtures/Doctrine/Entity/AuthorExcludedId.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
class AuthorExcludedId
{
/**
* @ORM\Id @ORM\Column(type="integer")
* @ORM\Id
* @ORM\Column(type="integer")
*
* @Exclude
*/
Expand Down
4 changes: 3 additions & 1 deletion tests/Fixtures/Doctrine/Entity/BlogPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
class BlogPost
{
/**
* @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;

Expand Down
3 changes: 2 additions & 1 deletion tests/Fixtures/Doctrine/Entity/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
class Comment
{
/**
* @ORM\Id @ORM\Column(type="integer")
* @ORM\Id
* @ORM\Column(type="integer")
*/
protected $id;

Expand Down
6 changes: 5 additions & 1 deletion tests/Fixtures/Doctrine/SingleTableInheritance/Clazz.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
*/
class Clazz extends AbstractModel
{
/** @ORM\Id @ORM\GeneratedValue(strategy = "AUTO") @ORM\Column(type = "integer") */
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;

/** @ORM\ManyToOne(targetEntity = "JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Teacher") */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
*/
abstract class Organization
{
/** @ORM\Id @ORM\GeneratedValue(strategy = "AUTO") @ORM\Column(type = "integer") */
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
}
6 changes: 5 additions & 1 deletion tests/Fixtures/Doctrine/SingleTableInheritance/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
*/
abstract class Person extends AbstractModel
{
/** @ORM\Id @ORM\GeneratedValue(strategy = "AUTO") @ORM\Column(type = "integer") */
/**
* @ORM\Id
* @ORM\Column(type = "integer")
* @ORM\GeneratedValue(strategy = "AUTO")
*/
private $id;
}
5 changes: 4 additions & 1 deletion tests/Fixtures/GetSetObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
#[AccessType(type: 'public_method')]
class GetSetObject
{
/** @AccessType("property") @Type("integer") */
/**
* @AccessType("property")
* @AccessType("property")
@Type("integer") */
#[AccessType(type: 'property')]
#[Type(name: 'integer')]
private $id = 1;
Expand Down
10 changes: 8 additions & 2 deletions tests/Fixtures/ObjectWithIntListAndIntMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@

class ObjectWithIntListAndIntMap
{
/** @Serializer\Type("array<integer>") @Serializer\XmlList */
/**
* @Serializer\Type("array<integer>")
* @Serializer\Type("array<integer>")
@Serializer\XmlList */
#[Serializer\Type(name: 'array<integer>')]
#[Serializer\XmlList]
private $list;

/** @Serializer\Type("array<integer,integer>") @Serializer\XmlMap */
/**
* @Serializer\Type("array<integer,integer>")
* @Serializer\Type("array<integer,integer>")
@Serializer\XmlMap */
#[Serializer\Type(name: 'array<integer,integer>')]
#[Serializer\XmlMap]
private $map;
Expand Down
1 change: 0 additions & 1 deletion tests/Fixtures/ObjectWithNamespacesAndList.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class ObjectWithNamespacesAndList
#[Type(name: 'array<string>')]
#[SerializedName(name: 'phones')]
#[XmlList(entry: 'phone', inline: false)]

public $phonesAlternativeD;
/**
* @Type("array<string,string>")
Expand Down
1 change: 1 addition & 0 deletions tests/Fixtures/SimpleInternalObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SimpleInternalObject extends \Exception
public function __construct($foo, $bar)
{
parent::__construct($foo);

$this->bar = $bar;
}
}
Loading