From ccb311a332b9456cb9db827fb4ebb14191d742c0 Mon Sep 17 00:00:00 2001 From: Dan Barrett Date: Tue, 21 Dec 2021 10:25:24 +1100 Subject: [PATCH 1/3] feat: added Symfony 6 support and updated packages --- .github/workflows/coding-standards.yml | 1 + .github/workflows/continuous-integration.yml | 28 +++++++---- .github/workflows/static-analysis.yml | 1 + DependencyInjection/Configuration.php | 5 ++ .../Iter8LdapRecordExtension.php | 5 ++ .../Iter8LdapRecordExtensionTest.php | 3 ++ composer.json | 27 +++++----- phpcs.xml.dist | 4 ++ phpunit.xml.dist | 50 ++++++++----------- psalm.xml.dist | 2 +- 10 files changed, 71 insertions(+), 55 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index a808734..049dbbf 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -14,6 +14,7 @@ jobs: php-version: - 7.4 - 8.0 + - 8.1 steps: - name: "Checkout" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index f422cee..fdec950 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -22,31 +22,37 @@ jobs: matrix: include: # Symfony 4.4.0 has a minimum requirement of PHP 7.1.3 but LdapRecord library - # has a minimum PHP requirement of 7.2. - - php-version: 7.2 - composer-flags: "--prefer-lowest --prefer-stable" - symfony-require: "4.4.*" + # has a minimum PHP requirement of 7.3. - php-version: 7.3 - composer-flags: "--prefer-stable" + composer-flags: "--prefer-lowest --prefer-stable" symfony-require: "4.4.*" - php-version: 7.4 composer-flags: "--prefer-stable" symfony-require: "4.4.*" - php-version: 7.4 composer-flags: "--prefer-stable" - symfony-require: "5.0.*" + symfony-require: "5.3.*" - php-version: 7.4 composer-flags: "--prefer-stable" - symfony-require: "5.1.*" - - php-version: 7.4 + symfony-require: "5.4.*" + - php-version: 8.0 composer-flags: "--prefer-stable" - symfony-require: "5.2.*" + symfony-require: "4.4.*" - php-version: 8.0 composer-flags: "--prefer-stable" - symfony-require: "5.2.*" + symfony-require: "5.3.*" + - php-version: 8.0 + composer-flags: "--prefer-stable" + symfony-require: "5.4.*" + - php-version: 8.0 + composer-flags: "--prefer-stable" + symfony-require: "6.0.*" + - php-version: 8.1 + composer-flags: "--ignore-platform-reqs" + symfony-require: "5.4.*" - php-version: 8.1 composer-flags: "--ignore-platform-reqs" - symfony-require: "5.2.*" + symfony-require: "6.0.*" services: ldap: diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 703ff97..91bcf5f 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -14,6 +14,7 @@ jobs: php-version: - 7.4 - 8.0 + - 8.1 steps: - name: "Checkout" diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 9fa95e2..2308e48 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -15,6 +15,11 @@ public function getConfigTreeBuilder(): TreeBuilder $rootNode = $treeBuilder->getRootNode(); + /** + * @psalm-suppress PossiblyNullReference + * @psalm-suppress PossiblyUndefinedMethod + * @psalm-suppress ReservedWord + */ $rootNode ->children() ->arrayNode('hosts') diff --git a/DependencyInjection/Iter8LdapRecordExtension.php b/DependencyInjection/Iter8LdapRecordExtension.php index e294a85..5cefc7f 100644 --- a/DependencyInjection/Iter8LdapRecordExtension.php +++ b/DependencyInjection/Iter8LdapRecordExtension.php @@ -22,12 +22,17 @@ protected function loadInternal( ContainerBuilder $container ): void { $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + /** @psalm-suppress ReservedWord */ $loader->load('services.xml'); if ($mergedConfig['use_ssl'] && $mergedConfig['use_tls']) { throw new InvalidArgumentException(self::EXCEPTION_TLS_AND_SSL); } + /** + * @var bool $shouldAutoConnect + * @phpcsSuppress SlevomatCodingStandard.PHP.RequireExplicitAssertion.RequiredExplicitAssertion + */ $shouldAutoConnect = $mergedConfig['auto_connect']; unset($mergedConfig['auto_connect']); diff --git a/Tests/DependencyInjection/Iter8LdapRecordExtensionTest.php b/Tests/DependencyInjection/Iter8LdapRecordExtensionTest.php index 551def2..5a0616a 100644 --- a/Tests/DependencyInjection/Iter8LdapRecordExtensionTest.php +++ b/Tests/DependencyInjection/Iter8LdapRecordExtensionTest.php @@ -80,6 +80,9 @@ public function test_is_connected_with_auto_connect_enabled(): void self::assertTrue($connection->isConnected()); } + /** + * @return array + */ private function baseConfig(): array { return [ diff --git a/composer.json b/composer.json index 9d3f13b..c31ea52 100644 --- a/composer.json +++ b/composer.json @@ -13,22 +13,22 @@ "source": "https://github.com/iter8-au/ldaprecord-bundle" }, "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "ext-ldap": "*", - "directorytree/ldaprecord": "^2.0", - "symfony/framework-bundle": "^4.4 || ^5.0" + "directorytree/ldaprecord": "^2.5", + "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0" }, "require-dev": { - "doctrine/coding-standard": "^8.0", + "doctrine/coding-standard": "^9.0", "ergebnis/composer-normalize": "^2.0", - "friendsofphp/php-cs-fixer": "^2.0", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-deprecation-rules": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/phpunit": "^8.0", - "psalm/plugin-phpunit": "^0.15.0", - "psalm/plugin-symfony": "^2.0", + "friendsofphp/php-cs-fixer": "^3.0", + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.0", + "psalm/plugin-phpunit": "^0.16", + "psalm/plugin-symfony": "^3.0", "squizlabs/php_codesniffer": "^3.5", "vimeo/psalm": "^4.0" }, @@ -65,6 +65,7 @@ "phpstan": "phpstan analyze", "phpstan-max": "@phpstan --level=max", "phpunit": "phpunit", - "psalm": "psalm --show-info=true" + "psalm": "psalm --show-info=true", + "psalm-dev": "@psalm --find-unused-psalm-suppress" } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index ec27d43..56f4711 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -48,6 +48,10 @@ Tests + + DependencyInjection/Iter8LdapRecordExtension\.php + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b3988ba..1ee5ce5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,32 +1,22 @@ - - - - - - - - - - - ./Tests - - - - - - ./ - - ./Tests - ./vendor - - - + + + + ./ + + + ./Tests + ./vendor + + + + + + + + + + ./Tests + + diff --git a/psalm.xml.dist b/psalm.xml.dist index 0990472..63acb6d 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -8,7 +8,7 @@ ignoreInternalFunctionNullReturn="false" findUnusedVariablesAndParams="true" findUnusedCode="true" - findUnusedPsalmSuppress="true" + findUnusedPsalmSuppress="false" ensureArrayStringOffsetsExist="true" ensureArrayIntOffsetsExist="true" cacheDirectory=".psalm" From b12690b8652e6725e3ed490a738fe6650dabfc2f Mon Sep 17 00:00:00 2001 From: Dan Barrett Date: Tue, 21 Dec 2021 15:41:27 +1100 Subject: [PATCH 2/3] feat: mitigated static analysis issues --- DependencyInjection/Configuration.php | 170 +++++++++++++++++++++++++- composer.json | 16 +-- phpstan.neon.dist | 6 +- psalm.xml.dist | 2 +- 4 files changed, 179 insertions(+), 15 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 2308e48..42ec8f1 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -4,17 +4,40 @@ namespace Iter8\Bundle\LdapRecordBundle\DependencyInjection; +use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; final class Configuration implements ConfigurationInterface { + /** + * @psalm-return TreeBuilder<'array'> + * @phpstan-return TreeBuilder + */ public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('iter8_ldap_record'); $rootNode = $treeBuilder->getRootNode(); + $this->addHostsSection($rootNode); + $this->addBaseDnSection($rootNode); + $this->addUsernameSection($rootNode); + $this->addPasswordSection($rootNode); + $this->addPortSection($rootNode); + $this->addUseSslSection($rootNode); + $this->addUseTlsSection($rootNode); + $this->addVersionSection($rootNode); + $this->addTimeoutSection($rootNode); + $this->addFollowReferralsSection($rootNode); + $this->addAutoConnectSection($rootNode); + $this->addOptionsSection($rootNode); + + return $treeBuilder; + } + + private function addHostsSection(ArrayNodeDefinition $rootNode): void + { /** * @psalm-suppress PossiblyNullReference * @psalm-suppress PossiblyUndefinedMethod @@ -24,45 +47,186 @@ public function getConfigTreeBuilder(): TreeBuilder ->children() ->arrayNode('hosts') ->requiresAtLeastOneElement() - ->scalarPrototype() - ->end() + ->scalarPrototype()->end() ->end() + ->end(); + } + + private function addBaseDnSection(ArrayNodeDefinition $rootNode): void + { + /** + * @psalm-suppress PossiblyNullReference + * @psalm-suppress PossiblyUndefinedMethod + * @psalm-suppress ReservedWord + * @psalm-suppress UnusedMethodCall + */ + $rootNode + ->children() ->scalarNode('base_dn') ->isRequired() ->cannotBeEmpty() ->end() + ->end(); + } + + private function addUsernameSection(ArrayNodeDefinition $rootNode): void + { + /** + * @psalm-suppress PossiblyNullReference + * @psalm-suppress PossiblyUndefinedMethod + * @psalm-suppress ReservedWord + * @psalm-suppress UnusedMethodCall + */ + $rootNode + ->children() ->scalarNode('username') ->isRequired() ->cannotBeEmpty() ->end() + ->end(); + } + + private function addPasswordSection(ArrayNodeDefinition $rootNode): void + { + /** + * @psalm-suppress PossiblyNullReference + * @psalm-suppress PossiblyUndefinedMethod + * @psalm-suppress ReservedWord + * @psalm-suppress UnusedMethodCall + */ + $rootNode + ->children() ->scalarNode('password') ->isRequired() ->end() + ->end(); + } + + private function addPortSection(ArrayNodeDefinition $rootNode): void + { + /** + * @psalm-suppress PossiblyNullReference + * @psalm-suppress PossiblyUndefinedMethod + * @psalm-suppress ReservedWord + * @psalm-suppress UnusedMethodCall + */ + $rootNode + ->children() ->integerNode('port') ->min(1) ->max(65535) ->defaultValue(389) ->end() + ->end(); + } + + private function addUseSslSection(ArrayNodeDefinition $rootNode): void + { + /** + * @psalm-suppress PossiblyNullReference + * @psalm-suppress PossiblyUndefinedMethod + * @psalm-suppress ReservedWord + * @psalm-suppress UnusedMethodCall + */ + $rootNode + ->children() ->booleanNode('use_ssl') ->defaultFalse() ->end() + ->end(); + } + + private function addUseTlsSection(ArrayNodeDefinition $rootNode): void + { + /** + * @psalm-suppress PossiblyNullReference + * @psalm-suppress PossiblyUndefinedMethod + * @psalm-suppress ReservedWord + * @psalm-suppress UnusedMethodCall + */ + $rootNode + ->children() ->booleanNode('use_tls') ->defaultFalse() ->end() + ->end(); + } + + private function addVersionSection(ArrayNodeDefinition $rootNode): void + { + /** + * @psalm-suppress PossiblyNullReference + * @psalm-suppress PossiblyUndefinedMethod + * @psalm-suppress ReservedWord + * @psalm-suppress UnusedMethodCall + */ + $rootNode + ->children() ->enumNode('version') ->values([2, 3]) ->defaultValue(3) ->end() + ->end(); + } + + private function addTimeoutSection(ArrayNodeDefinition $rootNode): void + { + /** + * @psalm-suppress PossiblyNullReference + * @psalm-suppress PossiblyUndefinedMethod + * @psalm-suppress ReservedWord + * @psalm-suppress UnusedMethodCall + */ + $rootNode + ->children() ->integerNode('timeout') ->info('Timeout (in seconds).') ->defaultValue(5) ->end() + ->end(); + } + + private function addFollowReferralsSection(ArrayNodeDefinition $rootNode): void + { + /** + * @psalm-suppress PossiblyNullReference + * @psalm-suppress PossiblyUndefinedMethod + * @psalm-suppress ReservedWord + * @psalm-suppress UnusedMethodCall + */ + $rootNode + ->children() ->booleanNode('follow_referrals') ->defaultFalse() ->end() + ->end(); + } + + private function addAutoConnectSection(ArrayNodeDefinition $rootNode): void + { + /** + * @psalm-suppress PossiblyNullReference + * @psalm-suppress PossiblyUndefinedMethod + * @psalm-suppress ReservedWord + * @psalm-suppress UnusedMethodCall + */ + $rootNode + ->children() ->booleanNode('auto_connect') ->defaultFalse() ->end() + ->end(); + } + + private function addOptionsSection(ArrayNodeDefinition $rootNode): void + { + /** + * @psalm-suppress PossiblyNullReference + * @psalm-suppress PossiblyUndefinedMethod + * @psalm-suppress ReservedWord + */ + $rootNode + ->children() ->arrayNode('options') ->arrayPrototype() ->children() @@ -72,7 +236,5 @@ public function getConfigTreeBuilder(): TreeBuilder ->end() ->end() ->end(); - - return $treeBuilder; } } diff --git a/composer.json b/composer.json index c31ea52..ed971aa 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { "name": "iter8/ldaprecord-bundle", - "type": "symfony-bundle", "description": "LdapRecord for Symfony bundle", "license": "MIT", + "type": "symfony-bundle", "keywords": [ "symfony", "symfony-bundle", @@ -26,16 +26,13 @@ "phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-phpunit": "^1.0", "phpstan/phpstan-strict-rules": "^1.0", + "phpstan/phpstan-symfony": "^1.0", "phpunit/phpunit": "^9.0", "psalm/plugin-phpunit": "^0.16", "psalm/plugin-symfony": "^3.0", "squizlabs/php_codesniffer": "^3.5", "vimeo/psalm": "^4.0" }, - "config": { - "preferred-install": "dist", - "sort-packages": true - }, "conflict": { "tightenco/collect": "<5.6" }, @@ -52,6 +49,10 @@ "": "Tests/DependencyInjection" } }, + "config": { + "preferred-install": "dist", + "sort-packages": true + }, "scripts": { "ci": [ "@phpcs", @@ -63,9 +64,10 @@ "csf-dry": "@csf --dry-run", "phpcs": "phpcs", "phpstan": "phpstan analyze", + "phpstan-dev": "@phpstan --debug", "phpstan-max": "@phpstan --level=max", "phpunit": "phpunit", - "psalm": "psalm --show-info=true", - "psalm-dev": "@psalm --find-unused-psalm-suppress" + "psalm": "psalm", + "psalm-dev": "@psalm --show-info=true --find-unused-psalm-suppress --no-cache --stats" } } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 541ed4e..dc442d6 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -7,11 +7,11 @@ parameters: paths: - %currentWorkingDirectory%/DependencyInjection - %currentWorkingDirectory%/Tests + - %currentWorkingDirectory%/Iter8LdapRecordBundle.php ignoreErrors: - - - message: '#.*NodeDefinition::children.*#' - path: %currentWorkingDirectory%/DependencyInjection includes: - vendor/phpstan/phpstan-strict-rules/rules.neon - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/rules.neon + - vendor/phpstan/phpstan-symfony/extension.neon + - vendor/phpstan/phpstan-symfony/rules.neon diff --git a/psalm.xml.dist b/psalm.xml.dist index 63acb6d..be6943c 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -12,7 +12,7 @@ ensureArrayStringOffsetsExist="true" ensureArrayIntOffsetsExist="true" cacheDirectory=".psalm" - errorLevel="2" + errorLevel="1" > From 2c44e03bd328f213a344f2cb64d489c49850e691 Mon Sep 17 00:00:00 2001 From: Dan Barrett Date: Tue, 11 Oct 2022 15:02:54 +1100 Subject: [PATCH 3/3] fix: minor uplift and fixes before merge --- .github/workflows/static-analysis.yml | 5 ++-- .gitignore | 1 + .php_cs.dist => .php-cs-fixer.dist.php | 16 ++++++------ DependencyInjection/Configuration.php | 25 ++++++++++--------- .../Iter8LdapRecordExtension.php | 3 ++- Tests/TestCase.php | 2 +- composer.json | 8 ++++-- phpcs.xml.dist | 5 ++++ phpstan.neon.dist | 1 + psalm.xml.dist | 2 +- 10 files changed, 42 insertions(+), 26 deletions(-) rename .php_cs.dist => .php-cs-fixer.dist.php (71%) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 91bcf5f..6d2b891 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -33,5 +33,6 @@ jobs: - name: "Run a static analysis with phpstan/phpstan" run: "vendor/bin/phpstan analyse" - - name: "Run a static analysis with vimeo/psalm" - run: "vendor/bin/psalm --output-format=github" + # Skip Psalm until we can get it working better with Symfony bundle configuration files. +# - name: "Run a static analysis with vimeo/psalm" +# run: "vendor/bin/psalm --output-format=github" diff --git a/.gitignore b/.gitignore index bcb722c..553c384 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ vendor/ composer.lock phpunit.xml .php_cs.cache +.php-cs-fixer.cache .phpunit.result.cache composer.phar package.tar diff --git a/.php_cs.dist b/.php-cs-fixer.dist.php similarity index 71% rename from .php_cs.dist rename to .php-cs-fixer.dist.php index c680b46..1faa1e6 100644 --- a/.php_cs.dist +++ b/.php-cs-fixer.dist.php @@ -1,6 +1,13 @@ in(__DIR__) + ->append([__FILE__]); + +// @See https://github.com/FriendsOfPHP/PHP-CS-Fixer +$config = new PhpCsFixer\Config(); + +return $config ->setRules([ '@Symfony' => true, '@Symfony:risky' => true, @@ -15,9 +22,4 @@ 'php_unit_method_casing' => ['case' => 'snake_case'], ]) ->setRiskyAllowed(true) - ->setFinder( - PhpCsFixer\Finder::create() - ->in(__DIR__) - ->append([__FILE__]) - ) -; + ->setFinder($finder); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 42ec8f1..b60076f 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -12,6 +12,7 @@ final class Configuration implements ConfigurationInterface { /** * @psalm-return TreeBuilder<'array'> + * * @phpstan-return TreeBuilder */ public function getConfigTreeBuilder(): TreeBuilder @@ -38,7 +39,7 @@ public function getConfigTreeBuilder(): TreeBuilder private function addHostsSection(ArrayNodeDefinition $rootNode): void { - /** + /* * @psalm-suppress PossiblyNullReference * @psalm-suppress PossiblyUndefinedMethod * @psalm-suppress ReservedWord @@ -54,7 +55,7 @@ private function addHostsSection(ArrayNodeDefinition $rootNode): void private function addBaseDnSection(ArrayNodeDefinition $rootNode): void { - /** + /* * @psalm-suppress PossiblyNullReference * @psalm-suppress PossiblyUndefinedMethod * @psalm-suppress ReservedWord @@ -71,7 +72,7 @@ private function addBaseDnSection(ArrayNodeDefinition $rootNode): void private function addUsernameSection(ArrayNodeDefinition $rootNode): void { - /** + /* * @psalm-suppress PossiblyNullReference * @psalm-suppress PossiblyUndefinedMethod * @psalm-suppress ReservedWord @@ -88,7 +89,7 @@ private function addUsernameSection(ArrayNodeDefinition $rootNode): void private function addPasswordSection(ArrayNodeDefinition $rootNode): void { - /** + /* * @psalm-suppress PossiblyNullReference * @psalm-suppress PossiblyUndefinedMethod * @psalm-suppress ReservedWord @@ -104,7 +105,7 @@ private function addPasswordSection(ArrayNodeDefinition $rootNode): void private function addPortSection(ArrayNodeDefinition $rootNode): void { - /** + /* * @psalm-suppress PossiblyNullReference * @psalm-suppress PossiblyUndefinedMethod * @psalm-suppress ReservedWord @@ -122,7 +123,7 @@ private function addPortSection(ArrayNodeDefinition $rootNode): void private function addUseSslSection(ArrayNodeDefinition $rootNode): void { - /** + /* * @psalm-suppress PossiblyNullReference * @psalm-suppress PossiblyUndefinedMethod * @psalm-suppress ReservedWord @@ -138,7 +139,7 @@ private function addUseSslSection(ArrayNodeDefinition $rootNode): void private function addUseTlsSection(ArrayNodeDefinition $rootNode): void { - /** + /* * @psalm-suppress PossiblyNullReference * @psalm-suppress PossiblyUndefinedMethod * @psalm-suppress ReservedWord @@ -154,7 +155,7 @@ private function addUseTlsSection(ArrayNodeDefinition $rootNode): void private function addVersionSection(ArrayNodeDefinition $rootNode): void { - /** + /* * @psalm-suppress PossiblyNullReference * @psalm-suppress PossiblyUndefinedMethod * @psalm-suppress ReservedWord @@ -171,7 +172,7 @@ private function addVersionSection(ArrayNodeDefinition $rootNode): void private function addTimeoutSection(ArrayNodeDefinition $rootNode): void { - /** + /* * @psalm-suppress PossiblyNullReference * @psalm-suppress PossiblyUndefinedMethod * @psalm-suppress ReservedWord @@ -188,7 +189,7 @@ private function addTimeoutSection(ArrayNodeDefinition $rootNode): void private function addFollowReferralsSection(ArrayNodeDefinition $rootNode): void { - /** + /* * @psalm-suppress PossiblyNullReference * @psalm-suppress PossiblyUndefinedMethod * @psalm-suppress ReservedWord @@ -204,7 +205,7 @@ private function addFollowReferralsSection(ArrayNodeDefinition $rootNode): void private function addAutoConnectSection(ArrayNodeDefinition $rootNode): void { - /** + /* * @psalm-suppress PossiblyNullReference * @psalm-suppress PossiblyUndefinedMethod * @psalm-suppress ReservedWord @@ -220,7 +221,7 @@ private function addAutoConnectSection(ArrayNodeDefinition $rootNode): void private function addOptionsSection(ArrayNodeDefinition $rootNode): void { - /** + /* * @psalm-suppress PossiblyNullReference * @psalm-suppress PossiblyUndefinedMethod * @psalm-suppress ReservedWord diff --git a/DependencyInjection/Iter8LdapRecordExtension.php b/DependencyInjection/Iter8LdapRecordExtension.php index 5cefc7f..6e1e616 100644 --- a/DependencyInjection/Iter8LdapRecordExtension.php +++ b/DependencyInjection/Iter8LdapRecordExtension.php @@ -22,7 +22,7 @@ protected function loadInternal( ContainerBuilder $container ): void { $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - /** @psalm-suppress ReservedWord */ + /* @psalm-suppress ReservedWord */ $loader->load('services.xml'); if ($mergedConfig['use_ssl'] && $mergedConfig['use_tls']) { @@ -31,6 +31,7 @@ protected function loadInternal( /** * @var bool $shouldAutoConnect + * * @phpcsSuppress SlevomatCodingStandard.PHP.RequireExplicitAssertion.RequiredExplicitAssertion */ $shouldAutoConnect = $mergedConfig['auto_connect']; diff --git a/Tests/TestCase.php b/Tests/TestCase.php index c667bc0..ba87bb5 100644 --- a/Tests/TestCase.php +++ b/Tests/TestCase.php @@ -14,7 +14,7 @@ protected function getLdapConfig(): array $h = @ldap_connect((string) getenv('LDAP_HOST'), (int) getenv('LDAP_PORT')); @ldap_set_option($h, \LDAP_OPT_PROTOCOL_VERSION, 3); - if (!\is_resource($h) || !@ldap_bind($h)) { + if (null === $h || !@ldap_bind($h)) { self::markTestSkipped('No server is listening on LDAP_HOST:LDAP_PORT'); } diff --git a/composer.json b/composer.json index ed971aa..ea9f29a 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0" }, "require-dev": { - "doctrine/coding-standard": "^9.0", + "doctrine/coding-standard": "^10.0", "ergebnis/composer-normalize": "^2.0", "friendsofphp/php-cs-fixer": "^3.0", "phpstan/phpstan": "^1.0", @@ -28,7 +28,7 @@ "phpstan/phpstan-strict-rules": "^1.0", "phpstan/phpstan-symfony": "^1.0", "phpunit/phpunit": "^9.0", - "psalm/plugin-phpunit": "^0.16", + "psalm/plugin-phpunit": "^0.17", "psalm/plugin-symfony": "^3.0", "squizlabs/php_codesniffer": "^3.5", "vimeo/psalm": "^4.0" @@ -50,6 +50,10 @@ } }, "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true, + "ergebnis/composer-normalize": true + }, "preferred-install": "dist", "sort-packages": true }, diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 56f4711..1c63521 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -25,6 +25,11 @@ + + + + + diff --git a/phpstan.neon.dist b/phpstan.neon.dist index dc442d6..7afcfb7 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -9,6 +9,7 @@ parameters: - %currentWorkingDirectory%/Tests - %currentWorkingDirectory%/Iter8LdapRecordBundle.php ignoreErrors: + - '#expects LDAP\\Connection#' includes: - vendor/phpstan/phpstan-strict-rules/rules.neon - vendor/phpstan/phpstan-phpunit/extension.neon diff --git a/psalm.xml.dist b/psalm.xml.dist index be6943c..0d58d5e 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -8,7 +8,7 @@ ignoreInternalFunctionNullReturn="false" findUnusedVariablesAndParams="true" findUnusedCode="true" - findUnusedPsalmSuppress="false" + findUnusedPsalmSuppress="true" ensureArrayStringOffsetsExist="true" ensureArrayIntOffsetsExist="true" cacheDirectory=".psalm"