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

Doctrine CS 10 #455

Merged
merged 1 commit into from Oct 5, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -39,7 +39,7 @@
},
"require-dev": {
"doctrine/cache": "^1.11 || ^2.0",
"doctrine/coding-standard": "^9",
"doctrine/coding-standard": "^9 || ^10",
"phpstan/phpstan": "~1.4.10 || ^1.8.0",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"symfony/cache": "^4.4 || ^5.4 || ^6",
Expand Down
4 changes: 1 addition & 3 deletions lib/Doctrine/Common/Annotations/Annotation.php
Expand Up @@ -18,9 +18,7 @@ class Annotation
*/
public $value;

/**
* @param array<string, mixed> $data Key-value for properties to be defined in this class.
*/
/** @param array<string, mixed> $data Key-value for properties to be defined in this class. */
final public function __construct(array $data)
{
foreach ($data as $key => $value) {
Expand Down
8 changes: 2 additions & 6 deletions lib/Doctrine/Common/Annotations/AnnotationException.php
Expand Up @@ -149,19 +149,15 @@ public static function enumeratorError($attributeName, $annotationName, $context
));
}

/**
* @return AnnotationException
*/
/** @return AnnotationException */
public static function optimizerPlusSaveComments()
{
return new self(
'You have to enable opcache.save_comments=1 or zend_optimizerplus.save_comments=1.'
);
}

/**
* @return AnnotationException
*/
/** @return AnnotationException */
public static function optimizerPlusLoadComments()
{
return new self(
Expand Down
4 changes: 1 addition & 3 deletions lib/Doctrine/Common/Annotations/CachedReader.php
Expand Up @@ -38,9 +38,7 @@ final class CachedReader implements Reader
/** @var int[] */
private $loadedFilemtimes = [];

/**
* @param bool $debug
*/
/** @param bool $debug */
public function __construct(Reader $reader, Cache $cache, $debug = false)
{
$this->delegate = $reader;
Expand Down
4 changes: 1 addition & 3 deletions lib/Doctrine/Common/Annotations/DocParser.php
Expand Up @@ -1166,9 +1166,7 @@ private function identifierEndsWithClassConstant(string $identifier): bool
return $this->getClassConstantPositionInIdentifier($identifier) === strlen($identifier) - strlen('::class');
}

/**
* @return int|false
*/
/** @return int|false */
private function getClassConstantPositionInIdentifier(string $identifier)
{
return stripos($identifier, '::class');
Expand Down
4 changes: 1 addition & 3 deletions lib/Doctrine/Common/Annotations/TokenParser.php
Expand Up @@ -46,9 +46,7 @@ class TokenParser
*/
private $pointer = 0;

/**
* @param string $contents
*/
/** @param string $contents */
public function __construct($contents)
{
$this->tokens = token_get_all($contents);
Expand Down
5 changes: 5 additions & 0 deletions phpcs.xml.dist
Expand Up @@ -148,4 +148,9 @@
<rule ref="Squiz.Functions.GlobalFunction.Found">
<exclude-pattern>*/tests/Doctrine/Tests/Common/Annotations/Fixtures/functions.php</exclude-pattern>
</rule>

<!-- Single-line PHPDoc blocks will confuse PHPUnit 7.5 -->
<rule ref="SlevomatCodingStandard.Commenting.RequireOneLineDocComment.MultiLineDocComment">
<exclude-pattern>*/tests</exclude-pattern>
</rule>
</ruleset>
50 changes: 25 additions & 25 deletions tests/Doctrine/Tests/Common/Annotations/DocParserTest.php
Expand Up @@ -130,7 +130,7 @@ public function testBasicAnnotations(): void
self::assertEquals('value2', $annot->value[1]['key2']);

// Complete docblock
$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* Some nifty class.
*
Expand Down Expand Up @@ -174,7 +174,7 @@ public function testNamespacedAnnotations(): void
$parser = new DocParser();
$parser->setIgnoreNotImportedAnnotations(true);

$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* Some nifty class.
*
Expand All @@ -200,14 +200,14 @@ public function testTypicalMethodDocBlock(): void
{
$parser = $this->createTestParser();

$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* Some nifty method.
*
* @since 2.0
* @Doctrine\Tests\Common\Annotations\Name(foo="bar")
* @param string \$foo This is foo.
* @param mixed \$bar This is bar.
* @param string $foo This is foo.
* @param mixed $bar This is bar.
* @return string Foo and bar.
* @This is irrelevant
* @Marker
Expand All @@ -229,7 +229,7 @@ public function testAnnotationWithoutConstructor(): void
{
$parser = $this->createTestParser();

$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @SomeAnnotationClassNameWithoutConstructor("Some data")
*/
Expand All @@ -245,7 +245,7 @@ public function testAnnotationWithoutConstructor(): void
self::assertNotNull($annot->data);
self::assertEquals($annot->data, 'Some data');

$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @SomeAnnotationClassNameWithoutConstructor(name="Some Name", data = "Some data")
*/
Expand All @@ -261,7 +261,7 @@ public function testAnnotationWithoutConstructor(): void
self::assertEquals($annot->name, 'Some Name');
self::assertEquals($annot->data, 'Some data');

$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @SomeAnnotationClassNameWithoutConstructor(data = "Some data")
*/
Expand All @@ -274,7 +274,7 @@ public function testAnnotationWithoutConstructor(): void
self::assertEquals($annot->data, 'Some data');
self::assertNull($annot->name);

$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @SomeAnnotationClassNameWithoutConstructor(name = "Some name")
*/
Expand All @@ -287,7 +287,7 @@ public function testAnnotationWithoutConstructor(): void
self::assertEquals($annot->name, 'Some name');
self::assertNull($annot->data);

$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @SomeAnnotationClassNameWithoutConstructor("Some data")
*/
Expand All @@ -300,7 +300,7 @@ public function testAnnotationWithoutConstructor(): void
self::assertEquals($annot->data, 'Some data');
self::assertNull($annot->name);

$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @SomeAnnotationClassNameWithoutConstructor("Some data",name = "Some name")
*/
Expand All @@ -313,7 +313,7 @@ public function testAnnotationWithoutConstructor(): void
self::assertEquals($annot->name, 'Some name');
self::assertEquals($annot->data, 'Some data');

$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @SomeAnnotationWithConstructorWithoutParams(name = "Some name")
*/
Expand All @@ -326,7 +326,7 @@ public function testAnnotationWithoutConstructor(): void
self::assertEquals($annot->name, 'Some name');
self::assertEquals($annot->data, 'Some data');

$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @SomeAnnotationClassNameWithoutConstructorAndProperties()
*/
Expand Down Expand Up @@ -1058,7 +1058,7 @@ public function testSupportClassConstants(string $docblock, $expected): void
public function testWithoutConstructorWhenIsNotDefaultValue(): void
{
$parser = $this->createTestParser();
$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @SomeAnnotationClassNameWithoutConstructorAndProperties("Foo")
*/
Expand All @@ -1076,7 +1076,7 @@ public function testWithoutConstructorWhenIsNotDefaultValue(): void
public function testWithoutConstructorWhenHasNoProperties(): void
{
$parser = $this->createTestParser();
$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @SomeAnnotationClassNameWithoutConstructorAndProperties(value = "Foo")
*/
Expand All @@ -1095,7 +1095,7 @@ public function testAnnotationTargetSyntaxError(): void
{
$parser = $this->createTestParser();
$context = 'class SomeClassName';
$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError()
*/
Expand All @@ -1114,7 +1114,7 @@ public function testAnnotationWithInvalidTargetDeclarationError(): void
{
$parser = $this->createTestParser();
$context = 'class SomeClassName';
$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @AnnotationWithInvalidTargetDeclaration()
*/
Expand Down Expand Up @@ -1142,7 +1142,7 @@ public function testAnnotationWithTargetEmptyError(): void
{
$parser = $this->createTestParser();
$context = 'class SomeClassName';
$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @AnnotationWithTargetEmpty()
*/
Expand Down Expand Up @@ -1171,7 +1171,7 @@ public function testRegressionDDC575(): void
{
$parser = $this->createTestParser();

$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @Name
*
Expand All @@ -1183,7 +1183,7 @@ public function testRegressionDDC575(): void

self::assertInstanceOf(Name::class, $result[0]);

$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @Name
* @Marker
Expand Down Expand Up @@ -1359,7 +1359,7 @@ public function testSyntaxErrorWithContextDescription(): void
*/
public function testSyntaxErrorWithUnknownCharacters(): void
{
$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @test at.
*/
Expand All @@ -1384,7 +1384,7 @@ class A {
*/
public function testIgnorePHPDocThrowTag(): void
{
$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @throws \RuntimeException
*/
Expand Down Expand Up @@ -1454,7 +1454,7 @@ public function testCastNegativeFloat(): void

public function testSetValuesException(): void
{
$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @SomeAnnotationClassNameWithoutConstructor(invalidaProperty = "Some val")
*/
Expand Down Expand Up @@ -1494,7 +1494,7 @@ public function testTrailingCommaIsAllowed(): void

public function testTabPrefixIsAllowed(): void
{
$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* @Name
*/
Expand Down Expand Up @@ -1578,7 +1578,7 @@ public function testMultiByteAnnotation(): void
$this->markTestSkipped('This test requires mbstring function overloading is turned on');
}

$docblock = <<<DOCBLOCK
$docblock = <<<'DOCBLOCK'
/**
* Мультибайтовый текст ломал парсер при оверлоадинге строковых функций
* @Doctrine\Tests\Common\Annotations\Name
Expand Down