承接 shipmonk/phpstan-dev 相关项目开发

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

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

shipmonk/phpstan-dev

最新稳定版本:0.1.4

Composer 安装命令:

composer require --dev shipmonk/phpstan-dev

包简介

Development utilities for PHPStan rules testing, extracted from shipmonk/phpstan-rules

README 文档

README

Inplace fixture asserts and autofix for PHPStan rules. No more manual line adjustments in tests when new code is added to rule fixtures.

Installation

composer require --dev shipmonk/phpstan-dev

Usage

<?php declare(strict_types = 1);

use PHPStan\Rules\Rule;

/**
 * @extends RuleTestCase<YourRule>
 */
class YourRuleTest extends \ShipMonk\PHPStanDev\RuleTestCase
{
    public function testRule(): void
    {
        $this->analyzeFiles([__DIR__ . '/Data/code.php']);
    }
}

Create test fixture at code.php:

<?php

$valid = 'This is valid code';
$invalid = something(); // error: Rule error message

Key Features

In-fixture error asserts of via // error:

Mark expected errors directly in test files via PHP comments:

<?php

$validCode = 'No error expected here';
$invalidCode = forbidden(); // error: Rule error message
$alsoInvalid = another(); // error: Rule error message // error: Same-line multi errors

Autofix

Automatically generate inplace error comments during development:

public function testRule(): void
{
    $this->analyzeFiles([...], autofix: true);
}

⚠️ Important: Remove autofix: true before committing - tests will fail if autofix is enabled.

Contributing

  • Check your code by composer check
  • Autofix coding-style by composer fix:cs
  • All functionality must be tested

License

MIT

统计信息

  • 总下载量: 14.08k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-06