Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.2.x' into 2.2.x-merge-up-into-…
Browse files Browse the repository at this point in the history
…3.0.x_60a019593b1c08.06542033
  • Loading branch information
greg0ire committed May 16, 2021
2 parents a38ed90 + 93bb1cb commit 634f836
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 21 deletions.
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Circular dependency

This package has a development dependency on `doctrine/common`, which has a
regular dependency on this package (`^2.0` at the time of writing).

To be able to use Composer, one has to let it understand that this is version 2
(even when developing on 3.0.x), as follows:

```shell
COMPOSER_ROOT_VERSION=2.0 composer update -v
```
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
*/
class LoadClassMetadataEventArgs extends EventArgs
{
/** @psalm-var ClassMetadata<object> */
/**
* @var ClassMetadata
* @psalm-var ClassMetadata<object>
*/
private $classMetadata;

/** @var ObjectManager */
Expand All @@ -31,6 +34,7 @@ public function __construct(ClassMetadata $classMetadata, ObjectManager $objectM
/**
* Retrieves the associated ClassMetadata.
*
* @return ClassMetadata
* @psalm-return ClassMetadata<object>
*/
public function getClassMetadata()
Expand Down
8 changes: 3 additions & 5 deletions lib/Doctrine/Persistence/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use function in_array;
use function is_array;
use function is_dir;
use function is_string;
use function preg_match;
use function preg_quote;
use function realpath;
Expand Down Expand Up @@ -235,10 +234,9 @@ public function getAllClassNames()
}

foreach ($this->excludePaths as $excludePath) {
$realpath = realpath($excludePath);
assert(is_string($realpath));

$exclude = str_replace('\\', '/', $realpath);
$realExcludePath = realpath($excludePath);
assert($realExcludePath !== false);
$exclude = str_replace('\\', '/', $realExcludePath);
$current = str_replace('\\', '/', $sourceFile);

if (strpos($current, $exclude) !== false) {
Expand Down
8 changes: 6 additions & 2 deletions lib/Doctrine/Persistence/Mapping/Driver/FileDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ abstract class FileDriver implements MappingDriver
/** @var FileLocator */
protected $locator;

/** @psalm-var ClassMetadata<object>[]|null */
/**
* @var ClassMetadata[]|null
* @psalm-var ClassMetadata<object>[]|null
*/
protected $classCache;

/** @var string */
Expand Down Expand Up @@ -72,7 +75,8 @@ public function getGlobalBasename()
* Gets the element of schema meta data for the class from the mapping file.
* This will lazily load the mapping file if it is not loaded yet.
*
* @psalm-return ClassMetadata<object> The element of schema meta data.
* @return ClassMetadata The element of schema meta data.
* @psalm-return ClassMetadata<object>
*
* @throws MappingException
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Persistence/Mapping/Driver/MappingDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface MappingDriver
/**
* Loads the metadata for the specified class into the provided container.
*
* @param ClassMetadata<object> $metadata
* @psalm-param ClassMetadata<object> $metadata
*
* @return void
*/
Expand Down
5 changes: 4 additions & 1 deletion lib/Doctrine/Persistence/Mapping/Driver/PHPDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
*/
class PHPDriver extends FileDriver
{
/** @var ClassMetadata<object> */
/**
* @var ClassMetadata
* @psalm-var ClassMetadata<object>
*/
protected $metadata;

/**
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/Persistence/Mapping/ReflectionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public function getClassNamespace(string $class);
*
* @psalm-param class-string<T> $class
*
* @return ReflectionClass<T>|null
* @return ReflectionClass|null
* @psalm-return ReflectionClass<T>|null
*
* @template T of object
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public function getClassNamespace(string $class)
/**
* @psalm-param class-string<T> $class
*
* @return ReflectionClass<T>
* @return ReflectionClass
* @psalm-return ReflectionClass<T>
*
* @template T of object
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function getValue($object = null)
* @link https://bugs.php.net/bug.php?id=63463
*
* @param object|null $object
* @param mixed $value
*/
public function setValue($object, $value = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class TypedNoDefaultReflectionProperty extends ReflectionProperty
* Checks that a typed property is initialized before accessing its value.
* This is necessary to avoid PHP error "Error: Typed property must not be accessed before initialization".
* Should be used only for reflecting typed properties without a default value.
*
* @param object|null $object
*/
public function getValue($object = null)
{
Expand All @@ -45,6 +47,7 @@ public function setValue($object, $value = null)
unset($this->$propertyName);
};
$unsetter = $unsetter->bindTo($object, $this->getDeclaringClass()->getName());
assert($unsetter instanceof Closure);

$unsetter();

Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ parameters:
- tests

excludes_analyse:
- %currentWorkingDirectory%/tests/Doctrine/Tests/Persistence/Mapping/_files/TestEntity.php
- tests/Doctrine/Tests/Persistence/Mapping/_files/TestEntity.php

ignoreErrors:
- '#Variable property access on \$this\(Doctrine\\Persistence\\Reflection\\TypedNoDefaultReflectionProperty\)\.#'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@
*/
class ClassMetadataFactoryTest extends DoctrineTestCase
{
/** @var TestClassMetadataFactory<ClassMetadata<object>> */
/**
* @var TestClassMetadataFactory
* @psalm-var TestClassMetadataFactory<ClassMetadata<object>>
*/
private $cmf;

protected function setUp(): void
{
$driver = $this->createMock(MappingDriver::class);
$driver = $this->createMock(MappingDriver::class);

/** @psalm-var ClassMetadata<object> */
$metadata = $this->createMock(ClassMetadata::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,11 @@ public function getReflectionClass(): ReflectionClass
return new ReflectionClass($this->getName());
}

/**
* {@inheritDoc}
*/
public function isIdentifier(string $fieldName): bool
{
return false;
}

/**
* {@inheritDoc}
*/
public function hasField(string $fieldName): bool
{
return false;
Expand Down

0 comments on commit 634f836

Please sign in to comment.