Skip to content

Commit

Permalink
Merge pull request #146 from doctrine/2.1.x
Browse files Browse the repository at this point in the history
Merge up 2.1.x into 2.2.x
  • Loading branch information
greg0ire authored Nov 27, 2020
2 parents 9899c16 + 6236bc2 commit 42d88e4
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 39 deletions.
18 changes: 12 additions & 6 deletions .doctrine-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,27 @@
"upcoming": true
},
{
"name": "2.1",
"branchName": "2.1.x",
"slug": "2.1",
"name": "2.2",
"branchName": "2.2.x",
"slug": "2.2",
"upcoming": true
},
{
"name": "2.0",
"branchName": "2.0.x",
"slug": "2.0",
"name": "2.1",
"branchName": "2.1.x",
"slug": "2.1",
"current": true,
"aliases": [
"current",
"stable"
]
},
{
"name": "2.0",
"branchName": "2.0.x",
"slug": "2.0",
"maintained": false
},
{
"name": "1.4",
"branchName": "1.4.x",
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ jobs:

- name: Psalm
uses: docker://vimeo/psalm-github-actions
with:
composer_require_dev: true
6 changes: 3 additions & 3 deletions lib/Doctrine/Common/Persistence/PersistentObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ private function get($field)
/**
* If this is an inverse side association, completes the owning side.
*
* @param string $field
* @param ClassMetadata $targetClass
* @param object $targetObject
* @param string $field
* @param string $targetClass
* @param object $targetObject
*
* @return void
*/
Expand Down
13 changes: 13 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
parameters:
ignoreErrors:
- "#^Call to an undefined method Doctrine\\\\Tests\\\\Persistence\\\\TestObject\\:\\:.+\\(\\)\\.$#"

-
message: "#^Method Doctrine\\\\Tests\\\\Persistence\\\\Mapping\\\\TestFileDriver\\:\\:loadMappingFile\\(\\) should return array\\<Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\> but returns array\\<string, string\\>\\.$#"
count: 2
path: tests/Doctrine/Tests/Persistence/Mapping/FileDriverTest.php

-
message: "#^Parameter \\#3 \\$nsSeparator of class Doctrine\\\\Persistence\\\\Mapping\\\\Driver\\\\SymfonyFileLocator constructor expects string, null given\\.$#"
count: 1
path: tests/Doctrine/Tests/Persistence/Mapping/SymfonyFileLocatorTest.php
8 changes: 4 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
includes:
- phpstan-baseline.neon

parameters:
level: 3
level: 5

paths:
- lib
- tests

excludes_analyse:
- %currentWorkingDirectory%/tests/Doctrine/Tests/Persistence/Mapping/_files/TestEntity.php
ignoreErrors:
- '#Call to an undefined method Doctrine\\Tests\\Persistence\\TestObject#'
- '#Method Doctrine\\Tests\\Persistence\\Mapping\\TestFileDriver\:\:loadMappingFile\(\) should return array\<Doctrine\\Persistence\\Mapping\\ClassMetadata\> but returns array\<string, string\>\.#'
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Persistence\Mapping\MappingException;
use Doctrine\Tests\DoctrineTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use stdClass;

use function assert;
use function is_callable;

/**
* @covers \Doctrine\Persistence\Mapping\AbstractClassMetadataFactory
Expand Down Expand Up @@ -142,7 +140,6 @@ public function testWillFailOnFallbackFailureWithNotLoadedMetadata(): void
public function testWillIgnoreCacheEntriesThatAreNotMetadataInstances(): void
{
$cacheDriver = $this->createMock(Cache::class);
assert($cacheDriver instanceof Cache || $cacheDriver instanceof MockObject);

$this->cmf->setCacheDriver($cacheDriver);

Expand All @@ -152,7 +149,6 @@ public function testWillIgnoreCacheEntriesThatAreNotMetadataInstances(): void
assert($metadata instanceof ClassMetadata);

$fallbackCallback = $this->getMockBuilder(stdClass::class)->setMethods(['__invoke'])->getMock();
assert($fallbackCallback instanceof MockObject || $fallbackCallback instanceof stdClass || is_callable($fallbackCallback));

$fallbackCallback->expects(self::any())->method('__invoke')->willReturn($metadata);

Expand Down
16 changes: 2 additions & 14 deletions tests/Doctrine/Tests/Persistence/Mapping/DriverChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,23 @@
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
use Doctrine\Persistence\Mapping\MappingException;
use Doctrine\Tests\DoctrineTestCase;
use PHPUnit\Framework\MockObject\MockObject;

use function assert;

class DriverChainTest extends DoctrineTestCase
{
public function testDelegateToMatchingNamespaceDriver(): void
{
$className = DriverChainEntity::class;
$classMetadata = $this->createMock(ClassMetadata::class);
assert($classMetadata instanceof ClassMetadata || $classMetadata instanceof MockObject);

$chain = new MappingDriverChain();

$driver1 = $this->createMock(MappingDriver::class);
assert($driver1 instanceof MappingDriver || $driver1 instanceof MockObject);
$driver1->expects($this->never())
->method('loadMetadataForClass');
$driver1->expectS($this->never())
->method('isTransient');

$driver2 = $this->createMock(MappingDriver::class);
assert($driver2 instanceof MappingDriver || $driver2 instanceof MockObject);
$driver2->expects($this->at(0))
->method('loadMetadataForClass')
->with($this->equalTo($className), $this->equalTo($classMetadata));
Expand All @@ -50,7 +44,6 @@ public function testLoadMetadataShouldThrowMappingExceptionWhenNoDelegatorWasFou
{
$className = DriverChainEntity::class;
$classMetadata = $this->createMock(ClassMetadata::class);
assert($classMetadata instanceof ClassMetadata || $classMetadata instanceof MockObject);

$chain = new MappingDriverChain();

Expand All @@ -63,13 +56,11 @@ public function testGatherAllClassNames(): void
$chain = new MappingDriverChain();

$driver1 = $this->createMock(MappingDriver::class);
assert($driver1 instanceof MappingDriver || $driver1 instanceof MockObject);
$driver1->expects($this->once())
->method('getAllClassNames')
->will($this->returnValue(['Doctrine\Tests\Models\Company\Foo']));

$driver2 = $this->createMock(MappingDriver::class);
assert($driver2 instanceof MappingDriver || $driver2 instanceof MockObject);
$driver2->expects($this->once())
->method('getAllClassNames')
->will($this->returnValue(['Doctrine\Tests\ORM\Mapping\Bar', 'Doctrine\Tests\ORM\Mapping\Baz', 'FooBarBaz']));
Expand All @@ -90,8 +81,7 @@ public function testGatherAllClassNames(): void
public function testIsTransient(): void
{
$driver1 = $this->createMock(MappingDriver::class);
assert($driver1 instanceof MappingDriver || $driver1 instanceof MockObject);
$chain = new MappingDriverChain();
$chain = new MappingDriverChain();
$chain->addDriver($driver1, 'Doctrine\Tests\Models\CMS');

self::assertTrue($chain->isTransient('stdClass'), 'stdClass isTransient');
Expand Down Expand Up @@ -136,10 +126,8 @@ public function testDefaultDriver(): void
public function testDefaultDriverGetAllClassNames(): void
{
$companyDriver = $this->createMock(MappingDriver::class);
assert($companyDriver instanceof MappingDriver || $companyDriver instanceof MockObject);
$defaultDriver = $this->createMock(MappingDriver::class);
assert($defaultDriver instanceof MappingDriver || $defaultDriver instanceof MockObject);
$chain = new MappingDriverChain();
$chain = new MappingDriverChain();

$companyDriver->expects($this->once())
->method('getAllClassNames')
Expand Down
3 changes: 3 additions & 0 deletions tests/Doctrine/Tests/Persistence/Mapping/FileDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ public function testNonLocatorFallback(): void
self::assertFalse($driver->isTransient('stdClass'));
}

/**
* @return MockObject&FileLocator
*/
private function newLocator(): MockObject
{
$locator = $this->createMock(FileLocator::class);
Expand Down
4 changes: 0 additions & 4 deletions tests/Doctrine/Tests/Persistence/Mapping/PHPDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
use Doctrine\Persistence\Mapping\ClassMetadata;
use Doctrine\Persistence\Mapping\Driver\PHPDriver;
use Doctrine\Tests\DoctrineTestCase;
use PHPUnit\Framework\MockObject\MockObject;

use function assert;

class PHPDriverTest extends DoctrineTestCase
{
public function testLoadMetadata(): void
{
$metadata = $this->createMock(ClassMetadata::class);
assert($metadata instanceof ClassMetadata || $metadata instanceof MockObject);
$metadata->expects($this->once())->method('getFieldNames');

$driver = new PHPDriver([__DIR__ . '/_files']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
use Doctrine\Persistence\Mapping\ClassMetadata;
use Doctrine\Persistence\Mapping\Driver\StaticPHPDriver;
use Doctrine\Tests\DoctrineTestCase;
use PHPUnit\Framework\MockObject\MockObject;

use function assert;

class StaticPHPDriverTest extends DoctrineTestCase
{
public function testLoadMetadata(): void
{
$metadata = $this->createMock(ClassMetadata::class);
assert($metadata instanceof ClassMetadata || $metadata instanceof MockObject);
$metadata->expects($this->once())->method('getFieldNames');

$driver = new StaticPHPDriver([__DIR__]);
Expand Down

0 comments on commit 42d88e4

Please sign in to comment.