Skip to content

Commit

Permalink
Merge origin/1.10.x into master (using imerge)
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire committed Aug 20, 2020
2 parents 80f0d17 + fbdb103 commit 2dceb19
Show file tree
Hide file tree
Showing 63 changed files with 1,154 additions and 408 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: "cs2pr"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v1"
Expand All @@ -33,6 +34,5 @@ jobs:
- name: "Install dependencies with composer"
run: "composer install --no-interaction --no-progress --no-suggest"

# https://github.com/doctrine/annotations/issues/349
- name: "Run PHP Code Beautifier"
run: "vendor/bin/phpcbf"
run: "vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr"
2 changes: 1 addition & 1 deletion lib/Doctrine/Common/Annotations/Annotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Annotation
public $value;

/**
* @param array $data Key-value for properties to be defined in this class.
* @param array<string, mixed> $data Key-value for properties to be defined in this class.
*/
final public function __construct(array $data)
{
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/Common/Annotations/Annotation/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@
*/
final class Enum
{
/** @var array */
/** @phpstan-var list<scalar> */
public $value;

/**
* Literal target declaration.
*
* @var array
* @var mixed[]
*/
public $literal;

/**
* @param array $values
*
* @throws InvalidArgumentException
*
* @phpstan-param array{literal?: mixed[], value: list<scalar>} $values
*/
public function __construct(array $values)
{
Expand Down
11 changes: 7 additions & 4 deletions lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
*/
final class IgnoreAnnotation
{
/** @var array */
/** @phpstan-var list<string> */
public $names;

/**
* @param array $values
*
* @throws RuntimeException
*
* @phpstan-param array{value: string|list<string>} $values
*/
public function __construct(array $values)
{
Expand All @@ -32,7 +32,10 @@ public function __construct(array $values)
}

if (! is_array($values['value'])) {
throw new RuntimeException(sprintf('@IgnoreAnnotation expects either a string name, or an array of strings, but got %s.', json_encode($values['value'])));
throw new RuntimeException(sprintf(
'@IgnoreAnnotation expects either a string name, or an array of strings, but got %s.',
json_encode($values['value'])
));
}

$this->names = $values['value'];
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/Common/Annotations/Annotation/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class Target
public const TARGET_ANNOTATION = 8;
public const TARGET_ALL = 15;

/** @var array */
/** @var array<string, int> */
private static $map = [
'ALL' => self::TARGET_ALL,
'CLASS' => self::TARGET_CLASS,
Expand All @@ -36,7 +36,7 @@ final class Target
'ANNOTATION' => self::TARGET_ANNOTATION,
];

/** @var array */
/** @phpstan-var list<string> */
public $value;

/**
Expand All @@ -54,9 +54,9 @@ final class Target
public $literal;

/**
* @param array $values
*
* @throws InvalidArgumentException
*
* @phpstan-param array{value?: string|list<string>} $values
*/
public function __construct(array $values)
{
Expand Down
13 changes: 7 additions & 6 deletions lib/Doctrine/Common/Annotations/AnnotationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,19 @@ public static function requiredError($attributeName, $annotationName, $context,
/**
* Creates a new AnnotationException describing a invalid enummerator.
*
* @param string $attributeName
* @param string $annotationName
* @param string $context
* @param array $available
* @param mixed $given
* @param string $attributeName
* @param string $annotationName
* @param string $context
* @param object|class-string $given
*
* @return AnnotationException
*
* @phpstan-param list<string> $available
*/
public static function enumeratorError($attributeName, $annotationName, $context, $available, $given)
{
return new self(sprintf(
'[Enum Error] Attribute "%s" of @%s declared on %s accept only [%s], but got %s.',
'[Enum Error] Attribute "%s" of @%s declared on %s accepts only [%s], but got %s.',
$attributeName,
$annotationName,
$context,
Expand Down
23 changes: 13 additions & 10 deletions lib/Doctrine/Common/Annotations/AnnotationReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AnnotationReader implements Reader
/**
* Global map for imports.
*
* @var array
* @var array<string, class-string>
*/
private static $globalImports = [
'ignoreannotation' => Annotation\IgnoreAnnotation::class,
Expand All @@ -32,7 +32,7 @@ class AnnotationReader implements Reader
*
* The names are case sensitive.
*
* @var array
* @var array<string, true>
*/
private static $globalIgnoredNames = ImplicitlyIgnoredAnnotationNames::LIST;

Expand All @@ -41,7 +41,7 @@ class AnnotationReader implements Reader
*
* The names are case sensitive.
*
* @var array
* @var array<string, true>
*/
private static $globalIgnoredNamespaces = [];

Expand Down Expand Up @@ -89,14 +89,14 @@ public static function addGlobalIgnoredNamespace($namespace)
/**
* In-memory cache mechanism to store imported annotations per class.
*
* @var array
* @var array<string, array<string, class-string>>
*/
private $imports = [];

/**
* In-memory cache mechanism to store ignored annotations per class.
*
* @var array
* @var array<string, array<string, true>>
*/
private $ignoredAnnotationNames = [];

Expand All @@ -107,7 +107,10 @@ public static function addGlobalIgnoredNamespace($namespace)
*/
public function __construct(?DocParser $parser = null)
{
if (extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.save_comments') === '0' || ini_get('opcache.save_comments') === '0')) {
if (
extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.save_comments') === '0' ||
ini_get('opcache.save_comments') === '0')
) {
throw AnnotationException::optimizerPlusSaveComments();
}

Expand Down Expand Up @@ -225,7 +228,7 @@ public function getMethodAnnotation(ReflectionMethod $method, $annotationName)
/**
* Returns the ignored annotations for the given class.
*
* @return array
* @return array<string, true>
*/
private function getIgnoredAnnotationNames(ReflectionClass $class)
{
Expand All @@ -242,7 +245,7 @@ private function getIgnoredAnnotationNames(ReflectionClass $class)
/**
* Retrieves imports.
*
* @return array
* @return array<string, class-string>
*/
private function getClassImports(ReflectionClass $class)
{
Expand All @@ -259,7 +262,7 @@ private function getClassImports(ReflectionClass $class)
/**
* Retrieves imports for methods.
*
* @return array
* @return array<string, class-string>
*/
private function getMethodImports(ReflectionMethod $method)
{
Expand All @@ -285,7 +288,7 @@ private function getMethodImports(ReflectionMethod $method)
/**
* Retrieves imports for properties.
*
* @return array
* @return array<string, class-string>
*/
private function getPropertyImports(ReflectionProperty $property)
{
Expand Down
27 changes: 19 additions & 8 deletions lib/Doctrine/Common/Annotations/AnnotationRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public static function reset(): void
/**
* Registers file.
*
* @deprecated This method is deprecated and will be removed in doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
* @deprecated This method is deprecated and will be removed in
* doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
*/
public static function registerFile(string $file): void
{
Expand All @@ -73,9 +74,10 @@ public static function registerFile(string $file): void
*
* Loading of this namespaces will be done with a PSR-0 namespace loading algorithm.
*
* @deprecated This method is deprecated and will be removed in doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
* @deprecated This method is deprecated and will be removed in
* doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
*
* @param string|array|null $dirs
* @phpstan-param string|list<string>|null $dirs
*/
public static function registerAutoloadNamespace(string $namespace, $dirs = null): void
{
Expand All @@ -87,7 +89,8 @@ public static function registerAutoloadNamespace(string $namespace, $dirs = null
*
* Loading of this namespaces will be done with a PSR-0 namespace loading algorithm.
*
* @deprecated This method is deprecated and will be removed in doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
* @deprecated This method is deprecated and will be removed in
* doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
*
* @param string[][]|string[]|null[] $namespaces indexed by namespace name
*/
Expand All @@ -102,7 +105,8 @@ public static function registerAutoloadNamespaces(array $namespaces): void
* NOTE: These class loaders HAVE to be silent when a class was not found!
* IMPORTANT: Loaders have to return true if they loaded a class that could contain the searched annotation class.
*
* @deprecated This method is deprecated and will be removed in doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
* @deprecated This method is deprecated and will be removed in
* doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
*/
public static function registerLoader(callable $callable): void
{
Expand All @@ -114,7 +118,8 @@ public static function registerLoader(callable $callable): void
/**
* Registers an autoloading callable for annotations, if it is not already registered
*
* @deprecated This method is deprecated and will be removed in doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
* @deprecated This method is deprecated and will be removed in
* doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
*/
public static function registerUniqueLoader(callable $callable): void
{
Expand Down Expand Up @@ -146,7 +151,8 @@ public static function loadAnnotationClass(string $class): bool
$file = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';

if ($dirs === null) {
if ($path = stream_resolve_include_path($file)) {
$path = stream_resolve_include_path($file);
if ($path) {
require $path;

return true;
Expand All @@ -168,7 +174,12 @@ public static function loadAnnotationClass(string $class): bool
}
}

if (self::$loaders === [] && self::$autoloadNamespaces === [] && self::$registerFileUsed === false && class_exists($class)) {
if (
self::$loaders === [] &&
self::$autoloadNamespaces === [] &&
self::$registerFileUsed === false &&
class_exists($class)
) {
return true;
}

Expand Down
Loading

0 comments on commit 2dceb19

Please sign in to comment.