承接 symplify/phpstan-extensions 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

symplify/phpstan-extensions

最新稳定版本:12.0.2

Composer 安装命令:

composer require symplify/phpstan-extensions

包简介

Pre-escaped error messages in 'symplify' error format, container aware test case and other useful extensions for PHPStan

README 文档

README

Downloads total


Install

composer require symplify/phpstan-extensions --dev

Symplify Error Formatter

Update your phpstan.neon config:

parameters:
    errorFormat: symplify
  • Do you want to click the error and get right to the line in the file it's reported at?
  • Do you want to copy-paste regex escaped error to your ignoreErrors?

Works best with anthraxx/intellij-awesome-console

vendor/bin/phpstan analyse src

------------------------------------------------------------------------------------------
src/Command/ReleaseCommand.php:51
------------------------------------------------------------------------------------------
- "Call to an undefined method Symplify\\Command\\ReleaseCommand\:\:nonExistingCall\(\)"
------------------------------------------------------------------------------------------

Improved Symfony Types

ContainerGetTypeExtension

With Symfony container and type as an argument, you always know the same type is returned:

use Symfony\Component\DependencyInjection\Container;

/** @var Container $container */
// PHPStan: object ❌
$container->get(Type::class);
// Reality: Type ✅
$container->get(Type::class);

// same for in-controller/container-aware context
$this->get(Type::class);

KernelGetContainerAfterBootReturnTypeExtension

After Symfony Kernel boot, getContainer() always returns the container:

use Symfony\Component\HttpKernel\Kernel;

final class AppKernel extends Kernel
{
    // ...
}

$kernel = new AppKernel('prod', false);
$kernel->boot();

// PHPStan: null|ContainerInterface ❌
$kernel->getContainer();
// Reality: ContainerInterface ✅
$kernel->getContainer();
// Reality: ContainerInterface ✅

SplFileInfoTolerantReturnTypeExtension

Symfony Finder finds only existing files (obviously), so the getRealPath() always return string:

use Symfony\Component\Finder\Finder;

$finder = new Finder();

foreach ($finder as $fileInfo) {
    // PHPStan: false|string ❌
    $fileInfo->getRealPath();
    // Reality: string ✅
    $fileInfo->getRealPath();
}

Happy coding!

统计信息

  • 总下载量: 5.61M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 38
  • 点击次数: 1
  • 依赖项目数: 103
  • 推荐数: 1

GitHub 信息

  • Stars: 38
  • Watchers: 1
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04