Skip to content

Commit

Permalink
Merge pull request #471 from greg0ire/drop-deprecated-method
Browse files Browse the repository at this point in the history
Remove deprecated method
  • Loading branch information
greg0ire authored Dec 19, 2022
2 parents 455db74 + 7a95b3b commit d02c9f3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 35 deletions.
2 changes: 2 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ arrays in some ways.
you have classes inheriting from classes inside this package, you should add
parameter and return type declarations.
- Support for PHP < 7.2 has been removed
- `PhpParser::parseClass()` has been removed. Use
`PhpParser::parseUseStatements()` instead.
14 changes: 0 additions & 14 deletions lib/Doctrine/Common/Annotations/PhpParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@
*/
final class PhpParser
{
/**
* Parses a class.
*
* @deprecated use parseUseStatements instead
*
* @param ReflectionClass $class A <code>ReflectionClass</code> object.
*
* @return array<string, class-string> A list with use statements in the form (Alias => FQN).
*/
public function parseClass(ReflectionClass $class)
{
return $this->parseUseStatements($class);
}

/**
* Parse a class or function for use statements.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public function initialize(): void
*/
public function bench(): void
{
$this->parser->parseClass($this->class);
$this->parser->parseUseStatements($this->class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public function initialize(): void
*/
public function bench(): void
{
$this->parser->parseClass($this->class);
$this->parser->parseUseStatements($this->class);
}
}
38 changes: 19 additions & 19 deletions tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testParseClassWithMultipleClassesInFile(): void
self::assertEquals([
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

public function testParseClassWithMultipleImportsInUseStatement(): void
Expand All @@ -32,7 +32,7 @@ public function testParseClassWithMultipleImportsInUseStatement(): void
self::assertEquals([
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

/**
Expand All @@ -47,13 +47,13 @@ public function testParseClassWithGroupUseStatement(): void
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'supersecure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

public function testParseClassWhenNotUserDefined(): void
{
$parser = new PhpParser();
self::assertEquals([], $parser->parseClass(new ReflectionClass(stdClass::class)));
self::assertEquals([], $parser->parseUseStatements(new ReflectionClass(stdClass::class)));
}

public function testClassFileDoesNotExist(): void
Expand All @@ -64,7 +64,7 @@ public function testClassFileDoesNotExist(): void
->will($this->returnValue('/valid/class/Fake.php(35) : eval()d code'));

$parser = new PhpParser();
self::assertEquals([], $parser->parseClass($class));
self::assertEquals([], $parser->parseUseStatements($class));
}

public function testParseClassWhenClassIsNotNamespaced(): void
Expand All @@ -75,7 +75,7 @@ public function testParseClassWhenClassIsNotNamespaced(): void
self::assertEquals([
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

public function testParseClassWhenClassIsInterface(): void
Expand All @@ -85,7 +85,7 @@ public function testParseClassWhenClassIsInterface(): void

self::assertEquals([
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

public function testClassWithFullyQualifiedUseStatements(): void
Expand All @@ -97,7 +97,7 @@ public function testClassWithFullyQualifiedUseStatements(): void
'secure' => '\\' . __NAMESPACE__ . '\Fixtures\Annotation\Secure',
'route' => '\\' . __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => '\\' . __NAMESPACE__ . '\Fixtures\Annotation\Template',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

public function testNamespaceAndClassCommentedOut(): void
Expand All @@ -108,7 +108,7 @@ public function testNamespaceAndClassCommentedOut(): void
self::assertEquals([
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

public function testEqualNamespacesPerFileWithClassAsFirst(): void
Expand All @@ -119,7 +119,7 @@ public function testEqualNamespacesPerFileWithClassAsFirst(): void
self::assertEquals([
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

public function testEqualNamespacesPerFileWithClassAsLast(): void
Expand All @@ -130,7 +130,7 @@ public function testEqualNamespacesPerFileWithClassAsLast(): void
self::assertEquals([
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

public function testDifferentNamespacesPerFileWithClassAsFirst(): void
Expand All @@ -140,7 +140,7 @@ public function testDifferentNamespacesPerFileWithClassAsFirst(): void

self::assertEquals([
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

public function testDifferentNamespacesPerFileWithClassAsLast(): void
Expand All @@ -150,7 +150,7 @@ public function testDifferentNamespacesPerFileWithClassAsLast(): void

self::assertEquals([
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

public function testGlobalNamespacesPerFileWithClassAsFirst(): void
Expand All @@ -161,7 +161,7 @@ public function testGlobalNamespacesPerFileWithClassAsFirst(): void
self::assertEquals([
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

public function testGlobalNamespacesPerFileWithClassAsLast(): void
Expand All @@ -172,7 +172,7 @@ public function testGlobalNamespacesPerFileWithClassAsLast(): void
self::assertEquals([
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

public function testNamespaceWithClosureDeclaration(): void
Expand All @@ -184,7 +184,7 @@ public function testNamespaceWithClosureDeclaration(): void
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

public function testIfPointerResetsOnMultipleParsingTries(): void
Expand All @@ -196,13 +196,13 @@ public function testIfPointerResetsOnMultipleParsingTries(): void
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));

self::assertEquals([
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}

/**
Expand All @@ -217,6 +217,6 @@ public function testClassWithClosure(): void
self::assertEquals([
'annotationtargetall' => __NAMESPACE__ . '\Fixtures\AnnotationTargetAll',
'annotationtargetannotation' => __NAMESPACE__ . '\Fixtures\AnnotationTargetAnnotation',
], $parser->parseClass($class));
], $parser->parseUseStatements($class));
}
}

0 comments on commit d02c9f3

Please sign in to comment.