Skip to content

Commit 9e2cd91

Browse files
committed
QA: fixes
1 parent e577d2a commit 9e2cd91

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

src/Mapping/ContainerEntityListenerResolver.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Doctrine\ORM\Mapping\EntityListenerResolver;
66
use Nette\DI\Container;
7-
use Nettrine\ORM\Exception\Logical\InvalidArgumentException;
87

98
class ContainerEntityListenerResolver implements EntityListenerResolver
109
{
@@ -38,12 +37,8 @@ public function clear($className = null): void
3837
/**
3938
* {@inheritDoc}
4039
*/
41-
public function register(mixed $object): void
40+
public function register($object): void
4241
{
43-
if (!is_object($object)) {
44-
throw new InvalidArgumentException(sprintf('An object was expected, but got "%s".', gettype($object)));
45-
}
46-
4742
$this->instances[$object::class] = $object;
4843
}
4944

@@ -52,6 +47,7 @@ public function register(mixed $object): void
5247
*/
5348
public function resolve($className): object
5449
{
50+
/** @var class-string<object> $className */
5551
$className = trim($className, '\\');
5652

5753
if (isset($this->instances[$className])) {
@@ -60,7 +56,7 @@ public function resolve($className): object
6056

6157
$service = $this->container->getByType($className, false);
6258

63-
$this->instances[$className] = $service ?: new $className();
59+
$this->instances[$className] = $service ?? new $className();
6460

6561
return $this->instances[$className];
6662
}

tests/Cases/DI/OrmExtensionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php declare(strict_types = 1);
22

3+
use Contributte\Tester\Toolkit;
34
use Doctrine\ORM\Decorator\EntityManagerDecorator;
45
use Nette\DI\Compiler;
56
use Nettrine\ORM\Exception\Logical\InvalidArgumentException;
6-
use Contributte\Tester\Toolkit;
77
use Tester\Assert;
88
use Tests\Fixtures\Dummy\DummyConfiguration;
99
use Tests\Fixtures\Dummy\DummyEntityManagerDecorator;

tests/Cases/DI/OrmXmlExtensionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php declare(strict_types = 1);
22

3+
use Contributte\Tester\Toolkit;
34
use Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver;
45
use Doctrine\ORM\Mapping\Driver\XmlDriver;
56
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
67
use Nette\DI\Compiler;
78
use Nette\DI\InvalidConfigurationException;
89
use Nettrine\ORM\DI\OrmXmlExtension;
9-
use Contributte\Tester\Toolkit;
1010
use Tester\Assert;
1111
use Tests\Toolkit\Container;
1212
use Tests\Toolkit\Helpers;

0 commit comments

Comments
 (0)