diff --git a/bin/graphql-client b/bin/graphql-client index 22f1da4..69f3c60 100755 --- a/bin/graphql-client +++ b/bin/graphql-client @@ -15,7 +15,16 @@ use Symfony\Component\Console\Application; $application = new Application(); -$application->add(new GenerateConfig()); -$application->add(new GetIntrospection()); +if (method_exists($application, 'add')) { + // Symfony Console ^6 + $application->add(new GenerateConfig()); + $application->add(new GetIntrospection()); +} + +if (method_exists($application, 'addCommand')) { + // Symfony Console ^7 and above + $application->addCommand(new GenerateConfig()); + $application->addCommand(new GetIntrospection()); +} $application->run(); diff --git a/composer.json b/composer.json index 8dab5f2..85cdd52 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "guzzlehttp/guzzle": "^6.3 || ^7.0", "softonic/guzzle-oauth2-middleware": "^2.1", "ext-json": "*", - "symfony/console": "^6.0 || ^7.0" + "symfony/console": "^6.0 || ^7.0 || ^8.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.9", diff --git a/src/Config/MutationTypeConfig.php b/src/Config/MutationTypeConfig.php index 9c65203..2befa70 100644 --- a/src/Config/MutationTypeConfig.php +++ b/src/Config/MutationTypeConfig.php @@ -23,7 +23,7 @@ class MutationTypeConfig */ public $children = []; - public function __get(string $propertyName) + public function __get(string $propertyName): mixed { if (property_exists(static::class, $propertyName)) { return $this->{$propertyName}; diff --git a/src/Console/Mutation/GenerateConfig.php b/src/Console/Mutation/GenerateConfig.php index 69f36ed..8badff1 100644 --- a/src/Console/Mutation/GenerateConfig.php +++ b/src/Console/Mutation/GenerateConfig.php @@ -28,7 +28,7 @@ class GenerateConfig extends Command */ private $fromSameMutation; - protected function configure() + protected function configure(): void { $this->setDescription('Creates a mutation config.') ->setHelp( diff --git a/src/Console/Mutation/GetIntrospection.php b/src/Console/Mutation/GetIntrospection.php index a4dd1d6..4438308 100644 --- a/src/Console/Mutation/GetIntrospection.php +++ b/src/Console/Mutation/GetIntrospection.php @@ -10,7 +10,7 @@ class GetIntrospection extends Command { protected static $defaultName = 'mutation:introspection'; - protected function configure() + protected function configure(): void { $this->setDescription('Returns a instrospection query.') ->setHelp('Returns the introspection query needed to execute in your GraphQL server in order ' . diff --git a/src/DataObjects/AbstractItem.php b/src/DataObjects/AbstractItem.php index 7242a4e..0ef46ea 100644 --- a/src/DataObjects/AbstractItem.php +++ b/src/DataObjects/AbstractItem.php @@ -34,12 +34,12 @@ public function has(string $key): bool return $this->arguments[$firstKey]->has($nextKey); } - public function __get(string $key) + public function __get(string $key): mixed { return $this->arguments[$key] ?? null; } - public function __set(string $key, $value): void + public function __set(string $key, mixed $value): void { $this->arguments[$key] = $value; } diff --git a/src/DataObjects/Mutation/Collection.php b/src/DataObjects/Mutation/Collection.php index 9c5ce8d..e5ea3af 100644 --- a/src/DataObjects/Mutation/Collection.php +++ b/src/DataObjects/Mutation/Collection.php @@ -21,7 +21,7 @@ public function add(array $itemData): MutationObject return $item; } - public function __unset($key): void + public function __unset(string $key): void { foreach ($this->arguments as $argument) { unset($argument->{$key}); diff --git a/src/DataObjects/Mutation/Item.php b/src/DataObjects/Mutation/Item.php index a01c94a..ca7436e 100644 --- a/src/DataObjects/Mutation/Item.php +++ b/src/DataObjects/Mutation/Item.php @@ -20,7 +20,7 @@ public function __construct(array $arguments = [], protected array $config = [], $this->hasChanged = $hasChanged; } - public function __get(string $key) + public function __get(string $key): mixed { if ((!array_key_exists($key, $this->arguments) || ($this->arguments[$key] === null)) && array_key_exists($key, $this->config) @@ -34,7 +34,7 @@ public function __get(string $key) return parent::__get($key); } - public function __set(string $key, $value): void + public function __set(string $key, mixed $value): void { if (!array_key_exists($key, $this->arguments) || $this->arguments[$key] !== $value) { $this->hasChanged = true;