From 4cf9522c6e3a31e7a96e78c631a9f727206578d3 Mon Sep 17 00:00:00 2001 From: d3fk Date: Fri, 8 Dec 2023 13:13:14 +0000 Subject: [PATCH] CS fix --- src/Command/ExtractCardinalitiesCommand.php | 2 +- src/Schema/Generator.php | 2 +- .../PropertyGenerator/PropertyGenerator.php | 2 +- src/Schema/Rdf/RdfResource.php | 21 +++++----- src/TypesGenerator.php | 2 +- .../PhpDocAnnotationGeneratorTest.php | 2 +- .../ApiPlatformCoreAttributeGeneratorTest.php | 2 +- .../ConfigurationAttributeGeneratorTest.php | 2 +- .../ConstraintAttributeGeneratorTest.php | 2 +- .../DoctrineMongoDBAttributeGeneratorTest.php | 4 +- ...ociationOverrideAttributeGeneratorTest.php | 2 +- .../DoctrineOrmAttributeGeneratorTest.php | 4 +- tests/ClassMutator/ClassParentMutatorTest.php | 2 +- .../ClassPropertiesAppenderTest.php | 4 +- tests/Schema/Model/ClassTest.php | 2 +- tests/Schema/Rdf/RdfResourceTest.php | 42 +++++++++---------- tests/TypesGeneratorTest.php | 2 +- 17 files changed, 50 insertions(+), 49 deletions(-) diff --git a/src/Command/ExtractCardinalitiesCommand.php b/src/Command/ExtractCardinalitiesCommand.php index 31b16bf2..fbb6c971 100644 --- a/src/Command/ExtractCardinalitiesCommand.php +++ b/src/Command/ExtractCardinalitiesCommand.php @@ -15,8 +15,8 @@ use ApiPlatform\SchemaGenerator\CardinalitiesExtractor; use ApiPlatform\SchemaGenerator\GoodRelationsBridge; -use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; +use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; diff --git a/src/Schema/Generator.php b/src/Schema/Generator.php index da1db98f..93fbbc1d 100644 --- a/src/Schema/Generator.php +++ b/src/Schema/Generator.php @@ -18,9 +18,9 @@ use ApiPlatform\SchemaGenerator\GoodRelationsBridge; use ApiPlatform\SchemaGenerator\PhpTypeConverter; use ApiPlatform\SchemaGenerator\Printer; +use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use ApiPlatform\SchemaGenerator\TwigBuilder; use ApiPlatform\SchemaGenerator\TypesGenerator; -use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use Symfony\Component\Console\Logger\ConsoleLogger; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; diff --git a/src/Schema/PropertyGenerator/PropertyGenerator.php b/src/Schema/PropertyGenerator/PropertyGenerator.php index 6991d555..e22f47db 100644 --- a/src/Schema/PropertyGenerator/PropertyGenerator.php +++ b/src/Schema/PropertyGenerator/PropertyGenerator.php @@ -23,8 +23,8 @@ use ApiPlatform\SchemaGenerator\PropertyGenerator\PropertyGeneratorInterface; use ApiPlatform\SchemaGenerator\Schema\Model\Property as SchemaProperty; use ApiPlatform\SchemaGenerator\Schema\Model\Type\PrimitiveType; -use ApiPlatform\SchemaGenerator\Schema\TypeConverter; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource; +use ApiPlatform\SchemaGenerator\Schema\TypeConverter; use Psr\Log\LoggerAwareTrait; final class PropertyGenerator implements PropertyGeneratorInterface diff --git a/src/Schema/Rdf/RdfResource.php b/src/Schema/Rdf/RdfResource.php index 17a9d108..432515c4 100644 --- a/src/Schema/Rdf/RdfResource.php +++ b/src/Schema/Rdf/RdfResource.php @@ -41,7 +41,7 @@ class RdfResource implements \ArrayAccess * * @param EasyRdfGraph|RdfGraph|null $graph */ - public function __construct(?string $uri, $graph = null, ?EasyRdfResource $resource = null) + public function __construct(?string $uri, $graph = null, EasyRdfResource $resource = null) { $graph = ($graph instanceof RdfGraph) ? $graph->getEasyGraph() : $graph; $this->resource = $resource ?? new EasyRdfResource($uri, $graph); @@ -174,7 +174,7 @@ public function localId(): ?string * Returns the label of the resource in the given language with given style * or make use of the default label if none exists in the defined language. */ - private function labelAsName(?string $language, ?string $namingConvention = null): ?string + private function labelAsName(?string $language, string $namingConvention = null): ?string { // English is the default language, forseeing graphs with several ones. $language = $language ?: 'en'; @@ -185,18 +185,19 @@ private function labelAsName(?string $language, ?string $namingConvention = null return $label ? u($label->getValue())->snake()->__toString() : ($defaultLabel ? u($defaultLabel->getValue())->snake()->__toString() : null); } + // default is camel case style as with schema.org return $label ? u($label->getValue())->camel()->__toString() : ($defaultLabel ? u($defaultLabel->getValue())->camel()->__toString() : null); } - /** - * Gets the graph related to this resource as a Schema Generator's RdfGraph. - */ - public function getGraph(): ?RdfGraph - { - return ($this->hasGraph()) ? RdfGraph::fromEasyRdf($this->resource->getGraph()) : null; - } + /** + * Gets the graph related to this resource as a Schema Generator's RdfGraph. + */ + public function getGraph(): ?RdfGraph + { + return ($this->hasGraph()) ? RdfGraph::fromEasyRdf($this->resource->getGraph()) : null; + } /** * Returns true if the current RdfResource belongs to a graph. @@ -405,7 +406,7 @@ public function offsetExists($offset): bool /** * Array Access Interface: perform get at using array syntax. * - * @return mixed Can return all value types. + * @return mixed can return all value types */ #[\ReturnTypeWillChange] public function offsetGet($offset) diff --git a/src/TypesGenerator.php b/src/TypesGenerator.php index 8c781cc7..96fabf63 100644 --- a/src/TypesGenerator.php +++ b/src/TypesGenerator.php @@ -28,9 +28,9 @@ use ApiPlatform\SchemaGenerator\Schema\Model\Property as SchemaProperty; use ApiPlatform\SchemaGenerator\Schema\PropertyGenerator\IdPropertyGenerator; use ApiPlatform\SchemaGenerator\Schema\PropertyGenerator\PropertyGenerator; -use ApiPlatform\SchemaGenerator\Schema\TypeConverter; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource; +use ApiPlatform\SchemaGenerator\Schema\TypeConverter; use ApiPlatform\SchemaGenerator\SchemaGeneratorConfigurationHolder as Config; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; diff --git a/tests/AnnotationGenerator/PhpDocAnnotationGeneratorTest.php b/tests/AnnotationGenerator/PhpDocAnnotationGeneratorTest.php index a092525d..10c7b39b 100644 --- a/tests/AnnotationGenerator/PhpDocAnnotationGeneratorTest.php +++ b/tests/AnnotationGenerator/PhpDocAnnotationGeneratorTest.php @@ -22,9 +22,9 @@ use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass; use ApiPlatform\SchemaGenerator\Schema\Model\Property as SchemaProperty; use ApiPlatform\SchemaGenerator\Schema\Model\Type\PrimitiveType as SchemaPrimitiveType; -use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource; +use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\String\Inflector\EnglishInflector; diff --git a/tests/AttributeGenerator/ApiPlatformCoreAttributeGeneratorTest.php b/tests/AttributeGenerator/ApiPlatformCoreAttributeGeneratorTest.php index 54ddcef4..385a0a93 100644 --- a/tests/AttributeGenerator/ApiPlatformCoreAttributeGeneratorTest.php +++ b/tests/AttributeGenerator/ApiPlatformCoreAttributeGeneratorTest.php @@ -29,9 +29,9 @@ use ApiPlatform\SchemaGenerator\PhpTypeConverter; use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass; use ApiPlatform\SchemaGenerator\Schema\Model\Property; -use ApiPlatform\SchemaGenerator\TypesGenerator; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource; +use ApiPlatform\SchemaGenerator\TypesGenerator; use Nette\PhpGenerator\Literal; use PHPUnit\Framework\TestCase; use Symfony\Component\String\Inflector\EnglishInflector; diff --git a/tests/AttributeGenerator/ConfigurationAttributeGeneratorTest.php b/tests/AttributeGenerator/ConfigurationAttributeGeneratorTest.php index 90b2f304..4c70f6d7 100644 --- a/tests/AttributeGenerator/ConfigurationAttributeGeneratorTest.php +++ b/tests/AttributeGenerator/ConfigurationAttributeGeneratorTest.php @@ -19,9 +19,9 @@ use ApiPlatform\SchemaGenerator\PhpTypeConverter; use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass; use ApiPlatform\SchemaGenerator\Schema\Model\Property; -use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource; +use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use PHPUnit\Framework\TestCase; use Symfony\Component\String\Inflector\EnglishInflector; diff --git a/tests/AttributeGenerator/ConstraintAttributeGeneratorTest.php b/tests/AttributeGenerator/ConstraintAttributeGeneratorTest.php index 804ae589..ca1a3c21 100644 --- a/tests/AttributeGenerator/ConstraintAttributeGeneratorTest.php +++ b/tests/AttributeGenerator/ConstraintAttributeGeneratorTest.php @@ -21,9 +21,9 @@ use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass; use ApiPlatform\SchemaGenerator\Schema\Model\Property; use ApiPlatform\SchemaGenerator\Schema\Model\Type\PrimitiveType as SchemaPrimitiveType; -use ApiPlatform\SchemaGenerator\TypesGenerator; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource; +use ApiPlatform\SchemaGenerator\TypesGenerator; use Nette\PhpGenerator\Literal; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; diff --git a/tests/AttributeGenerator/DoctrineMongoDBAttributeGeneratorTest.php b/tests/AttributeGenerator/DoctrineMongoDBAttributeGeneratorTest.php index bb096577..c5aaa131 100644 --- a/tests/AttributeGenerator/DoctrineMongoDBAttributeGeneratorTest.php +++ b/tests/AttributeGenerator/DoctrineMongoDBAttributeGeneratorTest.php @@ -21,10 +21,10 @@ use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass; use ApiPlatform\SchemaGenerator\Schema\Model\Property; use ApiPlatform\SchemaGenerator\Schema\Model\Type\PrimitiveType as SchemaPrimitiveType; -use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; -use ApiPlatform\SchemaGenerator\TypesGenerator; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource; +use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; +use ApiPlatform\SchemaGenerator\TypesGenerator; use Nette\PhpGenerator\Literal; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Processor; diff --git a/tests/AttributeGenerator/DoctrineOrmAssociationOverrideAttributeGeneratorTest.php b/tests/AttributeGenerator/DoctrineOrmAssociationOverrideAttributeGeneratorTest.php index e6cbdecb..2cb50353 100644 --- a/tests/AttributeGenerator/DoctrineOrmAssociationOverrideAttributeGeneratorTest.php +++ b/tests/AttributeGenerator/DoctrineOrmAssociationOverrideAttributeGeneratorTest.php @@ -18,9 +18,9 @@ use ApiPlatform\SchemaGenerator\PhpTypeConverter; use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass; use ApiPlatform\SchemaGenerator\Schema\Model\Property; -use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource; +use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use Nette\PhpGenerator\Literal; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Processor; diff --git a/tests/AttributeGenerator/DoctrineOrmAttributeGeneratorTest.php b/tests/AttributeGenerator/DoctrineOrmAttributeGeneratorTest.php index d460a991..2abdb1fe 100644 --- a/tests/AttributeGenerator/DoctrineOrmAttributeGeneratorTest.php +++ b/tests/AttributeGenerator/DoctrineOrmAttributeGeneratorTest.php @@ -21,10 +21,10 @@ use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass; use ApiPlatform\SchemaGenerator\Schema\Model\Property; use ApiPlatform\SchemaGenerator\Schema\Model\Type\PrimitiveType as SchemaPrimitiveType; -use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; -use ApiPlatform\SchemaGenerator\TypesGenerator; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource; +use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; +use ApiPlatform\SchemaGenerator\TypesGenerator; use Nette\PhpGenerator\Literal; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Processor; diff --git a/tests/ClassMutator/ClassParentMutatorTest.php b/tests/ClassMutator/ClassParentMutatorTest.php index be3ec016..8bce0f48 100644 --- a/tests/ClassMutator/ClassParentMutatorTest.php +++ b/tests/ClassMutator/ClassParentMutatorTest.php @@ -17,9 +17,9 @@ use ApiPlatform\SchemaGenerator\Model\Use_; use ApiPlatform\SchemaGenerator\PhpTypeConverter; use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass; -use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource; +use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; diff --git a/tests/ClassMutator/ClassPropertiesAppenderTest.php b/tests/ClassMutator/ClassPropertiesAppenderTest.php index 7dd3875b..aa514fe6 100644 --- a/tests/ClassMutator/ClassPropertiesAppenderTest.php +++ b/tests/ClassMutator/ClassPropertiesAppenderTest.php @@ -21,10 +21,10 @@ use ApiPlatform\SchemaGenerator\Schema\Model\Property; use ApiPlatform\SchemaGenerator\Schema\Model\Type\PrimitiveType as SchemaPrimitiveType; use ApiPlatform\SchemaGenerator\Schema\PropertyGenerator\PropertyGenerator as SchemaPropertyGenerator; -use ApiPlatform\SchemaGenerator\Schema\TypeConverter; -use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource; +use ApiPlatform\SchemaGenerator\Schema\TypeConverter; +use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; diff --git a/tests/Schema/Model/ClassTest.php b/tests/Schema/Model/ClassTest.php index d77db3c8..c26b4a03 100644 --- a/tests/Schema/Model/ClassTest.php +++ b/tests/Schema/Model/ClassTest.php @@ -17,9 +17,9 @@ use ApiPlatform\SchemaGenerator\Model\Use_; use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass; use ApiPlatform\SchemaGenerator\Schema\Model\Property as SchemaProperty; -use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource; +use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\String\Inflector\EnglishInflector; diff --git a/tests/Schema/Rdf/RdfResourceTest.php b/tests/Schema/Rdf/RdfResourceTest.php index 3890c79a..204efb0d 100644 --- a/tests/Schema/Rdf/RdfResourceTest.php +++ b/tests/Schema/Rdf/RdfResourceTest.php @@ -188,18 +188,18 @@ public function testUpdateResourceName(): void } } - public function testResetResourceNamingBehavior(): void - { - foreach (self::$testGroups as $testValues) { - $resource = $this->createConfiguredRdfResource($this->getAllTypesRdfResourceConfig($testValues), $testValues['resourceUri'], $testValues['graph']); + public function testResetResourceNamingBehavior(): void + { + foreach (self::$testGroups as $testValues) { + $resource = $this->createConfiguredRdfResource($this->getAllTypesRdfResourceConfig($testValues), $testValues['resourceUri'], $testValues['graph']); - $resource->resetResourceNamingBehavior(); - $this->assertNull($resource->getResourceName()); + $resource->resetResourceNamingBehavior(); + $this->assertNull($resource->getResourceName()); - $resource->updateResourceName(); - $this->assertEquals($testValues['id'], $resource->localName()); - } - } + $resource->updateResourceName(); + $this->assertEquals($testValues['id'], $resource->localName()); + } + } public function testLocalId(): void { @@ -220,17 +220,17 @@ public function testLabelAsName(): void } } - public function testGetGraph(): void - { - foreach (self::$testGroups as $testValues) { - $resource = new RdfResource($testValues['resourceUri']); - $this->assertNull($resource->getGraph()); - $resource = new RdfResource($testValues['resourceUri'], $testValues['graph']); - $this->assertInstanceOf(RdfGraph::class, $resource->getGraph()); - $resource = new RdfResource($testValues['resourceUri'], new EasyRdfGraph($testValues['graphUri'])); - $this->assertInstanceOf(RdfGraph::class, $resource->getGraph()); - } - } + public function testGetGraph(): void + { + foreach (self::$testGroups as $testValues) { + $resource = new RdfResource($testValues['resourceUri']); + $this->assertNull($resource->getGraph()); + $resource = new RdfResource($testValues['resourceUri'], $testValues['graph']); + $this->assertInstanceOf(RdfGraph::class, $resource->getGraph()); + $resource = new RdfResource($testValues['resourceUri'], new EasyRdfGraph($testValues['graphUri'])); + $this->assertInstanceOf(RdfGraph::class, $resource->getGraph()); + } + } public function testAll(): void { diff --git a/tests/TypesGeneratorTest.php b/tests/TypesGeneratorTest.php index 8da17bac..c199bfe5 100644 --- a/tests/TypesGeneratorTest.php +++ b/tests/TypesGeneratorTest.php @@ -18,9 +18,9 @@ use ApiPlatform\SchemaGenerator\GoodRelationsBridge; use ApiPlatform\SchemaGenerator\PhpTypeConverter; use ApiPlatform\SchemaGenerator\Printer; +use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration; use ApiPlatform\SchemaGenerator\TypesGenerator; -use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph; use EasyRdf\RdfNamespace; use PHPUnit\Framework\TestCase; use Prophecy\Argument;