### Development commands Source: https://github.com/boring-o11y/wirestan/blob/main/README.md Install dependencies, run tests, and analyse the rule itself. ```sh composer install composer test # phpunit composer phpstan # analyse the rule itself ``` -------------------------------- ### Install wirestan via Composer Source: https://github.com/boring-o11y/wirestan/blob/main/README.md Install the package as a dev dependency using Composer. Requires PHP ^8.2, PHPStan ^2.0, and Livewire 3 or 4 in the analysed project. ```sh composer require --dev boring-o11y/wirestan ``` -------------------------------- ### PHP: Example of LockedPublicPropertyRule violation Source: https://github.com/boring-o11y/wirestan/blob/main/README.md Shows a Livewire component with a public property that is never reassigned outside seed methods and lacks #[Locked], which the rule flags. The property $bookingId is only assigned in mount(), while $note is reassigned in saveNote() and is therefore fine. ```php use Livewire\Component; class ShowBooking extends Component { public int $bookingId = 0; // ← flagged public string $note = ''; // fine: reassigned by saveNote() public function mount(int $bookingId): void { $this->bookingId = $bookingId; } public function saveNote(string $note): void { $this->note = $note; } } ``` -------------------------------- ### Run PHPStan analysis Source: https://github.com/boring-o11y/wirestan/blob/main/README.md Run the normal PHPStan analysis command to execute the wirestan rule as part of your CI. ```sh vendor/bin/phpstan analyse ``` -------------------------------- ### Generate PHPStan baseline Source: https://github.com/boring-o11y/wirestan/blob/main/README.md Run this command to generate a baseline for existing violations, so the rule only fails on new ones. ```sh vendor/bin/phpstan analyse --generate-baseline ``` -------------------------------- ### NEON: Configure reservedProperties in phpstan.neon Source: https://github.com/boring-o11y/wirestan/blob/main/README.md Shows how to override the default list of framework-reserved properties that the rule skips. Add your own convention property names to the list. ```neon parameters: wirestan: reservedProperties: - listeners - rules - messages - validationAttributes - queryString - paginationTheme - myOwnConvention ``` -------------------------------- ### Register wirestan rules in phpstan.neon Source: https://github.com/boring-o11y/wirestan/blob/main/README.md Include the bundled extension.neon from your phpstan.neon or phpstan.neon.dist when not using phpstan/extension-installer. This registers the rule automatically. ```neon includes: - vendor/boring-o11y/wirestan/extension.neon ``` -------------------------------- ### Silence individual finding with error identifier Source: https://github.com/boring-o11y/wirestan/blob/main/README.md Use this NEON configuration to ignore a specific error identifier for a given path. ```neon parameters: ignoreErrors: - identifier: boringO11yWirestan.lockedPublicProperty path: app/Livewire/SomeComponent.php ``` -------------------------------- ### PHP: Fix with #[Locked] attribute Source: https://github.com/boring-o11y/wirestan/blob/main/README.md The recommended fix: add the #[Locked] attribute to the property. This prevents client-side mutation via $wire.set. ```php use Livewire\Attributes\Locked; #[Locked] public int $bookingId = 0; ``` -------------------------------- ### Plain text: Rule violation message Source: https://github.com/boring-o11y/wirestan/blob/main/README.md The exact error message emitted by the rule when a public property is never reassigned outside lifecycle methods and lacks #[Locked]. It warns that the client can mutate the property via $wire.set. ```text Livewire public property ShowBooking::$bookingId is never reassigned outside lifecycle methods. It must be marked #[Livewire\Attributes\Locked] — otherwise the client can mutate it via $wire.set. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.