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
Use empty array instead of null
  • Loading branch information
gabsource committed Mar 25, 2025
commit 7f5b4e865b4c1570591190ac2c0756574f7db1f5
14 changes: 7 additions & 7 deletions src/Schema/Directives/BaseDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ abstract class BaseDirective implements Directive
*
* Lazily initialized.
*
* @var array<string, mixed>|null
* @var array<string, mixed>
*/
protected ?array $directiveArgs = null;
protected array $directiveArgs;

/** 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;
$this->directiveArgs = null;
$this->directiveArgs = [];

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

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

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

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