Merge pull request #126 from zhamao-robot/add-phpstan-extensions

添加 PHPStan 相关扩展
This commit is contained in:
sunxyw 2022-05-16 01:52:30 +08:00 committed by GitHub
commit a2877cab70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 6 deletions

View File

@ -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": {

View File

@ -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

View File

@ -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()) {

View File

@ -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;
}
}
/**