for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace GBProd\ElasticsearchDataProviderBundle\DataProvider;
/**
* Registry for DataProviders
*
* @author gbprod <[email protected]>
*/
class Registry
{
* @var array<DataProvider>
private $providers = [];
* Add a provider to the registry
* @param DataProvider $provider
* @param string $index
* @param string $type
public function addProvider(DataProvider $provider, $index, $type)
$this->providers[] = [
'provider' => $provider,
'index' => $index,
'type' => $type,
];
return $this;
}
* Get providers for index and type
$index
string|null
This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.
@param
It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.
$type
* @return array<DataProvider>
public function getProviders($index = null, $type = null)
$filteredProviders = $this->filter($index, $type);
return $this->mapProviders($filteredProviders);
private function filter($index, $type)
return array_filter(
$this->providers,
function ($providerData) use ($index, $type) {
return $this->match($providerData, $index, $type);
);
private function match($providerData, $index, $type)
return (null === $index && $type === null)
|| ($providerData['index'] == $index && $type === null)
|| ($providerData['index'] == $index && $providerData['type'] == $type)
;
private function mapProviders(array $providers)
return array_map(
function ($providerData) {
return $providerData['provider'];
},
$providers
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.