diff --git a/bin/schema b/bin/schema index 0a820ba6..c31ca8df 100755 --- a/bin/schema +++ b/bin/schema @@ -21,7 +21,7 @@ use ApiPlatform\SchemaGenerator\Command\DumpConfigurationCommand; use ApiPlatform\SchemaGenerator\Command\GenerateCommand; $application = new Application(); -$application->add(new ExtractCardinalitiesCommand()); -$application->add(new DumpConfigurationCommand()); -$application->add(new GenerateCommand()); +$application->addCommand(new ExtractCardinalitiesCommand()); +$application->addCommand(new DumpConfigurationCommand()); +$application->addCommand(new GenerateCommand()); $application->run(); diff --git a/phpstan.neon b/phpstan.neon index 53798508..06146e45 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -75,6 +75,3 @@ parameters: } ''' inferPrivatePropertyTypeFromConstructor: true - ignoreErrors: - # False positive - - '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)\.#' diff --git a/src/AttributeGenerator/ApiPlatformCoreAttributeGenerator.php b/src/AttributeGenerator/ApiPlatformCoreAttributeGenerator.php index b3df1a09..543157fd 100644 --- a/src/AttributeGenerator/ApiPlatformCoreAttributeGenerator.php +++ b/src/AttributeGenerator/ApiPlatformCoreAttributeGenerator.php @@ -148,6 +148,8 @@ private static function extractParameters(string $type, array $values): array ], [] ); + + // @phpstan-ignore-next-line if (isset(self::$parameterTypes[$type])) { $types = self::$parameterTypes[$type]; } else { diff --git a/src/Command/GenerateCommand.php b/src/Command/GenerateCommand.php index 40feae8b..4d0b6156 100644 --- a/src/Command/GenerateCommand.php +++ b/src/Command/GenerateCommand.php @@ -130,13 +130,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $configuration = $this->processConfiguration($configContent, $outputDir, $dir === $defaultOutput ? $this->namespacePrefix : null); (new SchemaGenerator())->generate($configuration, $output, $io); - (new OpenApiGenerator())->generate($configuration, $configArgument ?? self::DEFAULT_CONFIG_FILE, $output, $io); + (new OpenApiGenerator())->generate($configuration, $configArgument ?? self::DEFAULT_CONFIG_FILE, $output, $io); // @phpstan-ignore-line return Command::SUCCESS; } /** - * @return Configuration + * @return array */ private function processConfiguration(string $configContent, string $outputDir, ?string $defaultNamespacePrefix): array { @@ -146,7 +146,6 @@ private function processConfiguration(string $configContent, string $outputDir, $processor = new Processor(); $configuration = new SchemaGeneratorConfiguration($defaultNamespacePrefix); - /** @var Configuration $processedConfiguration */ $processedConfiguration = $processor->processConfiguration($configuration, [$config]); $processedConfiguration['output'] = $outputDir; if (!$processedConfiguration['output']) { diff --git a/src/OpenApi/Generator.php b/src/OpenApi/Generator.php index 929a933f..ceee8866 100644 --- a/src/OpenApi/Generator.php +++ b/src/OpenApi/Generator.php @@ -26,7 +26,7 @@ final class Generator { /** - * @param Configuration $configuration + * @param array $configuration */ public function generate(array $configuration, string $configurationPath, OutputInterface $output, SymfonyStyle $io): void { @@ -51,12 +51,12 @@ public function generate(array $configuration, string $configurationPath, Output $classGenerator = new ClassGenerator($inflector, new PhpTypeConverter()); $classGenerator->setLogger($logger); - $classes = $classGenerator->generate($openApi, $configuration); + $classes = $classGenerator->generate($openApi, $configuration); // @phpstan-ignore-line - $twig = (new TwigBuilder())->build($configuration); + $twig = (new TwigBuilder())->build($configuration); // @phpstan-ignore-line $filesGenerator = new FilesGenerator($inflector, new Printer(), $twig, $io); $filesGenerator->setLogger($logger); - $filesGenerator->generate($classes, $configuration); + $filesGenerator->generate($classes, $configuration); // @phpstan-ignore-line } } diff --git a/src/Schema/Generator.php b/src/Schema/Generator.php index 81b84a0e..5717c264 100644 --- a/src/Schema/Generator.php +++ b/src/Schema/Generator.php @@ -29,7 +29,7 @@ final class Generator { /** - * @param Configuration $configuration + * @param array $configuration */ public function generate(array $configuration, OutputInterface $output, SymfonyStyle $io): void { @@ -66,12 +66,12 @@ public function generate(array $configuration, OutputInterface $output, SymfonyS ); $entitiesGenerator->setLogger($logger); - $classes = $entitiesGenerator->generate($graphs, $configuration); + $classes = $entitiesGenerator->generate($graphs, $configuration); // @phpstan-ignore-line - $twig = (new TwigBuilder())->build($configuration); + $twig = (new TwigBuilder())->build($configuration); // @phpstan-ignore-line $filesGenerator = new FilesGenerator($inflector, new Printer(), $twig, $io); $filesGenerator->setLogger($logger); - $filesGenerator->generate($classes, $configuration); + $filesGenerator->generate($classes, $configuration); // @phpstan-ignore-line } } diff --git a/src/SchemaGeneratorConfiguration.php b/src/SchemaGeneratorConfiguration.php index 8ca95e16..8ea54d56 100644 --- a/src/SchemaGeneratorConfiguration.php +++ b/src/SchemaGeneratorConfiguration.php @@ -52,7 +52,6 @@ public function getConfigTreeBuilder(): TreeBuilder array_keys($nodeConfig) ); - // @phpstan-ignore-next-line node is not null $attributesNode = static fn () => (new NodeBuilder()) ->arrayNode('attributes') ->info('Attributes (merged with generated attributes)') diff --git a/src/TypesGenerator.php b/src/TypesGenerator.php index d42bf7f9..4b0a1189 100644 --- a/src/TypesGenerator.php +++ b/src/TypesGenerator.php @@ -174,6 +174,7 @@ public function generate(array $graphs, array $config): array ?? ($class->hasChild && !$class->isReferencedBy); // When including all properties, ignore properties already set on parent + // @phpstan-ignore-next-line if (($config['types'][$class->name()]['allProperties'] ?? true) && isset($classes[$class->parent()])) { $type = $class->resource(); foreach ($propertiesMap[$type->getUri()] as $property) {