chore: 添加缺失的静态资源文件
添加多个前端界面所需的图片、字体、音频等静态资源文件,包括: - 管理员后台的图标、背景图、组件图片 - 移动端页面的商品图片、用户中心图片、活动图标 - 第三方库的示例图片和字体文件 - 浏览器兼容性配置文件 - 图标字体文件(eot、ttf、woff、woff2格式) 这些资源是前端界面正常显示所必需的,之前可能因版本控制忽略或遗漏而缺失。
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Performance\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\PsrCachedReader;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Controller;
|
||||
use ReflectionMethod;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
|
||||
/**
|
||||
* @BeforeMethods({"initialize"})
|
||||
*/
|
||||
final class CachedReadPerformanceWithInMemoryBench
|
||||
{
|
||||
/** @var PsrCachedReader */
|
||||
private $reader;
|
||||
|
||||
/** @var ReflectionMethod */
|
||||
private $method;
|
||||
|
||||
public function initialize(): void
|
||||
{
|
||||
$this->reader = new PsrCachedReader(new AnnotationReader(), new ArrayAdapter());
|
||||
$this->method = new ReflectionMethod(Controller::class, 'helloAction');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Revs(500)
|
||||
* @Iterations(5)
|
||||
*/
|
||||
public function bench(): void
|
||||
{
|
||||
$this->reader->getMethodAnnotations($this->method);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Performance\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\DocLexer;
|
||||
|
||||
/**
|
||||
* @BeforeMethods({"initializeMethod", "initialize"})
|
||||
*/
|
||||
final class DocLexerPerformanceBench
|
||||
{
|
||||
use MethodInitializer;
|
||||
|
||||
/** @var DocLexer */
|
||||
private $lexer;
|
||||
|
||||
public function initialize(): void
|
||||
{
|
||||
$this->lexer = new DocLexer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Revs(500)
|
||||
* @Iterations(5)
|
||||
*/
|
||||
public function benchMethod(): void
|
||||
{
|
||||
$this->lexer->setInput($this->methodDocBlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Revs(500)
|
||||
* @Iterations(5)
|
||||
*/
|
||||
public function benchClass(): void
|
||||
{
|
||||
$this->lexer->setInput($this->classDocBlock);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Performance\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\DocParser;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
|
||||
|
||||
use function array_fill_keys;
|
||||
|
||||
/**
|
||||
* @BeforeMethods({"initializeMethod", "initialize"})
|
||||
*/
|
||||
final class DocParserPerformanceBench
|
||||
{
|
||||
use MethodInitializer;
|
||||
|
||||
private const IMPORTS = [
|
||||
'ignorephpdoc' => 'Annotations\Annotation\IgnorePhpDoc',
|
||||
'ignoreannotation' => 'Annotations\Annotation\IgnoreAnnotation',
|
||||
'route' => Route::class,
|
||||
'template' => Template::class,
|
||||
'__NAMESPACE__' => 'Doctrine\Tests\Common\Annotations\Fixtures',
|
||||
];
|
||||
|
||||
private const IGNORED = [
|
||||
'access', 'author', 'copyright', 'deprecated', 'example', 'ignore',
|
||||
'internal', 'link', 'see', 'since', 'tutorial', 'version', 'package',
|
||||
'subpackage', 'name', 'global', 'param', 'return', 'staticvar',
|
||||
'static', 'var', 'throws', 'inheritdoc',
|
||||
];
|
||||
|
||||
/** @var DocParser */
|
||||
private $parser;
|
||||
|
||||
public function initialize(): void
|
||||
{
|
||||
$this->parser = new DocParser();
|
||||
|
||||
$this->parser->setImports(self::IMPORTS);
|
||||
$this->parser->setIgnoredAnnotationNames(array_fill_keys(self::IGNORED, true));
|
||||
$this->parser->setIgnoreNotImportedAnnotations(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Revs(200)
|
||||
* @Iterations(5)
|
||||
*/
|
||||
public function benchMethodParsing(): void
|
||||
{
|
||||
$this->parser->parse($this->methodDocBlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Revs(200)
|
||||
* @Iterations(5)
|
||||
*/
|
||||
public function benchClassParsing(): void
|
||||
{
|
||||
$this->parser->parse($this->classDocBlock);
|
||||
}
|
||||
}
|
||||
27
vendor/doctrine/annotations/tests/Doctrine/Performance/Common/Annotations/MethodInitializer.php
vendored
Normal file
27
vendor/doctrine/annotations/tests/Doctrine/Performance/Common/Annotations/MethodInitializer.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Performance\Common\Annotations;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Controller;
|
||||
use ReflectionMethod;
|
||||
|
||||
trait MethodInitializer
|
||||
{
|
||||
/** @var ReflectionMethod */
|
||||
private $method;
|
||||
|
||||
/** @var string */
|
||||
private $methodDocBlock;
|
||||
|
||||
/** @var string */
|
||||
private $classDocBlock;
|
||||
|
||||
public function initializeMethod(): void
|
||||
{
|
||||
$this->method = new ReflectionMethod(Controller::class, 'helloAction');
|
||||
$this->methodDocBlock = $this->method->getDocComment();
|
||||
$this->classDocBlock = $this->method->getDeclaringClass()->getDocComment();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Performance\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\PhpParser;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\NamespacedSingleClassLOC1000;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* @BeforeMethods({"initialize"})
|
||||
*/
|
||||
final class PhpParserPerformanceWithShortCutBench
|
||||
{
|
||||
/** @var ReflectionClass */
|
||||
private $class;
|
||||
|
||||
/** @var PhpParser */
|
||||
private $parser;
|
||||
|
||||
public function initialize(): void
|
||||
{
|
||||
$this->class = new ReflectionClass(NamespacedSingleClassLOC1000::class);
|
||||
$this->parser = new PhpParser();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Revs(500)
|
||||
* @Iterations(5)
|
||||
*/
|
||||
public function bench(): void
|
||||
{
|
||||
$this->parser->parseClass($this->class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Performance\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\PhpParser;
|
||||
use ReflectionClass;
|
||||
use SingleClassLOC1000;
|
||||
|
||||
/**
|
||||
* @BeforeMethods({"initialize"})
|
||||
*/
|
||||
final class PhpParserPerformanceWithoutShortCutBench
|
||||
{
|
||||
/** @var ReflectionClass */
|
||||
private $class;
|
||||
|
||||
/** @var PhpParser */
|
||||
private $parser;
|
||||
|
||||
public function initialize(): void
|
||||
{
|
||||
$this->class = new ReflectionClass(SingleClassLOC1000::class);
|
||||
$this->parser = new PhpParser();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Revs(500)
|
||||
* @Iterations(5)
|
||||
*/
|
||||
public function bench(): void
|
||||
{
|
||||
$this->parser->parseClass($this->class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Performance\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
|
||||
/**
|
||||
* @BeforeMethods({"initializeMethod", "initialize"})
|
||||
*/
|
||||
final class ReadPerformanceBench
|
||||
{
|
||||
use MethodInitializer;
|
||||
|
||||
/** @var AnnotationReader */
|
||||
private $reader;
|
||||
|
||||
public function initialize(): void
|
||||
{
|
||||
$this->reader = new AnnotationReader();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Revs(500)
|
||||
* @Iterations(5)
|
||||
*/
|
||||
public function bench(): void
|
||||
{
|
||||
$this->reader->getMethodAnnotations($this->method);
|
||||
}
|
||||
}
|
||||
8
vendor/doctrine/annotations/tests/Doctrine/Performance/Common/bootstrap.php
vendored
Normal file
8
vendor/doctrine/annotations/tests/Doctrine/Performance/Common/bootstrap.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../../../../vendor/autoload.php';
|
||||
require_once __DIR__ . '/../../Tests/Common/Annotations/Fixtures/Annotation/Route.php';
|
||||
require_once __DIR__ . '/../../Tests/Common/Annotations/Fixtures/Annotation/Secure.php';
|
||||
require_once __DIR__ . '/../../Tests/Common/Annotations/Fixtures/Annotation/Template.php';
|
||||
805
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php
vendored
Normal file
805
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php
vendored
Normal file
@@ -0,0 +1,805 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\Annotation;
|
||||
use Doctrine\Common\Annotations\AnnotationException;
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use ReflectionProperty;
|
||||
use Test;
|
||||
use TopLevelAnnotation;
|
||||
|
||||
use function class_exists;
|
||||
use function reset;
|
||||
|
||||
require_once __DIR__ . '/TopLevelAnnotation.php';
|
||||
|
||||
abstract class AbstractReaderTest extends TestCase
|
||||
{
|
||||
/** @var bool */
|
||||
private $expectException = true;
|
||||
|
||||
final protected function ignoreIssues(): void
|
||||
{
|
||||
$this->expectException = false;
|
||||
}
|
||||
|
||||
public function getReflectionClass(): ReflectionClass
|
||||
{
|
||||
return new ReflectionClass(DummyClass::class);
|
||||
}
|
||||
|
||||
public function testAnnotations(): void
|
||||
{
|
||||
$class = $this->getReflectionClass();
|
||||
$reader = $this->getReader();
|
||||
|
||||
self::assertCount(1, $reader->getClassAnnotations($class));
|
||||
self::assertInstanceOf(
|
||||
$annotName = DummyAnnotation::class,
|
||||
$annot = $reader->getClassAnnotation($class, $annotName)
|
||||
);
|
||||
self::assertEquals('hello', $annot->dummyValue);
|
||||
|
||||
$field1Prop = $class->getProperty('field1');
|
||||
$propAnnots = $reader->getPropertyAnnotations($field1Prop);
|
||||
self::assertCount(1, $propAnnots);
|
||||
self::assertInstanceOf($annotName, $annot = $reader->getPropertyAnnotation($field1Prop, $annotName));
|
||||
self::assertEquals('fieldHello', $annot->dummyValue);
|
||||
|
||||
$getField1Method = $class->getMethod('getField1');
|
||||
$methodAnnots = $reader->getMethodAnnotations($getField1Method);
|
||||
self::assertCount(1, $methodAnnots);
|
||||
self::assertInstanceOf($annotName, $annot = $reader->getMethodAnnotation($getField1Method, $annotName));
|
||||
self::assertEquals([1, 2, 'three'], $annot->value);
|
||||
|
||||
$field2Prop = $class->getProperty('field2');
|
||||
$propAnnots = $reader->getPropertyAnnotations($field2Prop);
|
||||
self::assertCount(1, $propAnnots);
|
||||
self::assertInstanceOf(
|
||||
$annotName = DummyJoinTable::class,
|
||||
$joinTableAnnot = $reader->getPropertyAnnotation($field2Prop, $annotName)
|
||||
);
|
||||
self::assertCount(1, $joinTableAnnot->joinColumns);
|
||||
self::assertCount(1, $joinTableAnnot->inverseJoinColumns);
|
||||
self::assertInstanceOf(DummyJoinColumn::class, $joinTableAnnot->joinColumns[0]);
|
||||
self::assertInstanceOf(DummyJoinColumn::class, $joinTableAnnot->inverseJoinColumns[0]);
|
||||
self::assertEquals('col1', $joinTableAnnot->joinColumns[0]->name);
|
||||
self::assertEquals('col2', $joinTableAnnot->joinColumns[0]->referencedColumnName);
|
||||
self::assertEquals('col3', $joinTableAnnot->inverseJoinColumns[0]->name);
|
||||
self::assertEquals('col4', $joinTableAnnot->inverseJoinColumns[0]->referencedColumnName);
|
||||
|
||||
$dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField1'), DummyAnnotation::class);
|
||||
self::assertEquals('', $dummyAnnot->dummyValue);
|
||||
self::assertEquals([1, 2, 'three'], $dummyAnnot->value);
|
||||
|
||||
$dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField3'), DummyAnnotation::class);
|
||||
self::assertEquals('\d{4}-[01]\d-[0-3]\d [0-2]\d:[0-5]\d:[0-5]\d', $dummyAnnot->value);
|
||||
|
||||
$dummyAnnot = $reader->getPropertyAnnotation($class->getProperty('field1'), DummyAnnotation::class);
|
||||
self::assertEquals('fieldHello', $dummyAnnot->dummyValue);
|
||||
|
||||
$classAnnot = $reader->getClassAnnotation($class, DummyAnnotation::class);
|
||||
self::assertEquals('hello', $classAnnot->dummyValue);
|
||||
}
|
||||
|
||||
public function testAnnotationsWithValidTargets(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$class = new ReflectionClass(Fixtures\ClassWithValidAnnotationTarget::class);
|
||||
|
||||
self::assertCount(1, $reader->getClassAnnotations($class));
|
||||
self::assertCount(1, $reader->getPropertyAnnotations($class->getProperty('foo')));
|
||||
self::assertCount(1, $reader->getMethodAnnotations($class->getMethod('someFunction')));
|
||||
self::assertCount(1, $reader->getPropertyAnnotations($class->getProperty('nested')));
|
||||
}
|
||||
|
||||
public function testAnnotationsWithVarType(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$class = new ReflectionClass(Fixtures\ClassWithAnnotationWithVarType::class);
|
||||
|
||||
self::assertCount(1, $fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo')));
|
||||
self::assertCount(1, $barAnnot = $reader->getMethodAnnotations($class->getMethod('bar')));
|
||||
|
||||
self::assertIsString($fooAnnot[0]->string);
|
||||
self::assertInstanceOf(Fixtures\AnnotationTargetAll::class, $barAnnot[0]->annotation);
|
||||
}
|
||||
|
||||
public function testAtInDescription(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$class = new ReflectionClass(Fixtures\ClassWithAtInDescriptionAndAnnotation::class);
|
||||
|
||||
self::assertCount(1, $fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo')));
|
||||
self::assertCount(1, $barAnnot = $reader->getPropertyAnnotations($class->getProperty('bar')));
|
||||
|
||||
self::assertInstanceOf(Fixtures\AnnotationTargetPropertyMethod::class, $fooAnnot[0]);
|
||||
self::assertInstanceOf(Fixtures\AnnotationTargetPropertyMethod::class, $barAnnot[0]);
|
||||
}
|
||||
|
||||
public function testClassWithWithDanglingComma(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$annots = $reader->getClassAnnotations(new ReflectionClass(DummyClassWithDanglingComma::class));
|
||||
|
||||
self::assertCount(1, $annots);
|
||||
}
|
||||
|
||||
public function testClassWithInvalidAnnotationTargetAtClassDocBlock(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
if ($this->expectException) {
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
'[Semantical Error] Annotation @AnnotationTargetPropertyMethod is not allowed to be declared on class' .
|
||||
' Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass.' .
|
||||
' You may only use this annotation on these code elements: METHOD, PROPERTY'
|
||||
);
|
||||
}
|
||||
|
||||
$reader->getClassAnnotations(new ReflectionClass(Fixtures\ClassWithInvalidAnnotationTargetAtClass::class));
|
||||
}
|
||||
|
||||
public function testClassWithWithInclude(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$annots = $reader->getClassAnnotations(new ReflectionClass(Fixtures\ClassWithRequire::class));
|
||||
self::assertCount(1, $annots);
|
||||
}
|
||||
|
||||
public function testClassWithInvalidAnnotationTargetAtPropertyDocBlock(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
if ($this->expectException) {
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
'[Semantical Error] Annotation @AnnotationTargetClass is not allowed to be declared on property' .
|
||||
' Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty::$foo. ' .
|
||||
'You may only use this annotation on these code elements: CLASS'
|
||||
);
|
||||
}
|
||||
|
||||
$reader->getPropertyAnnotations(new ReflectionProperty(
|
||||
Fixtures\ClassWithInvalidAnnotationTargetAtProperty::class,
|
||||
'foo'
|
||||
));
|
||||
}
|
||||
|
||||
public function testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
if ($this->expectException) {
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
'[Semantical Error] Annotation @AnnotationTargetAnnotation is not allowed to be declared on property' .
|
||||
' Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty::$bar.' .
|
||||
' You may only use this annotation on these code elements: ANNOTATION'
|
||||
);
|
||||
}
|
||||
|
||||
$reader->getPropertyAnnotations(new ReflectionProperty(
|
||||
Fixtures\ClassWithInvalidAnnotationTargetAtProperty::class,
|
||||
'bar'
|
||||
));
|
||||
}
|
||||
|
||||
public function testClassWithInvalidAnnotationTargetAtMethodDocBlock(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
if ($this->expectException) {
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
'[Semantical Error] Annotation @AnnotationTargetClass is not allowed to be declared on method' .
|
||||
' Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtMethod' .
|
||||
'::functionName(). You may only use this annotation on these code elements: CLASS'
|
||||
);
|
||||
}
|
||||
|
||||
$reader->getMethodAnnotations(new ReflectionMethod(
|
||||
Fixtures\ClassWithInvalidAnnotationTargetAtMethod::class,
|
||||
'functionName'
|
||||
));
|
||||
}
|
||||
|
||||
public function testClassWithAnnotationWithTargetSyntaxErrorAtClassDocBlock(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
"Expected namespace separator or identifier, got ')' at position 24" .
|
||||
' in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError.'
|
||||
);
|
||||
$reader->getClassAnnotations(new ReflectionClass(
|
||||
Fixtures\ClassWithAnnotationWithTargetSyntaxError::class
|
||||
));
|
||||
}
|
||||
|
||||
public function testClassWithAnnotationWithTargetSyntaxErrorAtPropertyDocBlock(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
"Expected namespace separator or identifier, got ')' at position 24" .
|
||||
' in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError.'
|
||||
);
|
||||
$reader->getPropertyAnnotations(new ReflectionProperty(
|
||||
Fixtures\ClassWithAnnotationWithTargetSyntaxError::class,
|
||||
'foo'
|
||||
));
|
||||
}
|
||||
|
||||
public function testClassWithAnnotationWithTargetSyntaxErrorAtMethodDocBlock(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
"Expected namespace separator or identifier, got ')' at position 24" .
|
||||
' in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError.'
|
||||
);
|
||||
$reader->getMethodAnnotations(new ReflectionMethod(
|
||||
Fixtures\ClassWithAnnotationWithTargetSyntaxError::class,
|
||||
'bar'
|
||||
));
|
||||
}
|
||||
|
||||
public function testClassWithPropertyInvalidVarTypeError(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$class = new ReflectionClass(Fixtures\ClassWithAnnotationWithVarType::class);
|
||||
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
'[Type Error] Attribute "string" of @AnnotationWithVarType declared on property' .
|
||||
' Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType::$invalidProperty' .
|
||||
' expects a(n) string, but got integer.'
|
||||
);
|
||||
$reader->getPropertyAnnotations($class->getProperty('invalidProperty'));
|
||||
}
|
||||
|
||||
public function testClassWithMethodInvalidVarTypeError(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$class = new ReflectionClass(Fixtures\ClassWithAnnotationWithVarType::class);
|
||||
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
'[Type Error] Attribute "annotation" of @AnnotationWithVarType declared' .
|
||||
' on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType::invalidMethod()' .
|
||||
' expects a(n) \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,' .
|
||||
' but got an instance of Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation.'
|
||||
);
|
||||
$reader->getMethodAnnotations($class->getMethod('invalidMethod'));
|
||||
}
|
||||
|
||||
public function testClassSyntaxErrorContext(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
"Expected namespace separator or identifier, got ')' at position 18" .
|
||||
' in class Doctrine\Tests\Common\Annotations\DummyClassSyntaxError.'
|
||||
);
|
||||
$reader->getClassAnnotations(new ReflectionClass(DummyClassSyntaxError::class));
|
||||
}
|
||||
|
||||
public function testMethodSyntaxErrorContext(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
"Expected namespace separator or identifier, got ')' at position 18" .
|
||||
' in method Doctrine\Tests\Common\Annotations\DummyClassMethodSyntaxError::foo().'
|
||||
);
|
||||
$reader->getMethodAnnotations(new ReflectionMethod(DummyClassMethodSyntaxError::class, 'foo'));
|
||||
}
|
||||
|
||||
public function testPropertySyntaxErrorContext(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
"Expected namespace separator or identifier, got ')'" .
|
||||
' at position 36 in property Doctrine\Tests\Common\Annotations\DummyClassPropertySyntaxError::$foo.'
|
||||
);
|
||||
$reader->getPropertyAnnotations(new ReflectionProperty(DummyClassPropertySyntaxError::class, 'foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group regression
|
||||
*/
|
||||
public function testMultipleAnnotationsOnSameLine(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$annots = $reader->getPropertyAnnotations(new ReflectionProperty(DummyClass2::class, 'id'));
|
||||
self::assertCount(3, $annots);
|
||||
}
|
||||
|
||||
public function testNonAnnotationProblem(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
|
||||
self::assertNotNull($annot = $reader->getPropertyAnnotation(
|
||||
new ReflectionProperty(DummyClassNonAnnotationProblem::class, 'foo'),
|
||||
$name = DummyAnnotation::class
|
||||
));
|
||||
self::assertInstanceOf($name, $annot);
|
||||
}
|
||||
|
||||
public function testIncludeIgnoreAnnotation(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
|
||||
$reader->getPropertyAnnotations(new ReflectionProperty(Fixtures\ClassWithIgnoreAnnotation::class, 'foo'));
|
||||
self::assertFalse(class_exists(Fixtures\IgnoreAnnotationClass::class, false));
|
||||
}
|
||||
|
||||
public function testImportWithConcreteAnnotation(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$property = new ReflectionProperty(TestImportWithConcreteAnnotation::class, 'field');
|
||||
$annotations = $reader->getPropertyAnnotations($property);
|
||||
self::assertCount(1, $annotations);
|
||||
self::assertNotNull($reader->getPropertyAnnotation($property, DummyAnnotation::class));
|
||||
}
|
||||
|
||||
public function testImportWithInheritance(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
|
||||
$class = new TestParentClass();
|
||||
$ref = new ReflectionClass($class);
|
||||
|
||||
$childAnnotations = $reader->getPropertyAnnotations($ref->getProperty('child'));
|
||||
self::assertCount(1, $childAnnotations);
|
||||
self::assertInstanceOf(Foo\Name::class, reset($childAnnotations));
|
||||
|
||||
$parentAnnotations = $reader->getPropertyAnnotations($ref->getProperty('parent'));
|
||||
self::assertCount(1, $parentAnnotations);
|
||||
self::assertInstanceOf(Bar\Name::class, reset($parentAnnotations));
|
||||
}
|
||||
|
||||
public function testImportDetectsNotImportedAnnotation(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
if ($this->expectException) {
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
'The annotation "@NameFoo" in property' .
|
||||
' Doctrine\Tests\Common\Annotations\TestAnnotationNotImportedClass::$field was never imported.'
|
||||
);
|
||||
}
|
||||
|
||||
$reader->getPropertyAnnotations(new ReflectionProperty(TestAnnotationNotImportedClass::class, 'field'));
|
||||
}
|
||||
|
||||
public function testImportDetectsNonExistentAnnotation(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
if ($this->expectException) {
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
'The annotation "@Foo\Bar\Name" in property' .
|
||||
' Doctrine\Tests\Common\Annotations\TestNonExistentAnnotationClass::$field was never imported.'
|
||||
);
|
||||
}
|
||||
|
||||
$reader->getPropertyAnnotations(new ReflectionProperty(TestNonExistentAnnotationClass::class, 'field'));
|
||||
}
|
||||
|
||||
public function testTopLevelAnnotation(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$annotations = $reader->getPropertyAnnotations(new ReflectionProperty(
|
||||
TestTopLevelAnnotationClass::class,
|
||||
'field'
|
||||
));
|
||||
|
||||
self::assertCount(1, $annotations);
|
||||
self::assertInstanceOf(TopLevelAnnotation::class, reset($annotations));
|
||||
}
|
||||
|
||||
public function testIgnoresAnnotationsNotPrefixedWithWhitespace(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
|
||||
$annotation = $reader->getClassAnnotation(
|
||||
new ReflectionClass(new TestIgnoresNonAnnotationsClass()),
|
||||
NameBar::class
|
||||
);
|
||||
self::assertInstanceOf(NameBar::class, $annotation);
|
||||
}
|
||||
|
||||
private static $testResetsPhpParserAfterUseRun = false;
|
||||
|
||||
/**
|
||||
* When getUseStatements isn't available on ReflectionClass the PhpParser has to use token_get_all(). If that
|
||||
* happens various PHP compiler globals get set, and these can have seriously bad effects on the next file to be
|
||||
* parsed.
|
||||
* Notably the doc_comment compiler global can end up containing a docblock comment. The next file to be parsed
|
||||
* on an include() will have this docblock comment attached to the first thing in the file that the compiler
|
||||
* considers to own comments. If this is a class then any later calls to getDocComment() for that class will have
|
||||
* undesirable effects. *sigh*
|
||||
*/
|
||||
public function testResetsPhpParserAfterUse(): void
|
||||
{
|
||||
// If someone has already included our main test fixture this test is invalid. It's important that our require
|
||||
// causes this file to be parsed and compiled at a certain point.
|
||||
self::assertFalse(! self::$testResetsPhpParserAfterUseRun && class_exists(
|
||||
Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment::class
|
||||
), 'Test invalid if class has already been compiled');
|
||||
self::$testResetsPhpParserAfterUseRun = true;
|
||||
|
||||
$reader = $this->getReader();
|
||||
|
||||
// First make sure the annotation cache knows about the annotations we want to use.
|
||||
// If we don't do this then loading of annotations into the cache will cause the parser to get out of the bad
|
||||
// state we want to test.
|
||||
$class = new ReflectionClass(Fixtures\ClassWithValidAnnotationTarget::class);
|
||||
$reader->getClassAnnotations($class);
|
||||
|
||||
// Now import an incredibly dull class which makes use of the same
|
||||
// class level annotation that the previous class does.
|
||||
$class = new ReflectionClass(Fixtures\ClassWithClassAnnotationOnly::class);
|
||||
$annotations = $reader->getClassAnnotations($class);
|
||||
|
||||
// This include needs to be here since we need the PHP compiler to run over it as the next thing the PHP
|
||||
// parser sees since PhpParser called token_get_all() on the intro to ClassWithClassAnnotationOnly.
|
||||
// Our test class cannot be in a namespace (some versions of PHP reset the doc_comment compiler global when
|
||||
// you hit a namespace declaration), so cannot be autoloaded.
|
||||
require_once __DIR__ . '/Fixtures/ClassNoNamespaceNoComment.php';
|
||||
|
||||
// So, hopefully, if all has gone OK, our class with class annotations should actually have them.
|
||||
// If this fails then something is quite badly wrong elsewhere.
|
||||
// Note that if this happens before the require it can cause other PHP files to be included, resetting the
|
||||
// compiler global state, and invalidating this test case.
|
||||
self::assertNotEmpty($annotations);
|
||||
|
||||
$annotations = $reader->getClassAnnotations(new ReflectionClass(
|
||||
new Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment()
|
||||
));
|
||||
// And if our workaround for this bug is OK, our class with no doc
|
||||
// comment should not have any class annotations.
|
||||
self::assertEmpty($annotations);
|
||||
}
|
||||
|
||||
public function testErrorWhenInvalidAnnotationIsUsed(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(Fixtures\InvalidAnnotationUsageClass::class);
|
||||
if ($this->expectException) {
|
||||
$this->expectException(AnnotationException::class);
|
||||
$this->expectExceptionMessage(
|
||||
'The class "Doctrine\Tests\Common\Annotations\Fixtures\NoAnnotation" is not annotated with @Annotation.
|
||||
Are you sure this class can be used as annotation?
|
||||
If so, then you need to add @Annotation to the _class_ doc comment of' .
|
||||
' "Doctrine\Tests\Common\Annotations\Fixtures\NoAnnotation".
|
||||
If it is indeed no annotation, then you need to add @IgnoreAnnotation("NoAnnotation") to the _class_ doc comment' .
|
||||
' of class Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageClass.'
|
||||
);
|
||||
}
|
||||
|
||||
$reader->getClassAnnotations($ref);
|
||||
}
|
||||
|
||||
public function testInvalidAnnotationUsageButIgnoredClass(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(Fixtures\InvalidAnnotationUsageButIgnoredClass::class);
|
||||
$annots = $reader->getClassAnnotations($ref);
|
||||
|
||||
self::assertCount(2, $annots);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1660
|
||||
* @group regression
|
||||
*/
|
||||
public function testInvalidAnnotationButIgnored(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$class = new ReflectionClass(Fixtures\ClassDDC1660::class);
|
||||
|
||||
self::assertTrue(class_exists(Fixtures\Annotation\Version::class));
|
||||
self::assertEmpty($reader->getClassAnnotations($class));
|
||||
self::assertEmpty($reader->getMethodAnnotations($class->getMethod('bar')));
|
||||
self::assertEmpty($reader->getPropertyAnnotations($class->getProperty('foo')));
|
||||
}
|
||||
|
||||
public function testAnnotationEnumeratorException(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$class = new ReflectionClass(Fixtures\ClassWithAnnotationEnum::class);
|
||||
|
||||
self::assertCount(1, $bar = $reader->getMethodAnnotations($class->getMethod('bar')));
|
||||
self::assertCount(1, $foo = $reader->getPropertyAnnotations($class->getProperty('foo')));
|
||||
|
||||
self::assertInstanceOf(Fixtures\AnnotationEnum::class, $bar[0]);
|
||||
self::assertInstanceOf(Fixtures\AnnotationEnum::class, $foo[0]);
|
||||
|
||||
try {
|
||||
$reader->getPropertyAnnotations($class->getProperty('invalidProperty'));
|
||||
$this->fail();
|
||||
} catch (AnnotationException $exc) {
|
||||
self::assertEquals(
|
||||
'[Enum Error] Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum' .
|
||||
' declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum' .
|
||||
'::$invalidProperty accepts only [ONE, TWO, THREE], but got FOUR.',
|
||||
$exc->getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
$reader->getMethodAnnotations($class->getMethod('invalidMethod'));
|
||||
$this->fail();
|
||||
} catch (AnnotationException $exc) {
|
||||
self::assertEquals(
|
||||
'[Enum Error] Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum' .
|
||||
' declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum' .
|
||||
'::invalidMethod() accepts only [ONE, TWO, THREE], but got 5.',
|
||||
$exc->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DCOM-106
|
||||
*/
|
||||
public function testIgnoreFixMeAndUpperCaseToDo(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(DCOM106::class);
|
||||
|
||||
self::assertEmpty($reader->getClassAnnotations($ref));
|
||||
}
|
||||
|
||||
public function testWillSkipAnnotationsContainingDashes(): void
|
||||
{
|
||||
self::assertEmpty(
|
||||
$this
|
||||
->getReader()
|
||||
->getClassAnnotations(new ReflectionClass(
|
||||
Fixtures\ClassWithInvalidAnnotationContainingDashes::class
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
public function testWillFailOnAnnotationConstantReferenceContainingDashes(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$reflection = new ReflectionClass(Fixtures\ClassWithAnnotationConstantReferenceWithDashes::class);
|
||||
|
||||
$this->expectExceptionMessage(
|
||||
'[Syntax Error] Expected Doctrine\Common\Annotations\DocLexer::T_CLOSE_PARENTHESIS, got \'-\' at'
|
||||
. ' position 14 in class ' . Fixtures\ClassWithAnnotationConstantReferenceWithDashes::class . '.'
|
||||
);
|
||||
|
||||
$reader->getClassAnnotations($reflection);
|
||||
}
|
||||
|
||||
abstract protected function getReader(): Reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @parseAnnotation("var")
|
||||
*/
|
||||
class TestParseAnnotationClass
|
||||
{
|
||||
/** @var */
|
||||
public $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* @NameBar
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class TestIgnoresNonAnnotationsClass
|
||||
{
|
||||
}
|
||||
|
||||
class TestTopLevelAnnotationClass
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @\TopLevelAnnotation
|
||||
*/
|
||||
public $field;
|
||||
}
|
||||
|
||||
class TestNonExistentAnnotationClass
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @Foo\Bar\Name
|
||||
*/
|
||||
public $field;
|
||||
}
|
||||
|
||||
class TestAnnotationNotImportedClass
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @NameFoo
|
||||
*/
|
||||
public $field;
|
||||
}
|
||||
|
||||
class TestChildClass
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @\Doctrine\Tests\Common\Annotations\Foo\Name(name = "foo")
|
||||
*/
|
||||
protected $child;
|
||||
}
|
||||
|
||||
class TestParentClass extends TestChildClass
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @\Doctrine\Tests\Common\Annotations\Bar\Name(name = "bar")
|
||||
*/
|
||||
public $parent;
|
||||
}
|
||||
|
||||
class TestImportWithConcreteAnnotation
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @DummyAnnotation(dummyValue = "bar")
|
||||
*/
|
||||
public $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignoreAnnotation("var")
|
||||
*/
|
||||
class DummyClass2
|
||||
{
|
||||
/**
|
||||
* @DummyId @DummyColumn(type="integer") @DummyGeneratedValue
|
||||
* @var int
|
||||
*/
|
||||
public $id;
|
||||
}
|
||||
|
||||
/** @Annotation */
|
||||
class NameBar extends Annotation
|
||||
{
|
||||
}
|
||||
/** @Annotation */
|
||||
class DummyId extends Annotation
|
||||
{
|
||||
}
|
||||
/** @Annotation */
|
||||
class DummyColumn extends Annotation
|
||||
{
|
||||
/** @var mixed */
|
||||
public $type;
|
||||
}
|
||||
/** @Annotation */
|
||||
class DummyGeneratedValue extends Annotation
|
||||
{
|
||||
}
|
||||
/** @Annotation */
|
||||
class DummyAnnotation extends Annotation
|
||||
{
|
||||
/** @var mixed */
|
||||
public $dummyValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
*/
|
||||
class DummyAnnotationWithIgnoredAnnotation extends Annotation
|
||||
{
|
||||
/** @var mixed */
|
||||
public $dummyValue;
|
||||
}
|
||||
|
||||
/** @Annotation */
|
||||
class DummyJoinColumn extends Annotation
|
||||
{
|
||||
/** @var mixed */
|
||||
public $name;
|
||||
/** @var mixed */
|
||||
public $referencedColumnName;
|
||||
}
|
||||
/** @Annotation */
|
||||
class DummyJoinTable extends Annotation
|
||||
{
|
||||
/** @var mixed */
|
||||
public $name;
|
||||
/** @var mixed */
|
||||
public $joinColumns;
|
||||
/** @var mixed */
|
||||
public $inverseJoinColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @DummyAnnotation(dummyValue = "bar",)
|
||||
*/
|
||||
class DummyClassWithDanglingComma
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @DummyAnnotation(@)
|
||||
*/
|
||||
class DummyClassSyntaxError
|
||||
{
|
||||
}
|
||||
|
||||
class DummyClassMethodSyntaxError
|
||||
{
|
||||
/**
|
||||
* @DummyAnnotation(@)
|
||||
*/
|
||||
public function foo(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class DummyClassPropertySyntaxError
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @DummyAnnotation(@)
|
||||
*/
|
||||
public $foo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignoreAnnotation({"since", "var"})
|
||||
*/
|
||||
class DummyClassNonAnnotationProblem
|
||||
{
|
||||
/**
|
||||
* @DummyAnnotation
|
||||
* @var Test
|
||||
*/
|
||||
public $foo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @DummyAnnotation Foo bar <foobar@1domain.com>
|
||||
*/
|
||||
class DummyClassWithEmail
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fixme public
|
||||
* @TODO
|
||||
*/
|
||||
class DCOM106
|
||||
{
|
||||
}
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Foo;
|
||||
|
||||
use Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
/** @Annotation */
|
||||
class Name extends Annotation
|
||||
{
|
||||
/** @var mixed */
|
||||
public $name;
|
||||
}
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Bar;
|
||||
|
||||
use Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
/** @Annotation */
|
||||
class Name extends Annotation
|
||||
{
|
||||
/** @var mixed */
|
||||
public $name;
|
||||
}
|
||||
30
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php
vendored
Normal file
30
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Annotation;
|
||||
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Tests for {@see \Doctrine\Common\Annotations\Annotation\Target}
|
||||
*
|
||||
* @covers \Doctrine\Common\Annotations\Annotation\Target
|
||||
*/
|
||||
class TargetTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @group DDC-3006
|
||||
*/
|
||||
public function testValidMixedTargets(): void
|
||||
{
|
||||
$target = new Target(['value' => ['ALL']]);
|
||||
self::assertEquals(Target::TARGET_ALL, $target->targets);
|
||||
|
||||
$target = new Target(['value' => ['METHOD', 'METHOD']]);
|
||||
self::assertEquals(Target::TARGET_METHOD, $target->targets);
|
||||
self::assertNotEquals(Target::TARGET_PROPERTY, $target->targets);
|
||||
|
||||
$target = new Target(['value' => ['PROPERTY', 'METHOD']]);
|
||||
self::assertEquals(Target::TARGET_METHOD | Target::TARGET_PROPERTY, $target->targets);
|
||||
}
|
||||
}
|
||||
332
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php
vendored
Normal file
332
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php
vendored
Normal file
@@ -0,0 +1,332 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\DocParser;
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\SingleUseAnnotation;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithEnumProperty;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithEnumAnnotations;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithFullPathUseStatement;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithImportedIgnoredAnnotation;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithPHPCodeSnifferAnnotation;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithPhpCsSuppressAnnotation;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithPHPStanGenericsAnnotations;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\IgnoredNamespaces\AnnotatedAtClassLevel;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\IgnoredNamespaces\AnnotatedAtMethodLevel;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\IgnoredNamespaces\AnnotatedAtPropertyLevel;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\IgnoredNamespaces\AnnotatedWithAlias;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Suit;
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
use ReflectionClass;
|
||||
use ReflectionFunction;
|
||||
|
||||
use function class_exists;
|
||||
use function spl_autoload_register;
|
||||
use function spl_autoload_unregister;
|
||||
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
class AnnotationReaderTest extends AbstractReaderTest
|
||||
{
|
||||
/**
|
||||
* @return AnnotationReader
|
||||
*/
|
||||
protected function getReader(?DocParser $parser = null): Reader
|
||||
{
|
||||
return new AnnotationReader($parser);
|
||||
}
|
||||
|
||||
public function testMethodAnnotationFromTrait(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(Fixtures\ClassUsesTrait::class);
|
||||
|
||||
$annotations = $reader->getMethodAnnotations($ref->getMethod('someMethod'));
|
||||
self::assertInstanceOf(Bar\Autoload::class, $annotations[0]);
|
||||
|
||||
$annotations = $reader->getMethodAnnotations($ref->getMethod('traitMethod'));
|
||||
self::assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]);
|
||||
}
|
||||
|
||||
public function testMethodAnnotationFromOverwrittenTrait(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(Fixtures\ClassOverwritesTrait::class);
|
||||
|
||||
$annotations = $reader->getMethodAnnotations($ref->getMethod('traitMethod'));
|
||||
self::assertInstanceOf(Bar2\Autoload::class, $annotations[0]);
|
||||
}
|
||||
|
||||
public function testPropertyAnnotationFromTrait(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(Fixtures\ClassUsesTrait::class);
|
||||
|
||||
$annotations = $reader->getPropertyAnnotations($ref->getProperty('aProperty'));
|
||||
self::assertInstanceOf(Bar\Autoload::class, $annotations[0]);
|
||||
|
||||
$annotations = $reader->getPropertyAnnotations($ref->getProperty('traitProperty'));
|
||||
self::assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]);
|
||||
}
|
||||
|
||||
public function testOmitNotRegisteredAnnotation(): void
|
||||
{
|
||||
$parser = new DocParser();
|
||||
$parser->setIgnoreNotImportedAnnotations(true);
|
||||
|
||||
$reader = $this->getReader($parser);
|
||||
$ref = new ReflectionClass(Fixtures\ClassWithNotRegisteredAnnotationUsed::class);
|
||||
|
||||
$annotations = $reader->getMethodAnnotations($ref->getMethod('methodWithNotRegisteredAnnotation'));
|
||||
self::assertEquals([], $annotations);
|
||||
}
|
||||
|
||||
public function testClassAnnotationSupportsSelfAccessorForConstants(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(Fixtures\ClassWithAnnotationWithSelfConstantReference::class);
|
||||
|
||||
$annotations = $reader->getClassAnnotations($ref);
|
||||
|
||||
self::assertCount(1, $annotations);
|
||||
|
||||
$annotation = $annotations[0];
|
||||
self::assertInstanceOf(Fixtures\AnnotationWithConstants::class, $annotation);
|
||||
self::assertEquals(
|
||||
$annotation->value,
|
||||
Fixtures\ClassWithAnnotationWithSelfConstantReference::VALUE_FOR_CLASS
|
||||
);
|
||||
}
|
||||
|
||||
public function testPropertyAnnotationSupportsSelfAccessorForConstants(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(Fixtures\ClassWithAnnotationWithSelfConstantReference::class);
|
||||
|
||||
$classProperty = $ref->getProperty('classProperty');
|
||||
$classAnnotation = $reader->getPropertyAnnotation($classProperty, Fixtures\AnnotationWithConstants::class);
|
||||
self::assertNotNull($classAnnotation);
|
||||
self::assertEquals(
|
||||
$classAnnotation->value,
|
||||
Fixtures\ClassWithAnnotationWithSelfConstantReference::VALUE_FOR_CLASS
|
||||
);
|
||||
|
||||
$traitProperty = $ref->getProperty('traitProperty');
|
||||
$traitAnnotation = $reader->getPropertyAnnotation($traitProperty, Fixtures\AnnotationWithConstants::class);
|
||||
self::assertNotNull($traitAnnotation);
|
||||
self::assertEquals(
|
||||
$traitAnnotation->value,
|
||||
Fixtures\ClassWithAnnotationWithSelfConstantReference::VALUE_FOR_TRAIT
|
||||
);
|
||||
}
|
||||
|
||||
public function testMethodAnnotationSupportsSelfAccessorForConstants(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(Fixtures\ClassWithAnnotationWithSelfConstantReference::class);
|
||||
|
||||
$classMethod = $ref->getMethod('classMethod');
|
||||
$classAnnotation = $reader->getMethodAnnotation($classMethod, Fixtures\AnnotationWithConstants::class);
|
||||
self::assertNotNull($classAnnotation);
|
||||
self::assertEquals(
|
||||
$classAnnotation->value,
|
||||
Fixtures\ClassWithAnnotationWithSelfConstantReference::VALUE_FOR_CLASS
|
||||
);
|
||||
|
||||
$traitMethod = $ref->getMethod('traitMethod');
|
||||
$traitAnnotation = $reader->getMethodAnnotation($traitMethod, Fixtures\AnnotationWithConstants::class);
|
||||
self::assertNotNull($traitAnnotation);
|
||||
self::assertEquals(
|
||||
$traitAnnotation->value,
|
||||
Fixtures\ClassWithAnnotationWithSelfConstantReference::VALUE_FOR_TRAIT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 45
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testClassAnnotationIsIgnored(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(AnnotatedAtClassLevel::class);
|
||||
|
||||
$reader::addGlobalIgnoredNamespace('SomeClassAnnotationNamespace');
|
||||
|
||||
self::assertEmpty($reader->getClassAnnotations($ref));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 45
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testMethodAnnotationIsIgnored(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(AnnotatedAtMethodLevel::class);
|
||||
|
||||
$reader::addGlobalIgnoredNamespace('SomeMethodAnnotationNamespace');
|
||||
|
||||
self::assertEmpty($reader->getMethodAnnotations($ref->getMethod('test')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 45
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testPropertyAnnotationIsIgnored(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(AnnotatedAtPropertyLevel::class);
|
||||
|
||||
$reader::addGlobalIgnoredNamespace('SomePropertyAnnotationNamespace');
|
||||
|
||||
self::assertEmpty($reader->getPropertyAnnotations($ref->getProperty('property')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 244
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testAnnotationWithAliasIsIgnored(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(AnnotatedWithAlias::class);
|
||||
|
||||
$reader::addGlobalIgnoredNamespace('SomePropertyAnnotationNamespace');
|
||||
|
||||
self::assertEmpty($reader->getPropertyAnnotations($ref->getProperty('property')));
|
||||
}
|
||||
|
||||
public function testClassWithFullPathUseStatement(): void
|
||||
{
|
||||
if (class_exists(SingleUseAnnotation::class, false)) {
|
||||
throw new LogicException(
|
||||
'The SingleUseAnnotation must not be used in other tests for this test to be useful.' .
|
||||
'If the class is already loaded then the code path that finds the class to load is not used and ' .
|
||||
'this test becomes useless.'
|
||||
);
|
||||
}
|
||||
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(ClassWithFullPathUseStatement::class);
|
||||
|
||||
$annotations = $reader->getClassAnnotations($ref);
|
||||
|
||||
self::assertInstanceOf(SingleUseAnnotation::class, $annotations[0]);
|
||||
}
|
||||
|
||||
public function testPhpCsSuppressAnnotationIsIgnored(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(ClassWithPhpCsSuppressAnnotation::class);
|
||||
|
||||
self::assertEmpty($reader->getMethodAnnotations($ref->getMethod('foo')));
|
||||
}
|
||||
|
||||
public function testGloballyIgnoredAnnotationNotIgnored(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$class = new ReflectionClass(Fixtures\ClassDDC1660::class);
|
||||
$testLoader = static function (string $className): bool {
|
||||
if ($className === 'since') {
|
||||
throw new InvalidArgumentException(
|
||||
'Globally ignored annotation names should never be passed to an autoloader.'
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
spl_autoload_register($testLoader, true, true);
|
||||
try {
|
||||
self::assertEmpty($reader->getClassAnnotations($class));
|
||||
} finally {
|
||||
spl_autoload_unregister($testLoader);
|
||||
}
|
||||
}
|
||||
|
||||
public function testPHPCodeSnifferAnnotationsAreIgnored(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(ClassWithPHPCodeSnifferAnnotation::class);
|
||||
|
||||
self::assertEmpty($reader->getClassAnnotations($ref));
|
||||
}
|
||||
|
||||
public function testPHPStanGenericsAnnotationsAreIgnored(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(ClassWithPHPStanGenericsAnnotations::class);
|
||||
|
||||
self::assertEmpty($reader->getClassAnnotations($ref));
|
||||
self::assertEmpty($reader->getPropertyAnnotations($ref->getProperty('bar')));
|
||||
self::assertEmpty($reader->getMethodAnnotations($ref->getMethod('foo')));
|
||||
|
||||
$this->expectException('\Doctrine\Common\Annotations\AnnotationException');
|
||||
$this->expectExceptionMessage(
|
||||
'[Semantical Error] The annotation "@Template" in method' .
|
||||
' Doctrine\Tests\Common\Annotations\Fixtures\ClassWithPHPStanGenericsAnnotations' .
|
||||
'::twigTemplateFunctionName() was never imported.'
|
||||
);
|
||||
self::assertEmpty($reader->getMethodAnnotations($ref->getMethod('twigTemplateFunctionName')));
|
||||
}
|
||||
|
||||
public function testImportedIgnoredAnnotationIsStillIgnored(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(ClassWithImportedIgnoredAnnotation::class);
|
||||
|
||||
self::assertEmpty($reader->getMethodAnnotations($ref->getMethod('something')));
|
||||
}
|
||||
|
||||
public function testFunctionsAnnotation(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionFunction('Doctrine\Tests\Common\Annotations\Fixtures\foo');
|
||||
|
||||
$annotations = $reader->getFunctionAnnotations($ref);
|
||||
self::assertCount(1, $annotations);
|
||||
self::assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]);
|
||||
}
|
||||
|
||||
public function testFunctionAnnotation(): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionFunction('Doctrine\Tests\Common\Annotations\Fixtures\foo');
|
||||
|
||||
$annotation = $reader->getFunctionAnnotation($ref, Fixtures\Annotation\Autoload::class);
|
||||
self::assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 8.1
|
||||
* @dataProvider provideEnumProperties
|
||||
*/
|
||||
public function testAnnotationWithEnum(string $property, Suit $expectedValue): void
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new ReflectionClass(ClassWithEnumAnnotations::class);
|
||||
|
||||
$annotation = $reader->getPropertyAnnotation($ref->getProperty($property), AnnotationWithEnumProperty::class);
|
||||
|
||||
self::assertSame($expectedValue, $annotation->suit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array{string, Suit}>
|
||||
*/
|
||||
public function provideEnumProperties(): array
|
||||
{
|
||||
if (PHP_VERSION_ID < 80100) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
'annotationWithDefaults' => ['annotationWithDefaults', Suit::Hearts],
|
||||
'annotationWithSpades' => ['annotationWithSpades', Suit::Spades],
|
||||
];
|
||||
}
|
||||
}
|
||||
231
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AnnotationRegistryTest.php
vendored
Normal file
231
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AnnotationRegistryTest.php
vendored
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\CanBeAutoLoaded;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\LoadedUsingRegisterFile;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\ShouldNeverBeLoaded;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionProperty;
|
||||
use TypeError;
|
||||
|
||||
use function random_int;
|
||||
|
||||
class AnnotationRegistryTest extends TestCase
|
||||
{
|
||||
/** @var string */
|
||||
protected $class = AnnotationRegistry::class;
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testReset(): void
|
||||
{
|
||||
$data = ['foo' => 'bar'];
|
||||
|
||||
$this->setStaticField($this->class, 'autoloadNamespaces', $data);
|
||||
$this->setStaticField($this->class, 'loaders', $data);
|
||||
|
||||
self::assertSame($data, $this->getStaticField($this->class, 'autoloadNamespaces'));
|
||||
self::assertSame($data, $this->getStaticField($this->class, 'loaders'));
|
||||
|
||||
AnnotationRegistry::reset();
|
||||
|
||||
self::assertEmpty($this->getStaticField($this->class, 'autoloadNamespaces'));
|
||||
self::assertEmpty($this->getStaticField($this->class, 'loaders'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testRegisterAutoloadNamespaces(): void
|
||||
{
|
||||
$this->setStaticField($this->class, 'autoloadNamespaces', ['foo' => 'bar']);
|
||||
|
||||
AnnotationRegistry::registerAutoloadNamespaces(['test' => 'bar']);
|
||||
self::assertSame(['foo' => 'bar', 'test' => 'bar'], $this->getStaticField($this->class, 'autoloadNamespaces'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testRegisterLoaderNoCallable(): void
|
||||
{
|
||||
$this->expectException(TypeError::class);
|
||||
|
||||
AnnotationRegistry::registerLoader('test' . random_int(10, 10000));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $value
|
||||
*/
|
||||
protected function setStaticField(string $class, string $field, array $value): void
|
||||
{
|
||||
$reflection = new ReflectionProperty($class, $field);
|
||||
|
||||
$reflection->setAccessible(true);
|
||||
$reflection->setValue(null, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getStaticField(string $class, string $field)
|
||||
{
|
||||
$reflection = new ReflectionProperty($class, $field);
|
||||
|
||||
$reflection->setAccessible(true);
|
||||
|
||||
return $reflection->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testStopCallingLoadersIfClassIsNotFound(): void
|
||||
{
|
||||
AnnotationRegistry::reset();
|
||||
$i = 0;
|
||||
$autoLoader = static function () use (&$i): bool {
|
||||
$i += 1;
|
||||
|
||||
return false;
|
||||
};
|
||||
AnnotationRegistry::registerLoader($autoLoader);
|
||||
AnnotationRegistry::loadAnnotationClass('unloadableClass');
|
||||
AnnotationRegistry::loadAnnotationClass('unloadableClass');
|
||||
AnnotationRegistry::loadAnnotationClass('unloadableClass');
|
||||
self::assertSame(1, $i, 'Autoloader should only be called once');
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testStopCallingLoadersAfterClassIsFound(): void
|
||||
{
|
||||
$className = 'autoloadedClass' . random_int(10, 100000);
|
||||
AnnotationRegistry::reset();
|
||||
$i = 0;
|
||||
$autoLoader = static function () use (&$i, $className): bool {
|
||||
eval('class ' . $className . ' {}');
|
||||
$i += 1;
|
||||
|
||||
return true;
|
||||
};
|
||||
AnnotationRegistry::registerLoader($autoLoader);
|
||||
AnnotationRegistry::loadAnnotationClass($className);
|
||||
AnnotationRegistry::loadAnnotationClass($className);
|
||||
AnnotationRegistry::loadAnnotationClass($className);
|
||||
self::assertSame(1, $i, 'Autoloader should only be called once');
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testAddingANewLoaderClearsTheCache(): void
|
||||
{
|
||||
$failures = 0;
|
||||
$failingLoader = static function () use (&$failures): bool {
|
||||
$failures += 1;
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
AnnotationRegistry::reset();
|
||||
AnnotationRegistry::registerLoader($failingLoader);
|
||||
|
||||
self::assertSame(0, $failures);
|
||||
|
||||
AnnotationRegistry::loadAnnotationClass('unloadableClass');
|
||||
|
||||
self::assertSame(1, $failures);
|
||||
|
||||
AnnotationRegistry::loadAnnotationClass('unloadableClass');
|
||||
|
||||
self::assertSame(1, $failures);
|
||||
|
||||
AnnotationRegistry::registerLoader(static function (): bool {
|
||||
return false;
|
||||
});
|
||||
AnnotationRegistry::loadAnnotationClass('unloadableClass');
|
||||
|
||||
self::assertSame(2, $failures);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testResetClearsRegisteredAutoloaderFailures(): void
|
||||
{
|
||||
$failures = 0;
|
||||
$failingLoader = static function () use (&$failures): bool {
|
||||
$failures += 1;
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
AnnotationRegistry::reset();
|
||||
AnnotationRegistry::registerLoader($failingLoader);
|
||||
|
||||
self::assertSame(0, $failures);
|
||||
|
||||
AnnotationRegistry::loadAnnotationClass('unloadableClass');
|
||||
|
||||
self::assertSame(1, $failures);
|
||||
|
||||
AnnotationRegistry::loadAnnotationClass('unloadableClass');
|
||||
|
||||
self::assertSame(1, $failures);
|
||||
|
||||
AnnotationRegistry::reset();
|
||||
AnnotationRegistry::registerLoader($failingLoader);
|
||||
AnnotationRegistry::loadAnnotationClass('unloadableClass');
|
||||
|
||||
self::assertSame(2, $failures);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testRegisterLoaderIfNotExistsOnlyRegisteresSameLoaderOnce(): void
|
||||
{
|
||||
$className = 'autoloadedClassThatDoesNotExist';
|
||||
AnnotationRegistry::reset();
|
||||
$autoLoader = self::createPartialMock(Autoloader::class, ['__invoke']);
|
||||
$autoLoader->expects($this->once())->method('__invoke');
|
||||
AnnotationRegistry::registerUniqueLoader($autoLoader);
|
||||
AnnotationRegistry::registerUniqueLoader($autoLoader);
|
||||
AnnotationRegistry::loadAnnotationClass($className);
|
||||
AnnotationRegistry::loadAnnotationClass($className);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testClassExistsFallback(): void
|
||||
{
|
||||
AnnotationRegistry::reset();
|
||||
|
||||
self::assertTrue(AnnotationRegistry::loadAnnotationClass(CanBeAutoLoaded::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testClassExistsFallbackNotUsedWhenRegisterFileUsed(): void
|
||||
{
|
||||
AnnotationRegistry::reset();
|
||||
AnnotationRegistry::registerFile(__DIR__ . '/Fixtures/Annotation/LoadedUsingRegisterFile.php');
|
||||
|
||||
self::assertTrue(AnnotationRegistry::loadAnnotationClass(LoadedUsingRegisterFile::class));
|
||||
self::assertFalse(AnnotationRegistry::loadAnnotationClass(ShouldNeverBeLoaded::class));
|
||||
}
|
||||
}
|
||||
|
||||
class Autoloader
|
||||
{
|
||||
public function __invoke(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
46
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AnnotationTest.php
vendored
Normal file
46
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AnnotationTest.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Doctrine\Common\Annotations\Annotation;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
final class AnnotationTest extends TestCase
|
||||
{
|
||||
public function testMagicGetThrowsBadMethodCallException(): void
|
||||
{
|
||||
$name = 'foo';
|
||||
|
||||
$annotation = new Annotation([]);
|
||||
|
||||
$this->expectException(BadMethodCallException::class);
|
||||
$this->expectExceptionMessage(sprintf(
|
||||
"Unknown property '%s' on annotation '%s'.",
|
||||
$name,
|
||||
Annotation::class
|
||||
));
|
||||
|
||||
// @phpstan-ignore-next-line This is expected not to exist
|
||||
$annotation->{$name};
|
||||
}
|
||||
|
||||
public function testMagicSetThrowsBadMethodCallException(): void
|
||||
{
|
||||
$name = 'foo';
|
||||
|
||||
$annotation = new Annotation([]);
|
||||
|
||||
$this->expectException(BadMethodCallException::class);
|
||||
$this->expectExceptionMessage(sprintf(
|
||||
"Unknown property '%s' on annotation '%s'.",
|
||||
$name,
|
||||
Annotation::class
|
||||
));
|
||||
|
||||
// @phpstan-ignore-next-line This is expected not to exist
|
||||
$annotation->{$name} = 9001;
|
||||
}
|
||||
}
|
||||
292
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php
vendored
Normal file
292
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php
vendored
Normal file
@@ -0,0 +1,292 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\CachedReader;
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\ClassThatUsesTraitThatUsesAnotherTraitWithMethods;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
|
||||
use function assert;
|
||||
use function class_exists;
|
||||
use function time;
|
||||
use function touch;
|
||||
|
||||
class CachedReaderTest extends AbstractReaderTest
|
||||
{
|
||||
/** @var int|ArrayCache */
|
||||
private $cache;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
if (! class_exists(ArrayCache::class)) {
|
||||
$this->markTestSkipped('Cannot test deprecated cached reader without doctrine/cache 1.x');
|
||||
}
|
||||
|
||||
parent::setup();
|
||||
}
|
||||
|
||||
public function testIgnoresStaleCache(): void
|
||||
{
|
||||
$cache = time() - 10;
|
||||
touch(__DIR__ . '/Fixtures/Controller.php', $cache + 10);
|
||||
|
||||
$this->doTestCacheStale(Fixtures\Controller::class, $cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 62
|
||||
*/
|
||||
public function testIgnoresStaleCacheWithParentClass(): void
|
||||
{
|
||||
$cache = time() - 10;
|
||||
touch(__DIR__ . '/Fixtures/ControllerWithParentClass.php', $cache - 10);
|
||||
touch(__DIR__ . '/Fixtures/AbstractController.php', $cache + 10);
|
||||
|
||||
$this->doTestCacheStale(Fixtures\ControllerWithParentClass::class, $cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 62
|
||||
*/
|
||||
public function testIgnoresStaleCacheWithTraits(): void
|
||||
{
|
||||
$cache = time() - 10;
|
||||
touch(__DIR__ . '/Fixtures/ControllerWithTrait.php', $cache - 10);
|
||||
touch(__DIR__ . '/Fixtures/Traits/SecretRouteTrait.php', $cache + 10);
|
||||
|
||||
$this->doTestCacheStale(Fixtures\ControllerWithTrait::class, $cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 62
|
||||
*/
|
||||
public function testIgnoresStaleCacheWithTraitsThatUseOtherTraits(): void
|
||||
{
|
||||
$cache = time() - 10;
|
||||
|
||||
touch(__DIR__ . '/Fixtures/ClassThatUsesTraitThatUsesAnotherTrait.php', $cache - 10);
|
||||
touch(__DIR__ . '/Fixtures/Traits/EmptyTrait.php', $cache + 10);
|
||||
|
||||
$this->doTestCacheStale(
|
||||
Fixtures\ClassThatUsesTraitThatUsesAnotherTrait::class,
|
||||
$cache
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 62
|
||||
*/
|
||||
public function testIgnoresStaleCacheWithInterfacesThatExtendOtherInterfaces(): void
|
||||
{
|
||||
$cache = time() - 10;
|
||||
|
||||
touch(__DIR__ . '/Fixtures/InterfaceThatExtendsAnInterface.php', $cache - 10);
|
||||
touch(__DIR__ . '/Fixtures/EmptyInterface.php', $cache + 10);
|
||||
|
||||
$this->doTestCacheStale(
|
||||
Fixtures\InterfaceThatExtendsAnInterface::class,
|
||||
$cache
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 62
|
||||
* @group 105
|
||||
*/
|
||||
public function testUsesFreshCacheWithTraitsThatUseOtherTraits(): void
|
||||
{
|
||||
$cacheTime = time();
|
||||
|
||||
touch(__DIR__ . '/Fixtures/ClassThatUsesTraitThatUsesAnotherTrait.php', $cacheTime - 10);
|
||||
touch(__DIR__ . '/Fixtures/Traits/EmptyTrait.php', $cacheTime - 10);
|
||||
|
||||
$this->doTestCacheFresh(
|
||||
'Doctrine\Tests\Common\Annotations\Fixtures\ClassThatUsesTraitThatUsesAnotherTrait',
|
||||
$cacheTime
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 62
|
||||
*/
|
||||
public function testPurgeLoadedAnnotations(): void
|
||||
{
|
||||
$cache = time() - 10;
|
||||
|
||||
touch(__DIR__ . '/Fixtures/ClassThatUsesTraitThatUsesAnotherTrait.php', $cache - 10);
|
||||
touch(__DIR__ . '/Fixtures/Traits/EmptyTrait.php', $cache + 10);
|
||||
|
||||
$reader = $this->doTestCacheStale(
|
||||
Fixtures\ClassThatUsesTraitThatUsesAnotherTrait::class,
|
||||
$cache
|
||||
);
|
||||
|
||||
$classReader = new ReflectionClass(CachedReader::class);
|
||||
|
||||
$loadedAnnotationsProperty = $classReader->getProperty('loadedAnnotations');
|
||||
$loadedAnnotationsProperty->setAccessible(true);
|
||||
$this->assertCount(1, $loadedAnnotationsProperty->getValue($reader));
|
||||
|
||||
$loadedFilemtimesProperty = $classReader->getProperty('loadedFilemtimes');
|
||||
$loadedFilemtimesProperty->setAccessible(true);
|
||||
$this->assertCount(3, $loadedFilemtimesProperty->getValue($reader));
|
||||
|
||||
$reader->clearLoadedAnnotations();
|
||||
|
||||
$this->assertCount(0, $loadedAnnotationsProperty->getValue($reader));
|
||||
$this->assertCount(0, $loadedFilemtimesProperty->getValue($reader));
|
||||
}
|
||||
|
||||
/**
|
||||
* As there is a cache on loadedAnnotations, we need to test two different
|
||||
* method's annotations of the same file
|
||||
*
|
||||
* We test four things
|
||||
* 1. we load the file (and its filemtime) for method1 annotation with fresh cache
|
||||
* 2. we load the file for method2 with stale cache => but still no save, because seen as fresh
|
||||
* 3. we purge loaded annotations and filemtime
|
||||
* 4. same as 2, but this time without filemtime cache, so file seen as stale and new cache is saved
|
||||
*
|
||||
* @group 62
|
||||
* @group 105
|
||||
*/
|
||||
public function testAvoidCallingFilemtimeTooMuch(): void
|
||||
{
|
||||
$this->markTestSkipped('Skipped until further investigation');
|
||||
|
||||
$className = ClassThatUsesTraitThatUsesAnotherTraitWithMethods::class;
|
||||
$cacheKey = $className;
|
||||
$cacheTime = time() - 10;
|
||||
|
||||
$cacheKeyMethod1 = $cacheKey . '#method1';
|
||||
$cacheKeyMethod2 = $cacheKey . '#method2';
|
||||
|
||||
$route1 = new Route();
|
||||
$route1->pattern = '/someprefix';
|
||||
$route2 = new Route();
|
||||
$route2->pattern = '/someotherprefix';
|
||||
|
||||
$cache = $this->createMock('Doctrine\Common\Cache\Cache');
|
||||
assert($cache instanceof Cache && $cache instanceof MockObject);
|
||||
|
||||
$cache
|
||||
->expects($this->exactly(6))
|
||||
->method('fetch')
|
||||
->withConsecutive(
|
||||
// first pass => cache ok for method 1
|
||||
// we load annotations AND filemtimes for this file
|
||||
[$this->equalTo($cacheKeyMethod1)],
|
||||
[$this->equalTo('[C]' . $cacheKeyMethod1)],
|
||||
// second pass => cache ok for method 2
|
||||
// filemtime is seen as fresh even if it's not
|
||||
[$this->equalTo($cacheKeyMethod2)],
|
||||
[$this->equalTo('[C]' . $cacheKeyMethod2)],
|
||||
// third pass => cache stale for method 2
|
||||
// filemtime is seen as not fresh => we save
|
||||
[$this->equalTo($cacheKeyMethod2)],
|
||||
[$this->equalTo('[C]' . $cacheKeyMethod2)]
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
[$route1], // Result was cached, but there was an annotation;
|
||||
$cacheTime,
|
||||
[$route2], // Result was cached, but there was an annotation;
|
||||
$cacheTime,
|
||||
[$route2], // Result was cached, but there was an annotation;
|
||||
$cacheTime
|
||||
);
|
||||
|
||||
$cache
|
||||
->expects($this->exactly(2))
|
||||
->method('save')
|
||||
->withConsecutive(
|
||||
[$this->equalTo($cacheKeyMethod2)],
|
||||
[$this->equalTo('[C]' . $cacheKeyMethod2)]
|
||||
);
|
||||
|
||||
$reader = new CachedReader(new AnnotationReader(), $cache, true);
|
||||
|
||||
touch(__DIR__ . '/Fixtures/ClassThatUsesTraitThatUsesAnotherTraitWithMethods.php', $cacheTime - 20);
|
||||
touch(__DIR__ . '/Fixtures/Traits/EmptyTrait.php', $cacheTime - 20);
|
||||
$this->assertEquals([$route1], $reader->getMethodAnnotations(new ReflectionMethod($className, 'method1')));
|
||||
|
||||
// only filemtime changes, but not cleared => no change
|
||||
touch(__DIR__ . '/Fixtures/ClassThatUsesTraitThatUsesAnotherTrait.php', $cacheTime + 5);
|
||||
touch(__DIR__ . '/Fixtures/Traits/EmptyTrait.php', $cacheTime + 5);
|
||||
$this->assertEquals([$route2], $reader->getMethodAnnotations(new ReflectionMethod($className, 'method2')));
|
||||
|
||||
$reader->clearLoadedAnnotations();
|
||||
$this->assertEquals([$route2], $reader->getMethodAnnotations(new ReflectionMethod($className, 'method2')));
|
||||
}
|
||||
|
||||
protected function doTestCacheStale(string $className, int $lastCacheModification): CachedReader
|
||||
{
|
||||
$cacheKey = $className;
|
||||
|
||||
$cache = $this->createMock(Cache::class);
|
||||
$cache
|
||||
->expects($this->exactly(2))
|
||||
->method('fetch')
|
||||
->withConsecutive(
|
||||
[$this->equalTo($cacheKey)],
|
||||
[$this->equalTo('[C]' . $cacheKey)]
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
[], // Result was cached, but there was no annotation
|
||||
$lastCacheModification
|
||||
);
|
||||
$cache
|
||||
->expects($this->exactly(2))
|
||||
->method('save')
|
||||
->withConsecutive(
|
||||
[$this->equalTo($cacheKey)],
|
||||
[$this->equalTo('[C]' . $cacheKey)]
|
||||
);
|
||||
|
||||
$reader = new CachedReader(new AnnotationReader(), $cache, true);
|
||||
$route = new Route();
|
||||
$route->pattern = '/someprefix';
|
||||
|
||||
self::assertEquals([$route], $reader->getClassAnnotations(new ReflectionClass($className)));
|
||||
|
||||
return $reader;
|
||||
}
|
||||
|
||||
protected function doTestCacheFresh(string $className, int $lastCacheModification): void
|
||||
{
|
||||
$cacheKey = $className;
|
||||
$route = new Route();
|
||||
$route->pattern = '/someprefix';
|
||||
|
||||
$cache = $this->createMock('Doctrine\Common\Cache\Cache');
|
||||
$cache
|
||||
->expects($this->exactly(2))
|
||||
->method('fetch')
|
||||
->withConsecutive(
|
||||
[$this->equalTo($cacheKey)],
|
||||
[$this->equalTo('[C]' . $cacheKey)]
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
[$route],
|
||||
$lastCacheModification
|
||||
);
|
||||
$cache->expects(self::never())->method('save');
|
||||
|
||||
$reader = new CachedReader(new AnnotationReader(), $cache, true);
|
||||
|
||||
$this->assertEquals([$route], $reader->getClassAnnotations(new ReflectionClass($className)));
|
||||
}
|
||||
|
||||
protected function getReader(): Reader
|
||||
{
|
||||
$this->cache = new ArrayCache();
|
||||
|
||||
return new CachedReader(new AnnotationReader(), $this->cache);
|
||||
}
|
||||
}
|
||||
328
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php
vendored
Normal file
328
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php
vendored
Normal file
@@ -0,0 +1,328 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\DocLexer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use function str_repeat;
|
||||
|
||||
class DocLexerTest extends TestCase
|
||||
{
|
||||
public function testMarkerAnnotation(): void
|
||||
{
|
||||
$lexer = new DocLexer();
|
||||
|
||||
$lexer->setInput('@Name');
|
||||
self::assertNull($lexer->token);
|
||||
self::assertNull($lexer->lookahead);
|
||||
|
||||
self::assertTrue($lexer->moveNext());
|
||||
self::assertNull($lexer->token);
|
||||
self::assertNotNull($lexer->lookahead);
|
||||
self::assertEquals('@', $lexer->lookahead['value']);
|
||||
|
||||
self::assertTrue($lexer->moveNext());
|
||||
self::assertNotNull($lexer->token);
|
||||
self::assertEquals('@', $lexer->token['value']);
|
||||
self::assertEquals('Name', $lexer->lookahead['value']);
|
||||
|
||||
self::assertFalse($lexer->moveNext());
|
||||
}
|
||||
|
||||
public function testScannerTokenizesDocBlockWhitConstants(): void
|
||||
{
|
||||
$lexer = new DocLexer();
|
||||
$docblock = '@AnnotationWithConstants(
|
||||
PHP_EOL,
|
||||
ClassWithConstants::SOME_VALUE,
|
||||
ClassWithConstants::CONSTANT_,
|
||||
ClassWithConstants::CONST_ANT3,
|
||||
\Doctrine\Tests\Common\Annotations\Fixtures\InterfaceWithConstants::SOME_VALUE
|
||||
)';
|
||||
|
||||
$tokens = [
|
||||
[
|
||||
'value' => '@',
|
||||
'position' => 0,
|
||||
'type' => DocLexer::T_AT,
|
||||
],
|
||||
[
|
||||
'value' => 'AnnotationWithConstants',
|
||||
'position' => 1,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
],
|
||||
[
|
||||
'value' => '(',
|
||||
'position' => 24,
|
||||
'type' => DocLexer::T_OPEN_PARENTHESIS,
|
||||
],
|
||||
[
|
||||
'value' => 'PHP_EOL',
|
||||
'position' => 38,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
],
|
||||
[
|
||||
'value' => ',',
|
||||
'position' => 45,
|
||||
'type' => DocLexer::T_COMMA,
|
||||
],
|
||||
[
|
||||
'value' => 'ClassWithConstants::SOME_VALUE',
|
||||
'position' => 59,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
],
|
||||
[
|
||||
'value' => ',',
|
||||
'position' => 89,
|
||||
'type' => DocLexer::T_COMMA,
|
||||
],
|
||||
[
|
||||
'value' => 'ClassWithConstants::CONSTANT_',
|
||||
'position' => 103,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
],
|
||||
[
|
||||
'value' => ',',
|
||||
'position' => 132,
|
||||
'type' => DocLexer::T_COMMA,
|
||||
],
|
||||
[
|
||||
'value' => 'ClassWithConstants::CONST_ANT3',
|
||||
'position' => 146,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
],
|
||||
[
|
||||
'value' => ',',
|
||||
'position' => 176,
|
||||
'type' => DocLexer::T_COMMA,
|
||||
],
|
||||
[
|
||||
'value' => '\\Doctrine\\Tests\\Common\\Annotations\\Fixtures\\InterfaceWithConstants::SOME_VALUE',
|
||||
'position' => 190,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
],
|
||||
[
|
||||
'value' => ')',
|
||||
'position' => 277,
|
||||
'type' => DocLexer::T_CLOSE_PARENTHESIS,
|
||||
],
|
||||
];
|
||||
|
||||
$lexer->setInput($docblock);
|
||||
|
||||
foreach ($tokens as $expected) {
|
||||
$lexer->moveNext();
|
||||
$lookahead = $lexer->lookahead;
|
||||
self::assertEquals($expected['value'], $lookahead['value']);
|
||||
self::assertEquals($expected['type'], $lookahead['type']);
|
||||
self::assertEquals($expected['position'], $lookahead['position']);
|
||||
}
|
||||
|
||||
self::assertFalse($lexer->moveNext());
|
||||
}
|
||||
|
||||
public function testScannerTokenizesDocBlockWhitInvalidIdentifier(): void
|
||||
{
|
||||
$lexer = new DocLexer();
|
||||
$docblock = '@Foo\3.42';
|
||||
|
||||
$tokens = [
|
||||
[
|
||||
'value' => '@',
|
||||
'position' => 0,
|
||||
'type' => DocLexer::T_AT,
|
||||
],
|
||||
[
|
||||
'value' => 'Foo',
|
||||
'position' => 1,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
],
|
||||
[
|
||||
'value' => '\\',
|
||||
'position' => 4,
|
||||
'type' => DocLexer::T_NAMESPACE_SEPARATOR,
|
||||
],
|
||||
[
|
||||
'value' => 3.42,
|
||||
'position' => 5,
|
||||
'type' => DocLexer::T_FLOAT,
|
||||
],
|
||||
];
|
||||
|
||||
$lexer->setInput($docblock);
|
||||
|
||||
foreach ($tokens as $expected) {
|
||||
$lexer->moveNext();
|
||||
$lookahead = $lexer->lookahead;
|
||||
self::assertEquals($expected['value'], $lookahead['value']);
|
||||
self::assertEquals($expected['type'], $lookahead['type']);
|
||||
self::assertEquals($expected['position'], $lookahead['position']);
|
||||
}
|
||||
|
||||
self::assertFalse($lexer->moveNext());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 44
|
||||
*/
|
||||
public function testWithinDoubleQuotesVeryVeryLongStringWillNotOverflowPregSplitStackLimit(): void
|
||||
{
|
||||
$lexer = new DocLexer();
|
||||
|
||||
$lexer->setInput('"' . str_repeat('.', 20240) . '"');
|
||||
|
||||
self::assertIsArray($lexer->glimpse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 44
|
||||
*/
|
||||
public function testRecognizesDoubleQuotesEscapeSequence(): void
|
||||
{
|
||||
$lexer = new DocLexer();
|
||||
$docblock = '@Foo("""' . "\n" . '""")';
|
||||
|
||||
$tokens = [
|
||||
[
|
||||
'value' => '@',
|
||||
'position' => 0,
|
||||
'type' => DocLexer::T_AT,
|
||||
],
|
||||
[
|
||||
'value' => 'Foo',
|
||||
'position' => 1,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
],
|
||||
[
|
||||
'value' => '(',
|
||||
'position' => 4,
|
||||
'type' => DocLexer::T_OPEN_PARENTHESIS,
|
||||
],
|
||||
[
|
||||
'value' => "\"\n\"",
|
||||
'position' => 5,
|
||||
'type' => DocLexer::T_STRING,
|
||||
],
|
||||
[
|
||||
'value' => ')',
|
||||
'position' => 12,
|
||||
'type' => DocLexer::T_CLOSE_PARENTHESIS,
|
||||
],
|
||||
];
|
||||
|
||||
$lexer->setInput($docblock);
|
||||
|
||||
foreach ($tokens as $expected) {
|
||||
$lexer->moveNext();
|
||||
$lookahead = $lexer->lookahead;
|
||||
self::assertEquals($expected['value'], $lookahead['value']);
|
||||
self::assertEquals($expected['type'], $lookahead['type']);
|
||||
self::assertEquals($expected['position'], $lookahead['position']);
|
||||
}
|
||||
|
||||
self::assertFalse($lexer->moveNext());
|
||||
}
|
||||
|
||||
public function testDoesNotRecognizeFullAnnotationWithDashInIt(): void
|
||||
{
|
||||
$this->expectDocblockTokens(
|
||||
'@foo-bar--',
|
||||
[
|
||||
[
|
||||
'value' => '@',
|
||||
'position' => 0,
|
||||
'type' => DocLexer::T_AT,
|
||||
],
|
||||
[
|
||||
'value' => 'foo',
|
||||
'position' => 1,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
],
|
||||
[
|
||||
'value' => '-',
|
||||
'position' => 4,
|
||||
'type' => DocLexer::T_MINUS,
|
||||
],
|
||||
[
|
||||
'value' => 'bar',
|
||||
'position' => 5,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
],
|
||||
[
|
||||
'value' => '-',
|
||||
'position' => 8,
|
||||
'type' => DocLexer::T_MINUS,
|
||||
],
|
||||
[
|
||||
'value' => '-',
|
||||
'position' => 9,
|
||||
'type' => DocLexer::T_MINUS,
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function testRecognizesNegativeNumbers(): void
|
||||
{
|
||||
$this->expectDocblockTokens(
|
||||
'-12.34 -56',
|
||||
[
|
||||
[
|
||||
'value' => '-12.34',
|
||||
'position' => 0,
|
||||
'type' => DocLexer::T_FLOAT,
|
||||
],
|
||||
[
|
||||
'value' => '-56',
|
||||
'position' => 7,
|
||||
'type' => DocLexer::T_INTEGER,
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-param list<array{value: mixed, position: int, type:int}> $expectedTokens
|
||||
*/
|
||||
private function expectDocblockTokens(string $docBlock, array $expectedTokens): void
|
||||
{
|
||||
$lexer = new DocLexer();
|
||||
$lexer->setInput($docBlock);
|
||||
|
||||
$actualTokens = [];
|
||||
|
||||
while ($lexer->moveNext()) {
|
||||
$lookahead = $lexer->lookahead;
|
||||
|
||||
$actualTokens[] = [
|
||||
'value' => $lookahead['value'],
|
||||
'type' => $lookahead['type'],
|
||||
'position' => $lookahead['position'],
|
||||
];
|
||||
}
|
||||
|
||||
self::assertEquals($expectedTokens, $actualTokens);
|
||||
}
|
||||
|
||||
public function testTokenAdjacency(): void
|
||||
{
|
||||
$lexer = new DocLexer();
|
||||
|
||||
$lexer->setInput('-- -');
|
||||
|
||||
self::assertTrue($lexer->nextTokenIsAdjacent());
|
||||
self::assertTrue($lexer->moveNext());
|
||||
self::assertTrue($lexer->nextTokenIsAdjacent());
|
||||
self::assertTrue($lexer->moveNext());
|
||||
self::assertTrue($lexer->nextTokenIsAdjacent());
|
||||
self::assertTrue($lexer->moveNext());
|
||||
self::assertFalse($lexer->nextTokenIsAdjacent());
|
||||
self::assertFalse($lexer->moveNext());
|
||||
}
|
||||
|
||||
public function testItReturnsNullWhenThereIsNothingToParse(): void
|
||||
{
|
||||
self::assertNull((new DocLexer())->peek());
|
||||
}
|
||||
}
|
||||
2092
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php
vendored
Normal file
2092
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
52
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DummyClass.php
vendored
Normal file
52
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DummyClass.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations;
|
||||
|
||||
/**
|
||||
* A description of this class.
|
||||
*
|
||||
* Let's see if the parser recognizes that this @ is not really referring to an
|
||||
* annotation. Also make sure that @var \ is not concated to "@var\is".
|
||||
*
|
||||
* @DummyAnnotation(dummyValue="hello")
|
||||
*/
|
||||
class DummyClass
|
||||
{
|
||||
/**
|
||||
* A nice property.
|
||||
*
|
||||
* @var mixed
|
||||
* @DummyAnnotation(dummyValue="fieldHello")
|
||||
*/
|
||||
public $field1;
|
||||
|
||||
/**
|
||||
* @var mixed;
|
||||
* @DummyJoinTable(name="join_table",
|
||||
* joinColumns={@DummyJoinColumn(name="col1", referencedColumnName="col2")},
|
||||
* inverseJoinColumns={
|
||||
* @DummyJoinColumn(name="col3", referencedColumnName="col4")
|
||||
* })
|
||||
*/
|
||||
public $field2;
|
||||
|
||||
/**
|
||||
* Gets the value of field1.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @DummyAnnotation({1,2,"three"})
|
||||
*/
|
||||
public function getField1()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* A parameter value with a space in it.
|
||||
*
|
||||
* @DummyAnnotation("\d{4}-[01]\d-[0-3]\d [0-2]\d:[0-5]\d:[0-5]\d")
|
||||
*/
|
||||
public function getField3(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
56
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php
vendored
Normal file
56
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\FileCacheReader;
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
|
||||
use function glob;
|
||||
use function method_exists;
|
||||
use function mkdir;
|
||||
use function rmdir;
|
||||
use function sys_get_temp_dir;
|
||||
use function uniqid;
|
||||
use function unlink;
|
||||
|
||||
class FileCacheReaderTest extends AbstractReaderTest
|
||||
{
|
||||
/** @var string */
|
||||
private $cacheDir;
|
||||
|
||||
protected function getReader(): Reader
|
||||
{
|
||||
$this->cacheDir = sys_get_temp_dir() . '/annotations_' . uniqid('', true);
|
||||
@mkdir($this->cacheDir);
|
||||
|
||||
return new FileCacheReader(new AnnotationReader(), $this->cacheDir);
|
||||
}
|
||||
|
||||
public function tearDown(): void
|
||||
{
|
||||
foreach (glob($this->cacheDir . '/*.php') as $file) {
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
rmdir($this->cacheDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DCOM-81
|
||||
*/
|
||||
public function testAttemptToCreateAnnotationCacheDir(): void
|
||||
{
|
||||
$this->cacheDir = sys_get_temp_dir() . '/not_existed_dir_' . uniqid('', true);
|
||||
|
||||
if (method_exists($this, 'assertDirectoryDoesNotExist')) {
|
||||
self::assertDirectoryDoesNotExist($this->cacheDir);
|
||||
} else {
|
||||
self::assertDirectoryNotExists($this->cacheDir);
|
||||
}
|
||||
|
||||
new FileCacheReader(new AnnotationReader(), $this->cacheDir);
|
||||
|
||||
self::assertDirectoryExists($this->cacheDir);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
abstract class AbstractController
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/** @Annotation */
|
||||
class AnnotWithDefaultValue
|
||||
{
|
||||
/** @var string */
|
||||
public $foo = 'bar';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
*/
|
||||
class Autoload
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/** @Annotation */
|
||||
class CanBeAutoLoaded
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/** @Annotation */
|
||||
class LoadedUsingRegisterFile
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
class Param
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/** @Annotation */
|
||||
class Route
|
||||
{
|
||||
/** @var string @Required */
|
||||
public $pattern;
|
||||
/** @var mixed */
|
||||
public $name;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
use function is_string;
|
||||
|
||||
/** @Annotation */
|
||||
class Secure
|
||||
{
|
||||
/** @var mixed */
|
||||
public $roles;
|
||||
|
||||
/**
|
||||
* @param mixed[] $values
|
||||
*/
|
||||
public function __construct(array $values)
|
||||
{
|
||||
if (is_string($values['value'])) {
|
||||
$values['value'] = [$values['value']];
|
||||
}
|
||||
|
||||
$this->roles = $values['value'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/** @Annotation */
|
||||
class ShouldNeverBeLoaded
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
*/
|
||||
class SingleUseAnnotation
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/** @Annotation */
|
||||
class Template
|
||||
{
|
||||
/** @var mixed */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @param mixed[] $values
|
||||
*/
|
||||
public function __construct(array $values)
|
||||
{
|
||||
$this->name = $values['value'] ?? null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("PROPERTY")
|
||||
*/
|
||||
final class Version
|
||||
{
|
||||
}
|
||||
20
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationEnum.php
vendored
Normal file
20
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationEnum.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
final class AnnotationEnum
|
||||
{
|
||||
public const ONE = 'ONE';
|
||||
public const TWO = 'TWO';
|
||||
public const THREE = 'THREE';
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
* @Enum({"ONE","TWO","THREE"})
|
||||
*/
|
||||
public $value;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
final class AnnotationEnumInvalid
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @Enum({1, 2, "foo", "bar", {"foo":"bar"}})
|
||||
*/
|
||||
public $value;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnumLiteral as SelfEnum;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
final class AnnotationEnumLiteral
|
||||
{
|
||||
public const ONE = 1;
|
||||
public const TWO = 2;
|
||||
public const THREE = 3;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
* @Enum(
|
||||
* value = {
|
||||
* 1,
|
||||
* 2,
|
||||
* 3,
|
||||
* },
|
||||
* literal = {
|
||||
* 1 : "AnnotationEnumLiteral::ONE",
|
||||
* 2 : "AnnotationEnumLiteral::TWO",
|
||||
* 3 : "AnnotationEnumLiteral::THREE",
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
public $value;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
final class AnnotationEnumLiteralInvalid
|
||||
{
|
||||
public const ONE = 1;
|
||||
public const TWO = 2;
|
||||
public const THREE = 3;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
* @Enum(
|
||||
* value = {
|
||||
* 1,
|
||||
* 2
|
||||
* },
|
||||
* literal = {
|
||||
* 1 : "AnnotationEnumLiteral::ONE",
|
||||
* 2 : "AnnotationEnumLiteral::TWO",
|
||||
* 3 : "AnnotationEnumLiteral::THREE"
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
public $value;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
class AnnotationTargetAll
|
||||
{
|
||||
/** @var mixed */
|
||||
public $data;
|
||||
/** @var mixed */
|
||||
public $name;
|
||||
/** @var mixed */
|
||||
public $target;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({ "ANNOTATION" })
|
||||
*/
|
||||
final class AnnotationTargetAnnotation
|
||||
{
|
||||
/** @var mixed */
|
||||
public $data;
|
||||
/** @var mixed */
|
||||
public $name;
|
||||
/** @var mixed */
|
||||
public $target;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("CLASS")
|
||||
*/
|
||||
final class AnnotationTargetClass
|
||||
{
|
||||
/** @var mixed */
|
||||
public $data;
|
||||
/** @var mixed */
|
||||
public $name;
|
||||
/** @var mixed */
|
||||
public $target;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("METHOD")
|
||||
*/
|
||||
final class AnnotationTargetMethod
|
||||
{
|
||||
/** @var mixed */
|
||||
public $data;
|
||||
/** @var mixed */
|
||||
public $name;
|
||||
/** @var mixed */
|
||||
public $target;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({ "METHOD", "PROPERTY" })
|
||||
*/
|
||||
final class AnnotationTargetPropertyMethod
|
||||
{
|
||||
/** @var mixed */
|
||||
public $data;
|
||||
/** @var mixed */
|
||||
public $name;
|
||||
/** @var mixed */
|
||||
public $target;
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
* @Attributes({
|
||||
@Attribute("mixed", type = "mixed"),
|
||||
@Attribute("boolean", type = "boolean"),
|
||||
@Attribute("bool", type = "bool"),
|
||||
@Attribute("float", type = "float"),
|
||||
@Attribute("string", type = "string"),
|
||||
@Attribute("integer", type = "integer"),
|
||||
@Attribute("array", type = "array"),
|
||||
@Attribute("arrayOfIntegers", type = "array<integer>"),
|
||||
@Attribute("arrayOfStrings", type = "string[]"),
|
||||
@Attribute("annotation", type = "Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll"),
|
||||
@Attribute("arrayOfAnnotations", type = "array<Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll>"),
|
||||
})
|
||||
*/
|
||||
final class AnnotationWithAttributes
|
||||
{
|
||||
/**
|
||||
* @param mixed[] $data
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/** @var mixed */
|
||||
private $mixed;
|
||||
/** @var bool */
|
||||
private $boolean;
|
||||
/** @var bool */
|
||||
private $bool;
|
||||
/** @var float */
|
||||
private $float;
|
||||
/** @var string */
|
||||
private $string;
|
||||
/** @var integer */
|
||||
private $integer;
|
||||
/** @var mixed[] */
|
||||
private $array;
|
||||
/** @var object */
|
||||
private $annotation;
|
||||
/** @var int[] */
|
||||
private $arrayOfIntegers;
|
||||
/** @var string[] */
|
||||
private $arrayOfStrings;
|
||||
/** @var object[] */
|
||||
private $arrayOfAnnotations;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMixed()
|
||||
{
|
||||
return $this->mixed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getBoolean()
|
||||
{
|
||||
return $this->boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getBool()
|
||||
{
|
||||
return $this->bool;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getFloat()
|
||||
{
|
||||
return $this->float;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getString()
|
||||
{
|
||||
return $this->string;
|
||||
}
|
||||
|
||||
public function getInteger(): int
|
||||
{
|
||||
return $this->integer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getArray()
|
||||
{
|
||||
return $this->array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AnnotationTargetAll
|
||||
*/
|
||||
public function getAnnotation()
|
||||
{
|
||||
return $this->annotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getArrayOfStrings()
|
||||
{
|
||||
return $this->arrayOfStrings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<integer>
|
||||
*/
|
||||
public function getArrayOfIntegers()
|
||||
{
|
||||
return $this->arrayOfIntegers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll>
|
||||
*/
|
||||
public function getArrayOfAnnotations()
|
||||
{
|
||||
return $this->arrayOfAnnotations;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
final class AnnotationWithConstants
|
||||
{
|
||||
public const INTEGER = 1;
|
||||
public const FLOAT = 1.2;
|
||||
public const STRING = '1.2.3';
|
||||
|
||||
/** @var mixed */
|
||||
public $value;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
* @NamedArgumentConstructor
|
||||
*/
|
||||
final class AnnotationWithEnumProperty
|
||||
{
|
||||
public function __construct(
|
||||
public readonly Suit $suit = Suit::Hearts,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
* @Attributes({
|
||||
@Attribute("value", required = true , type = "string"),
|
||||
@Attribute(
|
||||
"annot",
|
||||
required = true ,
|
||||
type = "Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation"
|
||||
),
|
||||
})
|
||||
*/
|
||||
final class AnnotationWithRequiredAttributes
|
||||
{
|
||||
/**
|
||||
* @param mixed[] $data
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/** @var string */
|
||||
private $value;
|
||||
|
||||
/** @var AnnotationTargetAnnotation */
|
||||
private $annot;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AnnotationTargetAnnotation
|
||||
*/
|
||||
public function getAnnot()
|
||||
{
|
||||
return $this->annot;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
final class AnnotationWithRequiredAttributesWithoutConstructor
|
||||
{
|
||||
/**
|
||||
* @Required
|
||||
* @var string
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* @Required
|
||||
* @var \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation
|
||||
*/
|
||||
public $annot;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target(@)
|
||||
*/
|
||||
final class AnnotationWithTargetSyntaxError
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
final class AnnotationWithVarType
|
||||
{
|
||||
/** @var mixed */
|
||||
public $mixed;
|
||||
|
||||
/** @var boolean */
|
||||
public $boolean;
|
||||
|
||||
/** @var bool */
|
||||
public $bool;
|
||||
|
||||
/** @var float */
|
||||
public $float;
|
||||
|
||||
/** @var string */
|
||||
public $string;
|
||||
|
||||
/** @var integer */
|
||||
public $integer;
|
||||
|
||||
/** @var array */
|
||||
public $array;
|
||||
|
||||
/** @var \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll */
|
||||
public $annotation;
|
||||
|
||||
/** @var array<integer> */
|
||||
public $arrayOfIntegers;
|
||||
|
||||
/** @var string[] */
|
||||
public $arrayOfStrings;
|
||||
|
||||
/** @var \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll[] */
|
||||
public $arrayOfAnnotations;
|
||||
}
|
||||
11
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Api.php
vendored
Normal file
11
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Api.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* This class is not an annotation
|
||||
* It's a class build to test ClassWithInclude
|
||||
*/
|
||||
class Api
|
||||
{
|
||||
}
|
||||
30
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassDDC1660.php
vendored
Normal file
30
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassDDC1660.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
* @version $Id: SomeEntityClass.php 509 2012-02-03 09:38:48Z mf $
|
||||
*/
|
||||
class ClassDDC1660
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @since 2.0
|
||||
* @version 1
|
||||
*/
|
||||
public $foo;
|
||||
|
||||
/**
|
||||
* @param string $param
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 2.0
|
||||
* @version 1
|
||||
*/
|
||||
public function bar($param)
|
||||
{
|
||||
return $param;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetClass;
|
||||
|
||||
class Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Bar2\Autoload;
|
||||
|
||||
class ClassOverwritesTrait
|
||||
{
|
||||
use TraitWithAnnotatedMethod;
|
||||
|
||||
/**
|
||||
* @Autoload
|
||||
*/
|
||||
public function traitMethod(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Bar2;
|
||||
|
||||
/** @Annotation */
|
||||
class Autoload
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Traits\TraitThatUsesAnotherTrait;
|
||||
|
||||
/**
|
||||
* @Route("/someprefix")
|
||||
*/
|
||||
class ClassThatUsesTraitThatUsesAnotherTrait
|
||||
{
|
||||
use TraitThatUsesAnotherTrait;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Traits\TraitThatUsesAnotherTrait;
|
||||
|
||||
class ClassThatUsesTraitThatUsesAnotherTraitWithMethods
|
||||
{
|
||||
use TraitThatUsesAnotherTrait;
|
||||
|
||||
/**
|
||||
* @Route("/someprefix")
|
||||
*/
|
||||
public function method1(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/someotherprefix")
|
||||
*/
|
||||
public function method2(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
30
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassUsesTrait.php
vendored
Normal file
30
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassUsesTrait.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Bar\Autoload;
|
||||
|
||||
class ClassUsesTrait
|
||||
{
|
||||
use TraitWithAnnotatedMethod;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
* @Autoload
|
||||
*/
|
||||
public $aProperty;
|
||||
|
||||
/**
|
||||
* @Autoload
|
||||
*/
|
||||
public function someMethod(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Bar;
|
||||
|
||||
/** @Annotation */
|
||||
class Autoload
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
|
||||
/** @Route(@AValid-constant::REFERENCE) */
|
||||
class ClassWithAnnotationConstantReferenceWithDashes
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum;
|
||||
|
||||
class ClassWithAnnotationEnum
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @AnnotationEnum(AnnotationEnum::ONE)
|
||||
*/
|
||||
public $foo;
|
||||
|
||||
/**
|
||||
* @AnnotationEnum("TWO")
|
||||
*/
|
||||
public function bar(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
* @AnnotationEnum("FOUR")
|
||||
*/
|
||||
public $invalidProperty;
|
||||
|
||||
/**
|
||||
* @AnnotationEnum(5)
|
||||
*/
|
||||
public function invalidMethod(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Traits\TraitWithSelfConstantReferenceTrait;
|
||||
|
||||
/** @AnnotationWithConstants(self::VALUE_FOR_CLASS) */
|
||||
class ClassWithAnnotationWithSelfConstantReference
|
||||
{
|
||||
use TraitWithSelfConstantReferenceTrait;
|
||||
|
||||
public const VALUE_FOR_CLASS = 'ClassWithAnnotationWithSelfConstantReference.VALUE_FROM_CLASS';
|
||||
public const VALUE_FOR_TRAIT = 'ClassWithAnnotationWithSelfConstantReference.VALUE_FOR_TRAIT';
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
* @AnnotationWithConstants(self::VALUE_FOR_CLASS)
|
||||
*/
|
||||
private $classProperty;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*
|
||||
* @AnnotationWithConstants(self::VALUE_FOR_CLASS)
|
||||
*/
|
||||
public function classMethod()
|
||||
{
|
||||
return $this->classProperty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError;
|
||||
|
||||
/**
|
||||
* @AnnotationWithTargetSyntaxError()
|
||||
*/
|
||||
class ClassWithAnnotationWithTargetSyntaxError
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @AnnotationWithTargetSyntaxError()
|
||||
*/
|
||||
public $foo;
|
||||
|
||||
/**
|
||||
* @AnnotationWithTargetSyntaxError()
|
||||
*/
|
||||
public function bar(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType;
|
||||
|
||||
class ClassWithAnnotationWithVarType
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @AnnotationWithVarType(string = "String Value")
|
||||
*/
|
||||
public $foo;
|
||||
|
||||
/**
|
||||
* @AnnotationWithVarType(annotation = @AnnotationTargetAll)
|
||||
*/
|
||||
public function bar(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
* @AnnotationWithVarType(string = 123)
|
||||
*/
|
||||
public $invalidProperty;
|
||||
|
||||
/**
|
||||
* @AnnotationWithVarType(annotation = @AnnotationTargetAnnotation)
|
||||
*/
|
||||
public function invalidMethod(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod;
|
||||
|
||||
class ClassWithAtInDescriptionAndAnnotation
|
||||
{
|
||||
/**
|
||||
* Lala
|
||||
*
|
||||
* {
|
||||
* "email": "foo@example.com",
|
||||
* "email2": "123@example.com",
|
||||
* "email3": "@example.com"
|
||||
* }
|
||||
*
|
||||
* @AnnotationTargetPropertyMethod("Bar")
|
||||
* @var mixed
|
||||
*/
|
||||
public $foo;
|
||||
|
||||
/**
|
||||
* Lala
|
||||
*
|
||||
* {
|
||||
* "email": "foo@example.com",
|
||||
* "email2": "123@example.com",
|
||||
* "email3": "@example.com"
|
||||
* }
|
||||
*
|
||||
* @AnnotationTargetPropertyMethod("Bar")
|
||||
* @var mixed
|
||||
*/
|
||||
public $bar;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetClass;
|
||||
|
||||
/**
|
||||
* @AnnotationTargetClass("Some data")
|
||||
*/
|
||||
class ClassWithClassAnnotationOnly
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation;
|
||||
|
||||
/**
|
||||
* @AnnotationTargetAll("Foo")
|
||||
*/
|
||||
final class ClassWithClosure
|
||||
{
|
||||
/**
|
||||
* @AnnotationTargetAll(@AnnotationTargetAnnotation)
|
||||
* @var string
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* @return \Closure
|
||||
*
|
||||
* @AnnotationTargetAll(@AnnotationTargetAnnotation)
|
||||
*/
|
||||
public function methodName(\Closure $callback)
|
||||
{
|
||||
return static function () use ($callback) {
|
||||
return $callback;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $year
|
||||
* @param integer $month
|
||||
* @param integer $day
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\ArrayCollection
|
||||
*/
|
||||
public function getEventsForDate($year, $month, $day)
|
||||
{
|
||||
$extractEvents = null; // check if date of item is inside day given
|
||||
$extractEvents = $this->events->filter(static function ($item) use ($year, $month, $day) {
|
||||
$leftDate = new \DateTime($year . '-' . $month . '-' . $day . ' 00:00');
|
||||
$rigthDate = new \DateTime($year . '-' . $month . '-' . $day . ' +1 day 00:00');
|
||||
|
||||
return ( $leftDate <= $item->getDateStart() ) && ( $item->getDateStart() < $rigthDate );
|
||||
});
|
||||
|
||||
return $extractEvents;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
class ClassWithConstants
|
||||
{
|
||||
public const SOME_VALUE = 'ClassWithConstants.SOME_VALUE';
|
||||
public const SOME_KEY = 'ClassWithConstants.SOME_KEY';
|
||||
public const OTHER_KEY_ = 'ClassWithConstants.OTHER_KEY_';
|
||||
public const OTHER_KEY_2 = 'ClassWithConstants.OTHER_KEY_2';
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
class ClassWithEnumAnnotations
|
||||
{
|
||||
/** @AnnotationWithEnumProperty */
|
||||
public mixed $annotationWithDefaults;
|
||||
|
||||
/** @AnnotationWithEnumProperty(suit=Suit::Spades) */
|
||||
public mixed $annotationWithSpades;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* The leading \ is intentional to ensure that code using
|
||||
* this use statement format works see issue #115/PR #120
|
||||
*/
|
||||
use \Doctrine\Tests\Common\Annotations\Fixtures\Annotation as Annotations;
|
||||
|
||||
/**
|
||||
* @Annotations\SingleUseAnnotation
|
||||
*/
|
||||
class ClassWithFullPathUseStatement
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use
|
||||
\Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure,
|
||||
\Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use \Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
|
||||
|
||||
class ClassWithFullyQualifiedUseStatements
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @ignoreAnnotation("IgnoreAnnotationClass")
|
||||
*/
|
||||
class ClassWithIgnoreAnnotation
|
||||
{
|
||||
/**
|
||||
* @var mixed[]
|
||||
* @IgnoreAnnotationClass
|
||||
*/
|
||||
public $foo;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Param;
|
||||
|
||||
class ClassWithImportedIgnoredAnnotation
|
||||
{
|
||||
/**
|
||||
* @param string $foo
|
||||
*/
|
||||
public function something($foo): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @please-do-not-parse-me
|
||||
* @AlsoDoNot\Parse-me
|
||||
*/
|
||||
class ClassWithInvalidAnnotationContainingDashes
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod;
|
||||
|
||||
/**
|
||||
* @AnnotationTargetPropertyMethod("Some data")
|
||||
*/
|
||||
class ClassWithInvalidAnnotationTargetAtClass
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @AnnotationTargetPropertyMethod("Bar")
|
||||
*/
|
||||
public $foo;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetClass;
|
||||
|
||||
/**
|
||||
* @AnnotationTargetClass("Some data")
|
||||
*/
|
||||
class ClassWithInvalidAnnotationTargetAtMethod
|
||||
{
|
||||
/**
|
||||
* @param mixed $param
|
||||
*
|
||||
* @AnnotationTargetClass("functionName")
|
||||
*/
|
||||
public function functionName($param): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetClass;
|
||||
|
||||
/**
|
||||
* @AnnotationTargetClass("Some data")
|
||||
*/
|
||||
class ClassWithInvalidAnnotationTargetAtProperty
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @AnnotationTargetClass("Bar")
|
||||
*/
|
||||
public $foo;
|
||||
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
* @AnnotationTargetAnnotation("Foo")
|
||||
*/
|
||||
public $bar;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @package Doctrine\Tests\Common\Annotations\Fixtures
|
||||
*/
|
||||
class ClassWithNotRegisteredAnnotationUsed
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @notRegisteredCustomAnnotation
|
||||
*/
|
||||
public function methodWithNotRegisteredAnnotation()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @codingStandardsIgnoreStart
|
||||
* @codingStandardsIgnoreEnd
|
||||
*/
|
||||
class ClassWithPHPCodeSnifferAnnotation
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
interface WithPHPStanExtendsAnnotations
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
class ClassWithPHPStanExtendsAnnotationsGeneric
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
trait GenericPHPStanTrait
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @implements WithPHPStanExtendsAnnotationsInterface<int>
|
||||
* @extends ClassWithPHPStanExtendsAnnotationsGeneric<int>
|
||||
*/
|
||||
class ClassWithPHPStanGenericsAnnotations extends ClassWithPHPStanExtendsAnnotationsGeneric implements
|
||||
WithPHPStanExtendsAnnotations
|
||||
{
|
||||
/**
|
||||
* @use GenericPHPStanTrait<T>
|
||||
*/
|
||||
use GenericPHPStanTrait;
|
||||
|
||||
/** @var array<T> */
|
||||
private $bar;
|
||||
|
||||
/**
|
||||
* @param array<T> $array
|
||||
*
|
||||
* @return array<T>
|
||||
*/
|
||||
public function foo($array)
|
||||
{
|
||||
return $this->bar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Template("@foo.html.twig")
|
||||
*/
|
||||
public function twigTemplateFunctionName(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
class ClassWithPhpCsSuppressAnnotation
|
||||
{
|
||||
/**
|
||||
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint
|
||||
*/
|
||||
public function foo($parameterWithoutTypehint): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
// Include a class named Api
|
||||
require_once __DIR__ . '/Api.php';
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\DummyAnnotationWithIgnoredAnnotation;
|
||||
|
||||
/**
|
||||
* @DummyAnnotationWithIgnoredAnnotation(dummyValue="hello")
|
||||
*/
|
||||
class ClassWithRequire
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetClass;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod;
|
||||
|
||||
/**
|
||||
* @AnnotationTargetClass("Some data")
|
||||
*/
|
||||
class ClassWithValidAnnotationTarget
|
||||
{
|
||||
/** @AnnotationTargetPropertyMethod("Some data") */
|
||||
public $foo;
|
||||
|
||||
|
||||
/** @AnnotationTargetAll("Some data",name="Some name") */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @AnnotationTargetPropertyMethod("Some data",name="Some name")
|
||||
*/
|
||||
public function someFunction(): void
|
||||
{
|
||||
}
|
||||
|
||||
/** @AnnotationTargetAll(@AnnotationTargetAnnotation) */
|
||||
public $nested;
|
||||
}
|
||||
334
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Controller.php
vendored
Normal file
334
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/Controller.php
vendored
Normal file
@@ -0,0 +1,334 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
|
||||
|
||||
/**
|
||||
* @Route("/someprefix")
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class Controller
|
||||
{
|
||||
/**
|
||||
* @return mixed[]
|
||||
*
|
||||
* @Route("/", name="_demo")
|
||||
* @Template()
|
||||
*/
|
||||
public function indexAction(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*
|
||||
* @Route("/hello/{name}", name="_demo_hello")
|
||||
* @Template()
|
||||
*/
|
||||
public function helloAction(string $name): array
|
||||
{
|
||||
return ['name' => $name];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*
|
||||
* @Route("/contact", name="_demo_contact")
|
||||
* @Template()
|
||||
*/
|
||||
public function contactAction(): array
|
||||
{
|
||||
$form = ContactForm::create($this->get('form.context'), 'contact');
|
||||
|
||||
$form->bind($this->container->get('request'), $form);
|
||||
if ($form->isValid()) {
|
||||
$form->send($this->get('mailer'));
|
||||
|
||||
$this->get('session')->setFlash('notice', 'Message sent!');
|
||||
|
||||
return new RedirectResponse($this->generateUrl('_demo'));
|
||||
}
|
||||
|
||||
return ['form' => $form];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the ACL for the passed object identity
|
||||
*/
|
||||
private function createObjectIdentity(ObjectIdentityInterface $oid): void
|
||||
{
|
||||
$classId = $this->createOrRetrieveClassId($oid->getType());
|
||||
|
||||
$this->connection->executeQuery($this->getInsertObjectIdentitySql($oid->getIdentifier(), $classId, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for the passed class type.
|
||||
*
|
||||
* If the type does not yet exist in the database, it will be created.
|
||||
*
|
||||
* @param string $classType
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
private function createOrRetrieveClassId($classType)
|
||||
{
|
||||
$id = $this->connection->executeQuery($this->getSelectClassIdSql($classType))->fetchColumn();
|
||||
if ($id !== false) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
$this->connection->executeQuery($this->getInsertClassSql($classType));
|
||||
|
||||
return $this->connection->executeQuery($this->getSelectClassIdSql($classType))->fetchColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for the passed security identity.
|
||||
*
|
||||
* If the security identity does not yet exist in the database, it will be
|
||||
* created.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
private function createOrRetrieveSecurityIdentityId(SecurityIdentityInterface $sid)
|
||||
{
|
||||
$id = $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn();
|
||||
if ($id !== false) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
$this->connection->executeQuery($this->getInsertSecurityIdentitySql($sid));
|
||||
|
||||
return $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all ACEs for the given object identity primary key.
|
||||
*
|
||||
* @param integer $oidPK
|
||||
*/
|
||||
private function deleteAccessControlEntries($oidPK): void
|
||||
{
|
||||
$this->connection->executeQuery($this->getDeleteAccessControlEntriesSql($oidPK));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the object identity from the database.
|
||||
*
|
||||
* @param integer $pk
|
||||
*/
|
||||
private function deleteObjectIdentity($pk): void
|
||||
{
|
||||
$this->connection->executeQuery($this->getDeleteObjectIdentitySql($pk));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all entries from the relations table from the database.
|
||||
*
|
||||
* @param integer $pk
|
||||
*/
|
||||
private function deleteObjectIdentityRelations($pk): void
|
||||
{
|
||||
$this->connection->executeQuery($this->getDeleteObjectIdentityRelationsSql($pk));
|
||||
}
|
||||
|
||||
/**
|
||||
* This regenerates the ancestor table which is used for fast read access.
|
||||
*/
|
||||
private function regenerateAncestorRelations(AclInterface $acl): void
|
||||
{
|
||||
$pk = $acl->getId();
|
||||
$this->connection->executeQuery($this->getDeleteObjectIdentityRelationsSql($pk));
|
||||
$this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $pk));
|
||||
|
||||
$parentAcl = $acl->getParentAcl();
|
||||
while ($parentAcl !== null) {
|
||||
$this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $parentAcl->getId()));
|
||||
|
||||
$parentAcl = $parentAcl->getParentAcl();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This processes changes on an ACE related property (classFieldAces, or objectFieldAces).
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed[] $changes
|
||||
*/
|
||||
private function updateFieldAceProperty($name, array $changes): void
|
||||
{
|
||||
$sids = new \SplObjectStorage();
|
||||
$classIds = new \SplObjectStorage();
|
||||
$currentIds = [];
|
||||
foreach ($changes[1] as $field => $new) {
|
||||
for ($i = 0,$c = count($new); $i < $c; $i++) {
|
||||
$ace = $new[$i];
|
||||
|
||||
if ($ace->getId() === null) {
|
||||
if ($sids->contains($ace->getSecurityIdentity())) {
|
||||
$sid = $sids->offsetGet($ace->getSecurityIdentity());
|
||||
} else {
|
||||
$sid = $this->createOrRetrieveSecurityIdentityId($ace->getSecurityIdentity());
|
||||
}
|
||||
|
||||
$oid = $ace->getAcl()->getObjectIdentity();
|
||||
if ($classIds->contains($oid)) {
|
||||
$classId = $classIds->offsetGet($oid);
|
||||
} else {
|
||||
$classId = $this->createOrRetrieveClassId($oid->getType());
|
||||
}
|
||||
|
||||
$objectIdentityId = $name === 'classFieldAces' ? null : $ace->getAcl()->getId();
|
||||
|
||||
$this->connection->executeQuery($this->getInsertAccessControlEntrySql(
|
||||
$classId,
|
||||
$objectIdentityId,
|
||||
$field,
|
||||
$i,
|
||||
$sid,
|
||||
$ace->getStrategy(),
|
||||
$ace->getMask(),
|
||||
$ace->isGranting(),
|
||||
$ace->isAuditSuccess(),
|
||||
$ace->isAuditFailure()
|
||||
));
|
||||
$aceId = $this->connection->executeQuery(
|
||||
$this->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, $field, $i)
|
||||
)->fetchColumn();
|
||||
$this->loadedAces[$aceId] = $ace;
|
||||
|
||||
$aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id');
|
||||
$aceIdProperty->setAccessible(true);
|
||||
$aceIdProperty->setValue($ace, (int) $aceId);
|
||||
} else {
|
||||
$currentIds[$ace->getId()] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($changes[0] as $old) {
|
||||
for ($i = 0,$c = count($old); $i < $c; $i++) {
|
||||
$ace = $old[$i];
|
||||
|
||||
if (isset($currentIds[$ace->getId()])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId()));
|
||||
unset($this->loadedAces[$ace->getId()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This processes changes on an ACE related property (classAces, or objectAces).
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed[] $changes
|
||||
*/
|
||||
private function updateAceProperty($name, array $changes): void
|
||||
{
|
||||
[$old, $new] = $changes;
|
||||
|
||||
$sids = new \SplObjectStorage();
|
||||
$classIds = new \SplObjectStorage();
|
||||
$currentIds = [];
|
||||
for ($i = 0,$c = count($new); $i < $c; $i++) {
|
||||
$ace = $new[$i];
|
||||
|
||||
if ($ace->getId() === null) {
|
||||
if ($sids->contains($ace->getSecurityIdentity())) {
|
||||
$sid = $sids->offsetGet($ace->getSecurityIdentity());
|
||||
} else {
|
||||
$sid = $this->createOrRetrieveSecurityIdentityId($ace->getSecurityIdentity());
|
||||
}
|
||||
|
||||
$oid = $ace->getAcl()->getObjectIdentity();
|
||||
if ($classIds->contains($oid)) {
|
||||
$classId = $classIds->offsetGet($oid);
|
||||
} else {
|
||||
$classId = $this->createOrRetrieveClassId($oid->getType());
|
||||
}
|
||||
|
||||
$objectIdentityId = $name === 'classAces' ? null : $ace->getAcl()->getId();
|
||||
|
||||
$this->connection->executeQuery($this->getInsertAccessControlEntrySql(
|
||||
$classId,
|
||||
$objectIdentityId,
|
||||
null,
|
||||
$i,
|
||||
$sid,
|
||||
$ace->getStrategy(),
|
||||
$ace->getMask(),
|
||||
$ace->isGranting(),
|
||||
$ace->isAuditSuccess(),
|
||||
$ace->isAuditFailure()
|
||||
));
|
||||
$aceId = $this->connection->executeQuery(
|
||||
$this->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, null, $i)
|
||||
)->fetchColumn();
|
||||
$this->loadedAces[$aceId] = $ace;
|
||||
|
||||
$aceIdProperty = new \ReflectionProperty($ace, 'id');
|
||||
$aceIdProperty->setAccessible(true);
|
||||
$aceIdProperty->setValue($ace, (int) $aceId);
|
||||
} else {
|
||||
$currentIds[$ace->getId()] = true;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0,$c = count($old); $i < $c; $i++) {
|
||||
$ace = $old[$i];
|
||||
|
||||
if (isset($currentIds[$ace->getId()])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId()));
|
||||
unset($this->loadedAces[$ace->getId()]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Persists the changes which were made to ACEs to the database.
|
||||
*/
|
||||
private function updateAces(\SplObjectStorage $aces): void
|
||||
{
|
||||
foreach ($aces as $ace) {
|
||||
$propertyChanges = $aces->offsetGet($ace);
|
||||
$sets = [];
|
||||
|
||||
if (isset($propertyChanges['mask'])) {
|
||||
$sets[] = sprintf('mask = %d', $propertyChanges['mask'][1]);
|
||||
}
|
||||
|
||||
if (isset($propertyChanges['strategy'])) {
|
||||
$sets[] = sprintf('granting_strategy = %s', $this->connection->quote($propertyChanges['strategy']));
|
||||
}
|
||||
|
||||
if (isset($propertyChanges['aceOrder'])) {
|
||||
$sets[] = sprintf('ace_order = %d', $propertyChanges['aceOrder'][1]);
|
||||
}
|
||||
|
||||
if (isset($propertyChanges['auditSuccess'])) {
|
||||
$sets[] = sprintf(
|
||||
'audit_success = %s',
|
||||
$this->connection->getDatabasePlatform()->convertBooleans($propertyChanges['auditSuccess'][1])
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($propertyChanges['auditFailure'])) {
|
||||
$sets[] = sprintf(
|
||||
'audit_failure = %s',
|
||||
$this->connection->getDatabasePlatform()->convertBooleans($propertyChanges['auditFailure'][1])
|
||||
);
|
||||
}
|
||||
|
||||
$this->connection->executeQuery($this->getUpdateAccessControlEntrySql($ace->getId(), $sets));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
|
||||
|
||||
/**
|
||||
* @Route("/someprefix")
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ControllerWithParentClass extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @return mixed[]
|
||||
*
|
||||
* @Route("/", name="_demo")
|
||||
* @Template()
|
||||
*/
|
||||
public function indexAction(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Traits\SecretRouteTrait;
|
||||
|
||||
/**
|
||||
* @Route("/someprefix")
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ControllerWithTrait
|
||||
{
|
||||
use SecretRouteTrait;
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*
|
||||
* @Route("/", name="_demo")
|
||||
* @Template()
|
||||
*/
|
||||
public function indexAction(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures {
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
|
||||
|
||||
class DifferentNamespacesPerFileWithClassAsFirst
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
|
||||
}
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Foo {
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Foo {
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
|
||||
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
|
||||
}
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures {
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
|
||||
|
||||
class DifferentNamespacesPerFileWithClassAsLast
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
interface EmptyInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
|
||||
|
||||
class EqualNamespacesPerFileWithClassAsFirst
|
||||
{
|
||||
}
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
|
||||
|
||||
class EqualNamespacesPerFileWithClassAsLast
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace {
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
|
||||
|
||||
class GlobalNamespacesPerFileWithClassAsFirst
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace {
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
|
||||
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
|
||||
|
||||
class GlobalNamespacesPerFileWithClassAsLast
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\{Route, Secure as SuperSecure, Template};
|
||||
|
||||
class GroupUseStatement
|
||||
{
|
||||
}
|
||||
13
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/HereForTesting.php
vendored
Normal file
13
vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/HereForTesting.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
|
||||
|
||||
interface HereForTesting
|
||||
{
|
||||
/**
|
||||
* @Secure
|
||||
*/
|
||||
public function foo();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
class IgnoreAnnotationClass
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\IgnoredNamespaces;
|
||||
|
||||
/**
|
||||
* @SomeClassAnnotationNamespace\Subnamespace\Name
|
||||
*/
|
||||
class AnnotatedAtClassLevel
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\IgnoredNamespaces;
|
||||
|
||||
class AnnotatedAtMethodLevel
|
||||
{
|
||||
/**
|
||||
* @SomeMethodAnnotationNamespace\Subnamespace\Name
|
||||
*/
|
||||
public function test(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\IgnoredNamespaces;
|
||||
|
||||
class AnnotatedAtPropertyLevel
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @SomePropertyAnnotationNamespace\Subnamespace\Name
|
||||
*/
|
||||
public $property;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\IgnoredNamespaces;
|
||||
|
||||
use SomePropertyAnnotationNamespace\Subnamespace as SomeAlias;
|
||||
|
||||
class AnnotatedWithAlias
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
* @SomeAlias\Name
|
||||
*/
|
||||
public $property;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\EmptyInterface;
|
||||
|
||||
/**
|
||||
* @Route("/someprefix")
|
||||
*/
|
||||
interface InterfaceThatExtendsAnInterface extends EmptyInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
interface InterfaceWithConstants
|
||||
{
|
||||
public const SOME_VALUE = 'InterfaceWithConstants.SOME_VALUE';
|
||||
public const SOME_KEY = 'InterfaceWithConstants.SOME_KEY';
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
|
||||
/**
|
||||
* @NoAnnotation
|
||||
* @IgnoreAnnotation("NoAnnotation")
|
||||
* @Route("foo")
|
||||
*/
|
||||
class InvalidAnnotationUsageButIgnoredClass
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @NoAnnotation
|
||||
*/
|
||||
class InvalidAnnotationUsageClass
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
|
||||
|
||||
class AnotherClass
|
||||
{
|
||||
}
|
||||
class MultipleClassesInFile
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use
|
||||
Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route,
|
||||
Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
|
||||
|
||||
class MultipleImportsInUseStatement
|
||||
{
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user