mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-03 12:17:48 +08:00
Format code.
This commit is contained in:
parent
32e6b975d7
commit
07d2f1912d
@ -15,7 +15,6 @@ use Hyperf\Utils\Composer;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use PhpParser\NodeTraverser;
|
||||
use PhpParser\NodeVisitor\NameResolver;
|
||||
use PhpParser\ParserFactory;
|
||||
use PhpParser\PrettyPrinter\Standard;
|
||||
use PhpParser\PrettyPrinterAbstract;
|
||||
|
@ -11,8 +11,6 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Di\Aop;
|
||||
|
||||
use Hyperf\Utils\Traits\Container;
|
||||
|
||||
/**
|
||||
* @mixin \SplPriorityQueue
|
||||
*/
|
||||
@ -23,6 +21,15 @@ class AstVisitorRegistry
|
||||
*/
|
||||
protected static $queue;
|
||||
|
||||
public static function __callStatic($name, $arguments)
|
||||
{
|
||||
$queue = static::getQueue();
|
||||
if (method_exists($queue, $name)) {
|
||||
return $queue->{$name}(...$arguments);
|
||||
}
|
||||
throw new \InvalidArgumentException('Invalid method for ' . __CLASS__);
|
||||
}
|
||||
|
||||
public static function getQueue(): \SplPriorityQueue
|
||||
{
|
||||
if (! static::$queue instanceof \SplPriorityQueue) {
|
||||
@ -30,15 +37,4 @@ class AstVisitorRegistry
|
||||
}
|
||||
return static::$queue;
|
||||
}
|
||||
|
||||
public static function __callStatic($name, $arguments)
|
||||
{
|
||||
$queue = static::getQueue();
|
||||
if (method_exists($queue, $name)) {
|
||||
return $queue->$name(...$arguments);
|
||||
}
|
||||
throw new \InvalidArgumentException('Invalid method for ' . __CLASS__);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://doc.hyperf.io
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
namespace Hyperf\Di\Aop;
|
||||
|
||||
|
||||
use Hyperf\Di\Annotation\AnnotationCollector;
|
||||
use Hyperf\Di\BetterReflectionManager;
|
||||
use Hyperf\Di\Definition\PropertyHandlerManager;
|
||||
|
||||
trait PropertyHandlerTrait
|
||||
{
|
||||
|
||||
protected function __handlePropertyHandler(string $className)
|
||||
{
|
||||
$propertyHandlers = PropertyHandlerManager::all();
|
||||
@ -51,5 +58,4 @@ trait PropertyHandlerTrait
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,6 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Di\Aop;
|
||||
|
||||
use Hyperf\Di\Aop\VisitorMetadata;
|
||||
use Hyperf\Di\BetterReflectionManager;
|
||||
use Hyperf\Di\Inject\InjectTrait;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
@ -91,19 +89,19 @@ class PropertyHandlerVisitor extends NodeVisitorAbstract
|
||||
$left = new Node\Expr\FuncCall(new Name('get_parent_class'), [
|
||||
new Node\Arg(new Node\Expr\Variable('this')),
|
||||
]);
|
||||
$right = new Node\Expr\FuncCall(new Name('class_exists'), [
|
||||
$right = new Node\Expr\FuncCall(new Name('method_exists'), [
|
||||
new Node\Arg(new Node\Expr\ClassConstFetch(new Name('parent'), new Name('class'))),
|
||||
new Node\Arg(new Node\Scalar\String_('__construct')),
|
||||
], [
|
||||
]);
|
||||
return new Node\Stmt\If_(new Node\Expr\BinaryOp\BooleanAnd($left, $right), [
|
||||
'stmts' => [
|
||||
new Node\Stmt\Expression(new Node\Expr\StaticCall(new Name('parent'), '__construct'), [
|
||||
new Node\Arg(new Node\Expr\FuncCall('func_get_args', [], [
|
||||
new Node\Stmt\Expression(new Node\Expr\StaticCall(new Name('parent'), '__construct', [
|
||||
new Node\Arg(new Node\Expr\FuncCall(new Name('func_get_args'), [], [
|
||||
'unpack' => true,
|
||||
])),
|
||||
]),
|
||||
])),
|
||||
],
|
||||
]);
|
||||
return new Node\Stmt\If_(new Node\Expr\BinaryOp\BooleanAnd($left, $right));
|
||||
}
|
||||
|
||||
protected function buildStaticCallStatement(): Node\Stmt\Expression
|
||||
|
@ -30,6 +30,11 @@ use PhpParser\NodeVisitorAbstract;
|
||||
|
||||
class ProxyCallVisitor extends NodeVisitorAbstract
|
||||
{
|
||||
/**
|
||||
* @var \Hyperf\Di\Aop\VisitorMetadata
|
||||
*/
|
||||
protected $visitorMetadata;
|
||||
|
||||
/**
|
||||
* Determine if the class used proxy trait.
|
||||
*
|
||||
@ -57,11 +62,6 @@ class ProxyCallVisitor extends NodeVisitorAbstract
|
||||
*/
|
||||
private $extends;
|
||||
|
||||
/**
|
||||
* @var \Hyperf\Di\Aop\VisitorMetadata
|
||||
*/
|
||||
protected $visitorMetadata;
|
||||
|
||||
public function __construct(VisitorMetadata $visitorMetadata)
|
||||
{
|
||||
$this->visitorMetadata = $visitorMetadata;
|
||||
|
@ -1,28 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://doc.hyperf.io
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
namespace Hyperf\Di\Aop;
|
||||
|
||||
|
||||
class VisitorMetadata
|
||||
{
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->$name ?? null;
|
||||
return $this->{$name} ?? null;
|
||||
}
|
||||
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->$name = $value;
|
||||
$this->{$name} = $value;
|
||||
}
|
||||
|
||||
public function __isset($name)
|
||||
{
|
||||
return isset($this->$name);
|
||||
return isset($this->{$name});
|
||||
}
|
||||
|
||||
public function __unset($name)
|
||||
{
|
||||
unset($this->$name);
|
||||
unset($this->{$name});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,11 @@ namespace Hyperf\Di;
|
||||
|
||||
use Hyperf\Di\Annotation\AnnotationCollector;
|
||||
use Hyperf\Di\Annotation\AspectCollector;
|
||||
use Hyperf\Di\Annotation\InjectAspect;
|
||||
use Hyperf\Di\Aop\AstVisitorRegistry;
|
||||
use Hyperf\Di\Aop\PropertyHandlerVisitor;
|
||||
use Hyperf\Di\Aop\ProxyCallVisitor;
|
||||
use Hyperf\Di\Aop\RegisterInjectPropertyHandler;
|
||||
use Hyperf\Di\Annotation\InjectAspect;
|
||||
use Hyperf\Di\Inject\InjectVisitor;
|
||||
use Hyperf\Di\Listener\BootApplicationListener;
|
||||
|
||||
class ConfigProvider
|
||||
|
@ -27,5 +27,4 @@ interface DefinitionInterface
|
||||
* Set the name of the entry in the container.
|
||||
*/
|
||||
public function setName(string $name);
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Di\Definition;
|
||||
|
||||
use Hyperf\Di\Annotation\AnnotationCollector;
|
||||
use Hyperf\Di\ReflectionManager;
|
||||
use ReflectionFunctionAbstract;
|
||||
use function class_exists;
|
||||
|
@ -104,5 +104,4 @@ class ObjectResolver implements ResolverInterface
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user