diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 650f9f177f3f9cd6451a70e89081f925c4336db1..8172c66dbf07895b8210673dc90b56f88b7713df 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,6 @@ install-vendors: variables: COMPOSER_NO_INTERACTION: "1" script: - - phpenmod iconv - composer validate - composer install -n --prefer-dist --no-suggest --no-progress --no-scripts --ignore-platform-reqs cache: @@ -44,6 +43,7 @@ php-cs-fixer: phpcpd: <<: *test script: vendor/bin/phpcpd --fuzzy src tests + allow_failure: true phpunit: <<: *test diff --git a/composer.json b/composer.json index cee6c0359e24bc59f3b8acc80af9ce0f42515806..0dd36dc6b246c55ec9ddc32ab4cc720b048bb387 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,8 @@ "minimum-stability": "stable", "require": { "php": "^7.1", + "ext-json": "*", + "ext-zip": "*", "api-platform/core": "^2.2", "doctrine/cache": "^1.8", "doctrine/inflector": "^1.3", diff --git a/src/Metadata/PropertyMetadataFactory.php b/src/Metadata/PropertyMetadataFactory.php index a6acda8093e9a343e907b04dc7e0c42b347d0374..823aab2180a597740a030523fdfde377135e769f 100644 --- a/src/Metadata/PropertyMetadataFactory.php +++ b/src/Metadata/PropertyMetadataFactory.php @@ -47,9 +47,6 @@ class PropertyMetadataFactory /** @var ClassName */ private $resource; - /** @var bool */ - private $normalization; - /** @var string */ private $mode; @@ -89,9 +86,11 @@ class PropertyMetadataFactory } /** - * @param ClassName $class - * @param string $propertyName - * @param APIPropertyMetadata $propertyMeta + * @param ClassName $class + * @param string $propertyName + * + * @throws ResourceClassNotFoundException + * @throws \ApiPlatform\Core\Exception\PropertyNotFoundException * * @return PropertyMetadata */ diff --git a/src/Models/ClassInfo.php b/src/Models/ClassInfo.php index 669d828734d49045430ef68483c195976fcf6438..b9994b34a71d108888a0581527cca4e968d7cf64 100644 --- a/src/Models/ClassInfo.php +++ b/src/Models/ClassInfo.php @@ -168,6 +168,8 @@ final class ClassInfo implements ClassName /** * @param ClassInfo $child + * + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ private function addChild(ClassInfo $child): void { @@ -359,6 +361,7 @@ final class ClassInfo implements ClassName * Get properties. * * @return HasName[] + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ private function getAllConcreteProperties(): array { diff --git a/src/Models/PHPClass.php b/src/Models/PHPClass.php index 69fbee81806d28435a9a90bc3074bdd4896e457c..55d8baabc6f7a61c243b029ebdc3d18afe2fa553 100644 --- a/src/Models/PHPClass.php +++ b/src/Models/PHPClass.php @@ -121,7 +121,7 @@ final class PHPClass implements ClassName if (!preg_match('/^\\\\?((?:\w+\\\\)*)(\w+)$/i', $name, $groups)) { throw new InvalidArgumentException("Invalid PHP class name: $name"); } - [, $namespace, $baseName] = $groups; + list(, $namespace, $baseName) = $groups; $instances[$name] = new self($namespace, $baseName); } diff --git a/tests/Iterators/UniqueFilterTest.php b/tests/Iterators/UniqueFilterTest.php index b4d429dce3d7094dc883e189b8a1a4473c0ed651..7c42f6186e7781cbd76e25b17fa36d96e5e6fdb2 100644 --- a/tests/Iterators/UniqueFilterTest.php +++ b/tests/Iterators/UniqueFilterTest.php @@ -1,9 +1,20 @@ <?php declare(strict_types=1); -/** +/* + * irstea/ng-model-generator-bundle generates Typescript interfaces for Angular using api-platform metadata. * Copyright (C) 2018 IRSTEA - * All rights reserved. - * @copyright 2018 IRSTEA - * @author guillaume.perreal + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License and the GNU + * Lesser General Public License along with this program. If not, see + * <https://www.gnu.org/licenses/>. */ namespace Irstea\NgModelGeneratorBundle\Tests\Iterators; @@ -12,7 +23,7 @@ use Irstea\NgModelGeneratorBundle\Iterators\UniqueFilter; use PHPUnit\Framework\TestCase; /** - * Class UniqueFilterTest + * Class UniqueFilterTest. */ class UniqueFilterTest extends TestCase { @@ -26,7 +37,8 @@ class UniqueFilterTest extends TestCase $this->tested = new UniqueFilter(); } - public function testKeepUniqueValues() { + public function testKeepUniqueValues() + { $input = [4, 5, null, new \stdClass(), new \stdClass()]; self::assertEquals($input, array_filter($input, $this->tested)); } @@ -41,7 +53,7 @@ class UniqueFilterTest extends TestCase self::assertEquals(count($expected), count($actual)); - foreach($expected as $i => $value) { + foreach ($expected as $i => $value) { self::assertSame($value, $actual[$i]); } }