Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpstan Dev Laravel Package

shipmonk/phpstan-dev

Utilities for developing PHPStan rules: write expected errors directly in fixture files using // error: comments and avoid brittle line-number assertions. Includes an autofix mode to generate/update inline error comments during rule development.

View on GitHub
Deep Wiki
Context7

PHPStan Rules Development Utilities

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

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log