From 9a81f0e2db5d5b9ead09f5b24f9821b8036eb41d Mon Sep 17 00:00:00 2001 From: patinthehat Date: Fri, 30 Jul 2021 00:30:00 +0000 Subject: [PATCH] Fix styling --- src/Results/Nodes/ClassMethodNode.php | 1 - src/Results/Nodes/ClassPropertyNode.php | 1 - src/Results/Nodes/FunctionCallNode.php | 2 -- src/Results/Nodes/FunctionDefinitionNode.php | 1 - src/Results/Nodes/Traits/BootsTraits.php | 5 +++-- src/Results/Nodes/Traits/HasVisibility.php | 6 ++++-- src/Support/Collections/Collection.php | 1 - src/Support/NameResolver.php | 2 +- 8 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Results/Nodes/ClassMethodNode.php b/src/Results/Nodes/ClassMethodNode.php index b5e75a7..ac6b383 100644 --- a/src/Results/Nodes/ClassMethodNode.php +++ b/src/Results/Nodes/ClassMethodNode.php @@ -2,7 +2,6 @@ namespace Permafrost\PhpCodeSearch\Results\Nodes; -use Permafrost\PhpCodeSearch\Code\GenericCodeLocation; use Permafrost\PhpCodeSearch\Results\Nodes\Traits\BootsTraits; use Permafrost\PhpCodeSearch\Results\Nodes\Traits\HasLocation; use Permafrost\PhpCodeSearch\Results\Nodes\Traits\HasName; diff --git a/src/Results/Nodes/ClassPropertyNode.php b/src/Results/Nodes/ClassPropertyNode.php index 6170f57..f0b965b 100644 --- a/src/Results/Nodes/ClassPropertyNode.php +++ b/src/Results/Nodes/ClassPropertyNode.php @@ -2,7 +2,6 @@ namespace Permafrost\PhpCodeSearch\Results\Nodes; -use Permafrost\PhpCodeSearch\Code\GenericCodeLocation; use Permafrost\PhpCodeSearch\Results\Nodes\Traits\BootsTraits; use Permafrost\PhpCodeSearch\Results\Nodes\Traits\HasLocation; use Permafrost\PhpCodeSearch\Results\Nodes\Traits\HasName; diff --git a/src/Results/Nodes/FunctionCallNode.php b/src/Results/Nodes/FunctionCallNode.php index 28d8205..3c4246f 100644 --- a/src/Results/Nodes/FunctionCallNode.php +++ b/src/Results/Nodes/FunctionCallNode.php @@ -2,11 +2,9 @@ namespace Permafrost\PhpCodeSearch\Results\Nodes; -use Permafrost\PhpCodeSearch\Code\GenericCodeLocation; use Permafrost\PhpCodeSearch\Results\Nodes\Traits\BootsTraits; use Permafrost\PhpCodeSearch\Results\Nodes\Traits\HasLocation; use Permafrost\PhpCodeSearch\Results\Nodes\Traits\HasName; -use Permafrost\PhpCodeSearch\Results\Nodes\Traits\TransformsArguments; use Permafrost\PhpCodeSearch\Support\ExpressionTransformer; use PhpParser\Node; diff --git a/src/Results/Nodes/FunctionDefinitionNode.php b/src/Results/Nodes/FunctionDefinitionNode.php index bee9209..f7dd489 100644 --- a/src/Results/Nodes/FunctionDefinitionNode.php +++ b/src/Results/Nodes/FunctionDefinitionNode.php @@ -2,7 +2,6 @@ namespace Permafrost\PhpCodeSearch\Results\Nodes; -use Permafrost\PhpCodeSearch\Code\GenericCodeLocation; use Permafrost\PhpCodeSearch\Results\Nodes\Traits\BootsTraits; use Permafrost\PhpCodeSearch\Results\Nodes\Traits\HasLocation; use Permafrost\PhpCodeSearch\Results\Nodes\Traits\HasName; diff --git a/src/Results/Nodes/Traits/BootsTraits.php b/src/Results/Nodes/Traits/BootsTraits.php index da7e7d5..3e7fbf1 100644 --- a/src/Results/Nodes/Traits/BootsTraits.php +++ b/src/Results/Nodes/Traits/BootsTraits.php @@ -11,14 +11,15 @@ protected function bootTraits($node): void $reflectionObject = new \ReflectionObject($this); collect($reflectionObject->getTraitNames()) - ->map(function(string $name){ + ->map(function (string $name) { if (strpos($name, __NAMESPACE__) === false) { return null; } + return Arr::last(explode('\\', $name)); }) ->filter() - ->each(function(string $name) use ($node) { + ->each(function (string $name) use ($node) { $bootMethodName = 'boot'.$name; if (method_exists($this, $bootMethodName)) { diff --git a/src/Results/Nodes/Traits/HasVisibility.php b/src/Results/Nodes/Traits/HasVisibility.php index 6a3c9ed..7843095 100644 --- a/src/Results/Nodes/Traits/HasVisibility.php +++ b/src/Results/Nodes/Traits/HasVisibility.php @@ -2,7 +2,8 @@ namespace Permafrost\PhpCodeSearch\Results\Nodes\Traits; -trait HasVisibility { +trait HasVisibility +{ /** @var string */ public $visibility = 'unknown'; @@ -20,9 +21,10 @@ protected function initVisibilityAttribute($node): void 'isProtected' => 'protected', ]; - foreach($visibilityMap as $method => $visibility) { + foreach ($visibilityMap as $method => $visibility) { if ($node->$method()) { $this->visibility = $visibility; + return; } } diff --git a/src/Support/Collections/Collection.php b/src/Support/Collections/Collection.php index ef73ee8..25459f4 100644 --- a/src/Support/Collections/Collection.php +++ b/src/Support/Collections/Collection.php @@ -58,7 +58,6 @@ public function first(callable $callback = null, $default = null) return Arr::first($this->items, $callback, $default); } - public function get($key, $default = null) { if (array_key_exists($key, $this->items)) { diff --git a/src/Support/NameResolver.php b/src/Support/NameResolver.php index a44cf1b..62693f2 100644 --- a/src/Support/NameResolver.php +++ b/src/Support/NameResolver.php @@ -64,7 +64,7 @@ public static function resolve($node) public static function resolveAll(array $nodes): array { - return collect($nodes)->each(function($node) { + return collect($nodes)->each(function ($node) { return self::resolve($node); })->filter()->all(); }