diff --git a/composer.json b/composer.json index 90654437..e9372fd6 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,10 @@ "brainmaestro/composer-git-hooks": "^2.8", "friendsofphp/php-cs-fixer": "^3.2 != 3.7.0", "jetbrains/phpstorm-attributes": "^1.0", + "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.1", "phpunit/phpunit": "^8.5 || ^9.0", "roave/security-advisories": "dev-latest", "swoole/ide-helper": "^4.5" @@ -72,7 +75,10 @@ ], "config": { "optimize-autoloader": true, - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "phpstan/extension-installer": true + } }, "extra": { "hooks": { diff --git a/phpstan.neon b/phpstan.neon index 66ea6614..b6c908a9 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,10 +4,10 @@ parameters: paths: - ./src/ ignoreErrors: - - '#Used constant OS_TYPE_(LINUX|WINDOWS) not found#' - '#Constant .* not found#' - '#PHPDoc tag @throws with type Psr\\Container\\ContainerExceptionInterface is not subtype of Throwable#' - '#Unsafe usage of new static#' + - '#Call to method initTableList\(\) of deprecated class ZM\\DB\\DB#' dynamicConstantNames: - SWOOLE_VERSION - ZM_TEST_LOG_DEBUG diff --git a/src/ZM/Container/ContainerTrait.php b/src/ZM/Container/ContainerTrait.php index d654dc32..d5f58e1d 100644 --- a/src/ZM/Container/ContainerTrait.php +++ b/src/ZM/Container/ContainerTrait.php @@ -663,7 +663,7 @@ trait ContainerTrait { try { // 尝试解析 - return $this->make($parameter->getClass()->name); + return $this->make(ReflectionUtil::getParameterClassName($parameter)); } catch (EntryResolutionException $e) { // 如果参数是可选的,则返回默认值 if ($parameter->isDefaultValueAvailable()) { diff --git a/src/ZM/MySQL/MySQLStatement.php b/src/ZM/MySQL/MySQLStatement.php index d6c85a39..23b17869 100644 --- a/src/ZM/MySQL/MySQLStatement.php +++ b/src/ZM/MySQL/MySQLStatement.php @@ -9,11 +9,11 @@ declare(strict_types=1); namespace ZM\MySQL; use Doctrine\DBAL\Driver\Statement; -use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; use PDOStatement; +use Traversable; class MySQLStatement implements IteratorAggregate, Statement { @@ -102,9 +102,11 @@ class MySQLStatement implements IteratorAggregate, Statement return $this->statement->rowCount(); } - public function getIterator(): StatementIterator + public function getIterator(): Traversable { - return new StatementIterator($this); + while (($result = $this->statement->fetch()) !== false) { + yield $result; + } } /**