optimize syntax (#4931)

Co-authored-by: 李铭昕 <715557344@qq.com>
This commit is contained in:
张城铭 2022-07-17 21:38:21 +08:00 committed by GitHub
parent 2e7256cb01
commit 0b659abea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 8 deletions

View File

@ -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);
}
/**

View File

@ -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

View File

@ -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));
}
}

View File

@ -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