-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
28 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,12 @@ | |
{ | ||
"name": "Robbert Beesems", | ||
"email": "[email protected]", | ||
"homepage": "https://omines.nl/" | ||
"homepage": "https://www.omines.nl/" | ||
}, | ||
{ | ||
"name": "Niels Keurentjes", | ||
"email": "[email protected]", | ||
"homepage": "https://omines.nl/" | ||
"homepage": "https://www.omines.nl/" | ||
} | ||
], | ||
"support": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
parameters: | ||
level: 6 | ||
level: 7 | ||
paths: | ||
- src | ||
excludePaths: | ||
# We're not really testing these 2 barely supported adapters | ||
- src/Adapter/Elasticsearch | ||
- src/Adapter/MongoDB | ||
|
||
# Fixture is messy | ||
- tests/Fixtures | ||
|
||
checkGenericClassInNonGenericObjectType: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,8 +45,7 @@ interface_exists(QueryBuilderProcessorInterface::class); | |
* @author Robbert Beesems <[email protected]> | ||
* | ||
* @phpstan-type HydrationMode AbstractQuery::HYDRATE_* | ||
* @phpstan-type Processor QueryBuilderProcessorInterface|QueryBuilderProcessorInterface[]|callable | ||
* @phpstan-type ORMOptions array{entity: class-string, hydrate: HydrationMode, query: Processor, criteria: Processor} | ||
* @phpstan-type ORMOptions array{entity: class-string, hydrate: HydrationMode, query: QueryBuilderProcessorInterface[], criteria: QueryBuilderProcessorInterface[]} | ||
*/ | ||
class ORMAdapter extends AbstractAdapter | ||
{ | ||
|
@@ -73,10 +72,15 @@ public function __construct(ManagerRegistry $registry = null) | |
$this->registry = $registry; | ||
} | ||
|
||
/** | ||
* @param array<string, mixed> $options | ||
*/ | ||
public function configure(array $options): void | ||
{ | ||
$resolver = new OptionsResolver(); | ||
$this->configureOptions($resolver); | ||
|
||
/** @var ORMOptions $options */ | ||
$options = $resolver->resolve($options); | ||
|
||
$this->afterConfiguration($options); | ||
|
@@ -126,6 +130,7 @@ protected function getAliases(AdapterQuery $query): array | |
|
||
/** @var Query\Expr\From $from */ | ||
foreach ($builder->getDQLPart('from') as $from) { | ||
/* @phpstan-ignore-next-line */ | ||
$aliases[$from->getAlias()] = [null, $this->manager->getMetadataFactory()->getMetadataFor($from->getFrom())]; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,16 +22,18 @@ | |
* The instantiator service handles lazy instantiation of services and/or ad hoc instantiation of objects. | ||
* | ||
* @author Niels Keurentjes <[email protected]> | ||
* | ||
* @phpstan-type SupportedTypes AdapterInterface|AbstractColumn|DataTableTypeInterface | ||
*/ | ||
class Instantiator | ||
{ | ||
/** @var ServiceLocator[] */ | ||
/** @var ServiceLocator<SupportedTypes>[] */ | ||
private array $locators; | ||
|
||
/** | ||
* Instantiator constructor. | ||
* | ||
* @param ServiceLocator[] $locators | ||
* @param ServiceLocator<SupportedTypes>[] $locators | ||
*/ | ||
public function __construct(array $locators = []) | ||
{ | ||
|
@@ -61,15 +63,16 @@ public function getType(string $type): DataTableTypeInterface | |
private function getInstance(string $type, string $baseType) | ||
{ | ||
if (isset($this->locators[$baseType]) && $this->locators[$baseType]->has($type)) { | ||
return $this->locators[$baseType]->get($type); | ||
} elseif (class_exists($type) && is_subclass_of($type, $baseType)) { | ||
$instance = $this->locators[$baseType]->get($type); | ||
} elseif (class_exists($type)) { | ||
$instance = new $type(); | ||
if (!$instance instanceof $baseType) { | ||
throw new InvalidArgumentException(sprintf('Class "%s" must implement/extend %s', $type, $baseType)); | ||
} | ||
|
||
return $instance; | ||
} else { | ||
throw new InvalidArgumentException(sprintf('Could not resolve type "%s" to a service or class, are you missing a use statement? Or is it implemented but does it not correctly derive from "%s"?', $type, $baseType)); | ||
} | ||
throw new InvalidArgumentException(sprintf('Could not resolve type "%s" to a service or class, are you missing a use statement? Or is it implemented but does it not correctly derive from "%s"?', $type, $baseType)); | ||
if (!$instance instanceof $baseType) { | ||
throw new InvalidArgumentException(sprintf('Class "%s" must implement/extend %s', $type, $baseType)); | ||
} | ||
|
||
return $instance; | ||
} | ||
} |