Skip to content

Pass PHPStan for Laravel 12 #2674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Prev Previous commit
Next Next commit
Support 8.4 and pass "Cannot unset property Nuwave\Lighthouse\Schema\…
…Directives\BaseDirective::$directiveArgs because it might have hooks in a subclass."
  • Loading branch information
gabsource committed Mar 25, 2025
commit 05cf36600df14f151e60cab6963dfd585b805f7a
14 changes: 7 additions & 7 deletions src/Schema/Directives/BaseDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ abstract class BaseDirective implements Directive
*
* Lazily initialized.
*
* @var array<string, mixed>
* @var array<string, mixed>|null
*/
protected array $directiveArgs;
protected ?array $directiveArgs = null;

/** The hydrate function is called when retrieving a directive from the directive registry. */
public function hydrate(DirectiveNode $directiveNode, ScalarTypeDefinitionNode|ScalarTypeExtensionNode|ObjectTypeDefinitionNode|ObjectTypeExtensionNode|InterfaceTypeDefinitionNode|InterfaceTypeExtensionNode|UnionTypeDefinitionNode|UnionTypeExtensionNode|EnumTypeDefinitionNode|EnumTypeExtensionNode|InputObjectTypeDefinitionNode|InputObjectTypeExtensionNode|FieldDefinitionNode|InputValueDefinitionNode|EnumValueDefinitionNode $definitionNode): self
{
$this->directiveNode = $directiveNode;
$this->definitionNode = $definitionNode;

unset($this->directiveArgs);
$this->directiveArgs = null;

return $this;
}
Expand Down Expand Up @@ -110,11 +110,11 @@ public function getResolverFromArgument(string $argumentName): \Closure
*/
protected function directiveHasArgument(string $name): bool
{
if (! isset($this->directiveArgs)) {
if ($this->directiveArgs === null) {
$this->loadArgValues();
}

return array_key_exists($name, $this->directiveArgs);
return is_array($this->directiveArgs) && array_key_exists($name, $this->directiveArgs);
}

/**
Expand All @@ -128,11 +128,11 @@ protected function directiveHasArgument(string $name): bool
*/
protected function directiveArgValue(string $name, mixed $default = null): mixed
{
if (! isset($this->directiveArgs)) {
if ($this->directiveArgs === null) {
$this->loadArgValues();
}

return array_key_exists($name, $this->directiveArgs)
return is_array($this->directiveArgs) && array_key_exists($name, $this->directiveArgs)
? $this->directiveArgs[$name]
: $default;
}
Expand Down