From a57ae5095a3cd9cfcc536f5db6c454e5a7cec985 Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Wed, 17 Oct 2018 14:37:16 +0200 Subject: [PATCH] Update cs and when to check it --- Command/GenerateCommand.php | 2 +- Guesser/Guess/MultipleType.php | 2 +- Guesser/JsonSchema/AdditionalPropertiesGuesser.php | 2 +- Guesser/JsonSchema/AllOfGuesser.php | 2 +- Guesser/JsonSchema/AnyOfGuesser.php | 4 ++-- Guesser/JsonSchema/ArrayGuesser.php | 2 +- Guesser/JsonSchema/DefinitionGuesser.php | 2 +- Guesser/JsonSchema/ItemsGuesser.php | 4 ++-- Guesser/JsonSchema/MultipleGuesser.php | 2 +- Guesser/JsonSchema/ObjectGuesser.php | 6 +++--- Guesser/JsonSchema/ObjectOneOfGuesser.php | 2 +- Guesser/JsonSchema/OneOfGuesser.php | 2 +- Guesser/JsonSchema/PatternPropertiesGuesser.php | 2 +- Guesser/JsonSchema/SimpleTypeGuesser.php | 6 +++--- JsonSchemaMerger.php | 6 +++--- Printer.php | 4 ++-- Schema.php | 4 ++-- Tests/JaneBaseTest.php | 2 +- 18 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Command/GenerateCommand.php b/Command/GenerateCommand.php index 0fb5757..207682b 100644 --- a/Command/GenerateCommand.php +++ b/Command/GenerateCommand.php @@ -37,7 +37,7 @@ public function execute(InputInterface $input, OutputInterface $output) $options = require $configFile; - if (!is_array($options)) { + if (!\is_array($options)) { throw new \RuntimeException(sprintf('Invalid config file specified or invalid return type in file %s', $configFile)); } diff --git a/Guesser/Guess/MultipleType.php b/Guesser/Guess/MultipleType.php index 1458a14..2e83c62 100644 --- a/Guesser/Guess/MultipleType.php +++ b/Guesser/Guess/MultipleType.php @@ -84,7 +84,7 @@ public function getDocTypeHint($namespace) public function getTypeHint($namespace) { // We have exactly two types: one null and an object - if (2 === count($this->types)) { + if (2 === \count($this->types)) { list($type1, $type2) = $this->types; if ($this->isOptionalType($type1)) { diff --git a/Guesser/JsonSchema/AdditionalPropertiesGuesser.php b/Guesser/JsonSchema/AdditionalPropertiesGuesser.php index 66d5881..d742aea 100644 --- a/Guesser/JsonSchema/AdditionalPropertiesGuesser.php +++ b/Guesser/JsonSchema/AdditionalPropertiesGuesser.php @@ -39,7 +39,7 @@ public function supportObject($object) return false; } - if (true !== $object->getAdditionalProperties() && !is_object($object->getAdditionalProperties())) { + if (true !== $object->getAdditionalProperties() && !\is_object($object->getAdditionalProperties())) { return false; } diff --git a/Guesser/JsonSchema/AllOfGuesser.php b/Guesser/JsonSchema/AllOfGuesser.php index 8f71037..7b5f363 100644 --- a/Guesser/JsonSchema/AllOfGuesser.php +++ b/Guesser/JsonSchema/AllOfGuesser.php @@ -133,7 +133,7 @@ public function guessType($object, $name, $reference, Registry $registry) */ public function supportObject($object) { - return ($object instanceof JsonSchema) && is_array($object->getAllOf()) && count($object->getAllOf()) > 0; + return ($object instanceof JsonSchema) && \is_array($object->getAllOf()) && \count($object->getAllOf()) > 0; } /** diff --git a/Guesser/JsonSchema/AnyOfGuesser.php b/Guesser/JsonSchema/AnyOfGuesser.php index 465eda6..11ab6c6 100644 --- a/Guesser/JsonSchema/AnyOfGuesser.php +++ b/Guesser/JsonSchema/AnyOfGuesser.php @@ -30,7 +30,7 @@ public function guessClass($object, $name, $reference, Registry $registry) */ public function guessType($object, $name, $reference, Registry $registry) { - if (1 == count($object->getAnyOf())) { + if (1 == \count($object->getAnyOf())) { return $this->chainGuesser->guessType($object->getAnyOf()[0], $name, $reference . '/anyOf/0', $registry); } @@ -48,6 +48,6 @@ public function guessType($object, $name, $reference, Registry $registry) */ public function supportObject($object) { - return ($object instanceof JsonSchema) && is_array($object->getAnyOf()) && count($object->getAnyOf()) > 0; + return ($object instanceof JsonSchema) && \is_array($object->getAnyOf()) && \count($object->getAnyOf()) > 0; } } diff --git a/Guesser/JsonSchema/ArrayGuesser.php b/Guesser/JsonSchema/ArrayGuesser.php index dc53c94..8c56fd8 100644 --- a/Guesser/JsonSchema/ArrayGuesser.php +++ b/Guesser/JsonSchema/ArrayGuesser.php @@ -47,7 +47,7 @@ public function guessType($object, $name, $reference, Registry $registry) return new ArrayType($object, new Type($object, 'mixed')); } - if (!is_array($items)) { + if (!\is_array($items)) { return new ArrayType($object, $this->chainGuesser->guessType($items, $name . 'Item', $reference . '/items', $registry)); } diff --git a/Guesser/JsonSchema/DefinitionGuesser.php b/Guesser/JsonSchema/DefinitionGuesser.php index 910bd12..5dc6a4f 100644 --- a/Guesser/JsonSchema/DefinitionGuesser.php +++ b/Guesser/JsonSchema/DefinitionGuesser.php @@ -36,7 +36,7 @@ public function guessClass($object, $name, $reference, Registry $registry) */ public function supportObject($object) { - return ($object instanceof JsonSchema) && null !== $object->getDefinitions() && count($object->getDefinitions()) > 0; + return ($object instanceof JsonSchema) && null !== $object->getDefinitions() && \count($object->getDefinitions()) > 0; } /** diff --git a/Guesser/JsonSchema/ItemsGuesser.php b/Guesser/JsonSchema/ItemsGuesser.php index e1879ad..df42081 100644 --- a/Guesser/JsonSchema/ItemsGuesser.php +++ b/Guesser/JsonSchema/ItemsGuesser.php @@ -38,9 +38,9 @@ public function supportObject($object) $object->getItems() instanceof JsonSchema || ( - is_array($object->getItems()) + \is_array($object->getItems()) && - count($object->getItems()) > 0 + \count($object->getItems()) > 0 ) ) ; diff --git a/Guesser/JsonSchema/MultipleGuesser.php b/Guesser/JsonSchema/MultipleGuesser.php index cc4bdbd..638d5b9 100644 --- a/Guesser/JsonSchema/MultipleGuesser.php +++ b/Guesser/JsonSchema/MultipleGuesser.php @@ -19,7 +19,7 @@ class MultipleGuesser implements GuesserInterface, TypeGuesserInterface, ChainGu */ public function supportObject($object) { - return ($object instanceof JsonSchema) && is_array($object->getType()); + return ($object instanceof JsonSchema) && \is_array($object->getType()); } /** diff --git a/Guesser/JsonSchema/ObjectGuesser.php b/Guesser/JsonSchema/ObjectGuesser.php index f10119e..4c7a2b3 100644 --- a/Guesser/JsonSchema/ObjectGuesser.php +++ b/Guesser/JsonSchema/ObjectGuesser.php @@ -96,7 +96,7 @@ public function guessProperties($object, $name, $reference, Registry $registry) } $type = $propertyObj->getType(); - $nullable = 'null' == $type || (is_array($type) && in_array('null', $type)); + $nullable = 'null' == $type || (\is_array($type) && \in_array('null', $type)); $properties[$key] = new Property($property, $key, $reference . '/properties/' . $key, $nullable, null, $propertyObj->getDescription()); } @@ -113,7 +113,7 @@ public function guessType($object, $name, $reference, Registry $registry) $required = $object->getRequired() ?: []; foreach ($object->getProperties() as $key => $property) { - if (!in_array($key, $required)) { + if (!\in_array($key, $required)) { continue; } @@ -124,7 +124,7 @@ public function guessType($object, $name, $reference, Registry $registry) if (null !== $property->getEnum()) { $isSimple = true; foreach ($property->getEnum() as $value) { - if (is_array($value) || is_object($value)) { + if (\is_array($value) || \is_object($value)) { $isSimple = false; } } diff --git a/Guesser/JsonSchema/ObjectOneOfGuesser.php b/Guesser/JsonSchema/ObjectOneOfGuesser.php index d1e03ff..e989c41 100644 --- a/Guesser/JsonSchema/ObjectOneOfGuesser.php +++ b/Guesser/JsonSchema/ObjectOneOfGuesser.php @@ -80,6 +80,6 @@ public function guessType($object, $name, $reference, Registry $registry) */ public function supportObject($object) { - return ($object instanceof JsonSchema) && 'object' === $object->getType() && is_array($object->getOneOf()) && count($object->getOneOf()) > 0; + return ($object instanceof JsonSchema) && 'object' === $object->getType() && \is_array($object->getOneOf()) && \count($object->getOneOf()) > 0; } } diff --git a/Guesser/JsonSchema/OneOfGuesser.php b/Guesser/JsonSchema/OneOfGuesser.php index d8b656d..15f70c6 100644 --- a/Guesser/JsonSchema/OneOfGuesser.php +++ b/Guesser/JsonSchema/OneOfGuesser.php @@ -19,7 +19,7 @@ class OneOfGuesser implements ChainGuesserAwareInterface, TypeGuesserInterface, */ public function supportObject($object) { - return ($object instanceof JsonSchema) && 'object' !== $object->getType() && is_array($object->getOneOf()) && count($object->getOneOf()) > 0; + return ($object instanceof JsonSchema) && 'object' !== $object->getType() && \is_array($object->getOneOf()) && \count($object->getOneOf()) > 0; } /** diff --git a/Guesser/JsonSchema/PatternPropertiesGuesser.php b/Guesser/JsonSchema/PatternPropertiesGuesser.php index bc25578..0777f87 100644 --- a/Guesser/JsonSchema/PatternPropertiesGuesser.php +++ b/Guesser/JsonSchema/PatternPropertiesGuesser.php @@ -31,7 +31,7 @@ public function supportObject($object) return false; } - if (!($object->getPatternProperties() instanceof \ArrayObject) || 0 == count($object->getPatternProperties())) { + if (!($object->getPatternProperties() instanceof \ArrayObject) || 0 == \count($object->getPatternProperties())) { return false; } diff --git a/Guesser/JsonSchema/SimpleTypeGuesser.php b/Guesser/JsonSchema/SimpleTypeGuesser.php index ec37e12..b15af0e 100644 --- a/Guesser/JsonSchema/SimpleTypeGuesser.php +++ b/Guesser/JsonSchema/SimpleTypeGuesser.php @@ -39,12 +39,12 @@ public function supportObject($object) { return ($object instanceof JsonSchema) && - in_array($object->getType(), $this->typesSupported) + \in_array($object->getType(), $this->typesSupported) && ( - !in_array($object->getType(), $this->excludeFormat) + !\in_array($object->getType(), $this->excludeFormat) || - !in_array($object->getFormat(), $this->excludeFormat[$object->getType()]) + !\in_array($object->getFormat(), $this->excludeFormat[$object->getType()]) ) ; } diff --git a/JsonSchemaMerger.php b/JsonSchemaMerger.php index 9c25b2a..18b8c49 100644 --- a/JsonSchemaMerger.php +++ b/JsonSchemaMerger.php @@ -36,11 +36,11 @@ public function merge(JsonSchema $left, JsonSchema $right) private function arrayMerge($left, $right) { - if (!is_array($left)) { + if (!\is_array($left)) { return $right; } - if (!is_array($right)) { + if (!\is_array($right)) { return $left; } @@ -49,7 +49,7 @@ private function arrayMerge($left, $right) private function arrayUnique($array) { - if (!is_array($array)) { + if (!\is_array($array)) { return $array; } diff --git a/Printer.php b/Printer.php index cf40118..3a6d032 100644 --- a/Printer.php +++ b/Printer.php @@ -24,8 +24,8 @@ public function output(Registry $registry): void { foreach ($registry->getSchemas() as $schema) { foreach ($schema->getFiles() as $file) { - if (!file_exists(dirname($file->getFilename()))) { - mkdir(dirname($file->getFilename()), 0755, true); + if (!file_exists(\dirname($file->getFilename()))) { + mkdir(\dirname($file->getFilename()), 0755, true); } file_put_contents($file->getFilename(), $this->prettyPrinter->prettyPrintFile([$file->getNode()])); diff --git a/Schema.php b/Schema.php index f08a96c..f97bb8a 100644 --- a/Schema.php +++ b/Schema.php @@ -113,7 +113,7 @@ public function addReference(string $reference): void public function hasReference(string $reference): bool { - return in_array($reference, $this->references, true); + return \in_array($reference, $this->references, true); } /** @@ -146,7 +146,7 @@ private function fixPath(string $path): string continue; } - if ('..' === $part && count($pathParts) > 0) { + if ('..' === $part && \count($pathParts) > 0) { array_pop($pathParts); continue; } diff --git a/Tests/JaneBaseTest.php b/Tests/JaneBaseTest.php index bbe9e78..2df7bdb 100644 --- a/Tests/JaneBaseTest.php +++ b/Tests/JaneBaseTest.php @@ -41,7 +41,7 @@ public function testRessources($name, SplFileInfo $testDirectory) $generatedFinder->in($testDirectory->getRealPath() . \DIRECTORY_SEPARATOR . 'generated'); $generatedData = []; - $this->assertEquals(count($expectedFinder), count($generatedFinder), sprintf('No same number of files for %s', $testDirectory->getRelativePathname())); + $this->assertEquals(\count($expectedFinder), \count($generatedFinder), sprintf('No same number of files for %s', $testDirectory->getRelativePathname())); foreach ($generatedFinder as $generatedFile) { $generatedData[$generatedFile->getRelativePathname()] = $generatedFile->getRealPath();