use of null coalescing operator
parent
6a36828069
commit
e34d8e15dd
|
@ -136,7 +136,7 @@ class Index implements ReadableIndex, \Serializable
|
||||||
*/
|
*/
|
||||||
public function getDefinitionsForNamespace(string $namespace): \Generator
|
public function getDefinitionsForNamespace(string $namespace): \Generator
|
||||||
{
|
{
|
||||||
foreach ($this->doGetDefinitionsForNamespace($namespace) as $fqn => $definition) {
|
foreach ($this->namespaceDefinitions[$namespace] ?? [] as $fqn => $definition) {
|
||||||
yield $fqn => $definition;
|
yield $fqn => $definition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ class Index implements ReadableIndex, \Serializable
|
||||||
public function getDefinition(string $fqn, bool $globalFallback = false)
|
public function getDefinition(string $fqn, bool $globalFallback = false)
|
||||||
{
|
{
|
||||||
$namespace = $this->extractNamespace($fqn);
|
$namespace = $this->extractNamespace($fqn);
|
||||||
$definitions = $this->doGetDefinitionsForNamespace($namespace);
|
$definitions = $this->namespaceDefinitions[$namespace] ?? [];
|
||||||
|
|
||||||
if (isset($definitions[$fqn])) {
|
if (isset($definitions[$fqn])) {
|
||||||
return $definitions[$fqn];
|
return $definitions[$fqn];
|
||||||
|
@ -213,12 +213,7 @@ class Index implements ReadableIndex, \Serializable
|
||||||
*/
|
*/
|
||||||
public function getReferenceUris(string $fqn): \Generator
|
public function getReferenceUris(string $fqn): \Generator
|
||||||
{
|
{
|
||||||
$uris = isset($this->references[$fqn])
|
foreach ($this->references[$fqn] ?? [] as $uri) {
|
||||||
? $this->references[$fqn]
|
|
||||||
: []
|
|
||||||
;
|
|
||||||
|
|
||||||
foreach ($uris as $uri) {
|
|
||||||
yield $uri;
|
yield $uri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,18 +326,4 @@ class Index implements ReadableIndex, \Serializable
|
||||||
|
|
||||||
return $fqn;
|
return $fqn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Definitions that are in the given namespace
|
|
||||||
*
|
|
||||||
* @param string $namespace
|
|
||||||
* @return Definition[]
|
|
||||||
*/
|
|
||||||
private function doGetDefinitionsForNamespace(string $namespace): array
|
|
||||||
{
|
|
||||||
return isset($this->namespaceDefinitions[$namespace])
|
|
||||||
? $this->namespaceDefinitions[$namespace]
|
|
||||||
: []
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue