Skip to content

Commit 611a5bf

Browse files
authored
Merge pull request #14 from cycle/remove_instantiator_null_value
Remove null value for instantiator
2 parents fd8e7d5 + 30583a5 commit 611a5bf

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/Promise/ProxyFactory.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Cycle\ORM\Schema;
2121
use Doctrine\Instantiator\Exception\ExceptionInterface;
2222
use Doctrine\Instantiator\Instantiator;
23+
use Doctrine\Instantiator\InstantiatorInterface;
2324
use ReflectionClass;
2425
use ReflectionException;
2526
use Spiral\Core\Container\SingletonInterface;
@@ -38,7 +39,7 @@ final class ProxyFactory implements PromiseFactoryInterface, SingletonInterface
3839
/** @var Names */
3940
private $names;
4041

41-
/** @var Instantiator */
42+
/** @var InstantiatorInterface */
4243
private $instantiator;
4344

4445
/** @var array */
@@ -50,20 +51,20 @@ final class ProxyFactory implements PromiseFactoryInterface, SingletonInterface
5051
/**
5152
* @param Extractor $extractor
5253
* @param Printer $printer
53-
* @param Instantiator|null $instantiator
54+
* @param InstantiatorInterface|null $instantiator
5455
* @param MaterializerInterface|null $materializer
5556
* @param Names|null $names
5657
*/
5758
public function __construct(
5859
Extractor $extractor,
5960
Printer $printer,
60-
?Instantiator $instantiator = null,
61+
?InstantiatorInterface $instantiator = null,
6162
?MaterializerInterface $materializer = null,
6263
?Names $names = null
6364
) {
6465
$this->extractor = $extractor;
6566
$this->printer = $printer;
66-
$this->instantiator = $instantiator;
67+
$this->instantiator = $instantiator ?? new Instantiator();
6768
$this->materializer = $materializer ?? new EvalMaterializer();
6869
$this->names = $names ?? new Names();
6970
}

tests/Promise/FactoryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function testPromise(string $materializer, array $params): void
127127
public function testNullScope(string $materializer, array $params): void
128128
{
129129
$this->expectException(ProxyFactoryException::class);
130-
$this->expectExceptionMessageRegExp('/Method `\w+\(\)` not loaded for/');
130+
$this->expectExceptionMessageMatches('/Method `\w+\(\)` not loaded for/');
131131

132132
$role = SchematicEntity::class;
133133
$orm = $this->orm();
@@ -159,7 +159,7 @@ public function testNullScope(string $materializer, array $params): void
159159
public function testUnknownScope(string $materializer, array $params): void
160160
{
161161
$this->expectException(ProxyFactoryException::class);
162-
$this->expectExceptionMessageRegExp('/Method `\w+\(\)` not loaded for/');
162+
$this->expectExceptionMessageMatches('/Method `\w+\(\)` not loaded for/');
163163

164164
$role = SchematicEntity::class;
165165
$orm = $this->orm();
@@ -191,7 +191,7 @@ public function testUnknownScope(string $materializer, array $params): void
191191
public function testUnknownProperty(string $materializer, array $params): void
192192
{
193193
$this->expectException(ProxyFactoryException::class);
194-
$this->expectExceptionMessageRegExp('/Property `\w+` not loaded in `[_a-z]+\(\)` method for/');
194+
$this->expectExceptionMessageMatches('/Property `\w+` not loaded in `[_a-z]+\(\)` method for/');
195195

196196
$role = SchematicEntity::class;
197197
$orm = $this->orm();

0 commit comments

Comments
 (0)