diff --git a/composer.json b/composer.json index d1e8b9f9..33c891eb 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,8 @@ "php": "8.1.99" }, "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true, + "phpstan/extension-installer": true } }, "extra": { @@ -32,13 +33,19 @@ }, "require": { "php": "~8.1.0 || ~8.2.0 || ~8.3.0", - "laminas/laminas-stdlib": "^3.7.1" + "laminas/laminas-stdlib": "^3.7.1", + "psr/container": "^1.1" }, "require-dev": { "laminas/laminas-coding-standard": "^2.4.0", "laminas/laminas-eventmanager": "^3.6.0", "laminas/laminas-hydrator": "^4.7", "laminas/laminas-servicemanager": "^3.19.0", + "phpstan/extension-installer": "^1.4", + "phpstan/phpdoc-parser": "^1.5", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", "phpunit/phpunit": "^9.5.25" }, "suggest": { @@ -64,6 +71,7 @@ ], "cs-check": "phpcs", "cs-fix": "phpcbf", + "static-analysis": "phpstan analyse src test", "test": "phpunit --colors=always --testsuite \"unit test\"", "test-coverage": "phpunit --colors=always --coverage-clover clover.xml", "test-integration": "phpunit --colors=always --testsuite \"integration test\"", diff --git a/composer.lock b/composer.lock index a9713ff5..61b6cb8c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bab14dbc23e177873fe7698ca0c27a52", + "content-hash": "10bb680350e2d5748569ba5fb81fd9f3", "packages": [ { "name": "laminas/laminas-stdlib", @@ -64,6 +64,54 @@ } ], "time": "2024-01-19T12:39:49+00:00" + }, + { + "name": "psr/container", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/1.1.2" + }, + "time": "2021-11-05T16:50:12+00:00" } ], "packages-dev": [ @@ -738,6 +786,54 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpstan/extension-installer", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "85e90b3942d06b2326fba0403ec24fe912372936" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936", + "reference": "85e90b3942d06b2326fba0403ec24fe912372936", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.0 || ^2.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.4.3" + }, + "time": "2024-09-04T20:21:43+00:00" + }, { "name": "phpstan/phpdoc-parser", "version": "1.5.1", @@ -782,6 +878,162 @@ }, "time": "2022-05-05T11:32:40+00:00" }, + { + "name": "phpstan/phpstan", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "46b4d3529b12178112d9008337beda0cc2a1a6b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/46b4d3529b12178112d9008337beda0cc2a1a6b4", + "reference": "46b4d3529b12178112d9008337beda0cc2a1a6b4", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2024-11-28T22:19:37+00:00" + }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/1cc1259cb91ee4cfbb5c39bca9f635f067c910b4", + "reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.6" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.1" + }, + "time": "2024-11-28T21:56:36+00:00" + }, + { + "name": "phpstan/phpstan-phpunit", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-phpunit.git", + "reference": "4b6ad7fab8683ff4efd7887ba26ef8ee171c7475" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/4b6ad7fab8683ff4efd7887ba26ef8ee171c7475", + "reference": "4b6ad7fab8683ff4efd7887ba26ef8ee171c7475", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0" + }, + "conflict": { + "phpunit/phpunit": "<7.0" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon", + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPUnit extensions and rules for PHPStan", + "support": { + "issues": "https://github.com/phpstan/phpstan-phpunit/issues", + "source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.1" + }, + "time": "2024-11-12T12:48:00+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.31", @@ -1204,54 +1456,6 @@ ], "time": "2024-03-21T12:07:32+00:00" }, - { - "name": "psr/container", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", - "shasum": "" - }, - "require": { - "php": ">=7.4.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "support": { - "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" - }, - "time": "2021-11-05T16:50:12+00:00" - }, { "name": "sebastian/cli-parser", "version": "1.0.2", @@ -2522,13 +2726,13 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { "php": "~8.1.0 || ~8.2.0 || ~8.3.0" }, - "platform-dev": [], + "platform-dev": {}, "platform-overrides": { "php": "8.1.99" }, diff --git a/src/Adapter/AdapterAbstractServiceFactory.php b/src/Adapter/AdapterAbstractServiceFactory.php index 92061335..70387a76 100644 --- a/src/Adapter/AdapterAbstractServiceFactory.php +++ b/src/Adapter/AdapterAbstractServiceFactory.php @@ -2,8 +2,8 @@ namespace Laminas\Db\Adapter; -use Interop\Container\ContainerInterface; -use Laminas\ServiceManager\AbstractFactoryInterface; +use Psr\Container\ContainerInterface; +use Laminas\ServiceManager\Factory\AbstractFactoryInterface; use Laminas\ServiceManager\ServiceLocatorInterface; use function is_array; diff --git a/src/Adapter/AdapterServiceFactory.php b/src/Adapter/AdapterServiceFactory.php index e57575ed..41a86f56 100644 --- a/src/Adapter/AdapterServiceFactory.php +++ b/src/Adapter/AdapterServiceFactory.php @@ -2,9 +2,9 @@ namespace Laminas\Db\Adapter; -use Interop\Container\ContainerInterface; -use Laminas\ServiceManager\FactoryInterface; +use Laminas\ServiceManager\Factory\FactoryInterface; use Laminas\ServiceManager\ServiceLocatorInterface; +use Psr\Container\ContainerInterface; class AdapterServiceFactory implements FactoryInterface { diff --git a/src/Adapter/Driver/Pdo/Connection.php b/src/Adapter/Driver/Pdo/Connection.php index bcf5c5b5..8cdcab04 100644 --- a/src/Adapter/Driver/Pdo/Connection.php +++ b/src/Adapter/Driver/Pdo/Connection.php @@ -4,7 +4,7 @@ use Laminas\Db\Adapter\Driver\AbstractConnection; use Laminas\Db\Adapter\Exception; -use Laminas\Db\Adapter\Exception\RunTimeException; +use Laminas\Db\Adapter\Exception\RuntimeException; use PDOException; use PDOStatement; @@ -79,6 +79,8 @@ public function setConnectionParameters(array $connectionParameters) 3 )); } + + return $this; } /** diff --git a/src/Adapter/Driver/Pdo/Pdo.php b/src/Adapter/Driver/Pdo/Pdo.php index 72af7561..6429f831 100644 --- a/src/Adapter/Driver/Pdo/Pdo.php +++ b/src/Adapter/Driver/Pdo/Pdo.php @@ -318,8 +318,8 @@ public function formatParameterName($name, $type = null) if (preg_match('/[^a-zA-Z0-9_]/', $name)) { throw new Exception\RuntimeException(sprintf( 'The PDO param %s contains invalid characters.' - . ' Only alphabetic characters, digits, and underscores (_)' - . ' are allowed.', + . ' Only alphabetic characters, digits, and underscores (_)' + . ' are allowed.', $name )); } diff --git a/src/ResultSet/HydratingResultSet.php b/src/ResultSet/HydratingResultSet.php index e99b7295..c3187aaa 100644 --- a/src/ResultSet/HydratingResultSet.php +++ b/src/ResultSet/HydratingResultSet.php @@ -27,10 +27,7 @@ class HydratingResultSet extends AbstractResultSet */ public function __construct(?HydratorInterface $hydrator = null, $objectPrototype = null) { - $defaultHydratorClass = class_exists(ArraySerializableHydrator::class) - ? ArraySerializableHydrator::class - : ArraySerializable::class; - $this->setHydrator($hydrator ?: new $defaultHydratorClass()); + $this->setHydrator($hydrator ?: new ArraySerializableHydrator()); $this->setObjectPrototype($objectPrototype ?: new ArrayObject()); }