TypePHP 编译器
https://swoole.com/aot/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
<?php
|
|
/**
|
|
* This file is part of TypePHP.
|
|
*
|
|
* @link https://www.swoole.com/
|
|
* @contact service@swoole.com
|
|
*/
|
|
|
|
namespace TypePhp\Resolver;
|
|
|
|
use PhpParser\NodeAbstract;
|
|
|
|
final readonly class PropertyWriteTarget
|
|
{
|
|
public function __construct(
|
|
public NodeAbstract $node,
|
|
public string $label,
|
|
private ?string $objectExpr = null,
|
|
private ?string $propertyExpr = null,
|
|
) {
|
|
}
|
|
|
|
public function isDynamicObjectProperty(): bool
|
|
{
|
|
return $this->objectExpr !== null && $this->propertyExpr !== null;
|
|
}
|
|
|
|
public function getDynamicObjectExpr(): string
|
|
{
|
|
if (!$this->isDynamicObjectProperty()) {
|
|
throw new \LogicException('Property write target is not a dynamic object property');
|
|
}
|
|
|
|
return $this->objectExpr;
|
|
}
|
|
|
|
public function getDynamicPropertyExpr(): string
|
|
{
|
|
if (!$this->isDynamicObjectProperty()) {
|
|
throw new \LogicException('Property write target is not a dynamic object property');
|
|
}
|
|
|
|
return $this->propertyExpr;
|
|
}
|
|
}
|
|
|