mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 11:48:08 +08:00
parent
2e7256cb01
commit
0b659abea2
@ -33,7 +33,7 @@ class DefinitionSource implements DefinitionSourceInterface
|
||||
*/
|
||||
public function getDefinition(string $name): ?DefinitionInterface
|
||||
{
|
||||
return $this->source[$name] ?? $this->source[$name] = $this->autowire($name);
|
||||
return $this->source[$name] ??= $this->autowire($name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,11 +53,7 @@ class ObjectDefinition implements DefinitionInterface
|
||||
|
||||
public function getClassName(): string
|
||||
{
|
||||
if ($this->className !== null) {
|
||||
return $this->className;
|
||||
}
|
||||
|
||||
return $this->name;
|
||||
return $this->className ?? $this->name;
|
||||
}
|
||||
|
||||
public function isClassExists(): bool
|
||||
|
@ -29,7 +29,8 @@ class DefinitionSourceTest extends TestCase
|
||||
public function testGetDefinition()
|
||||
{
|
||||
$source = new DefinitionSource([]);
|
||||
$source->getDefinition(Bar::class);
|
||||
$bar = $source->getDefinition(Bar::class);
|
||||
$this->assertSame(1, count($source->getDefinitions()));
|
||||
$this->assertSame($bar, $source->getDefinition(Bar::class));
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class ChannelPool extends \SplQueue
|
||||
|
||||
public static function getInstance(): self
|
||||
{
|
||||
return static::$instance ?? (static::$instance = new self());
|
||||
return static::$instance ??= new self();
|
||||
}
|
||||
|
||||
public function get(): Channel
|
||||
|
Loading…
Reference in New Issue
Block a user