Loading...
Loading...
Personal PHP conventions enforced when creating, modifying, or planning code that will touch PHP files. Covers strict types, function imports, testing philosophy, class design, observability, and planning practices. Activate whenever working on PHP code.
npx skill4agent add cosmastech/skills php-conventionsdeclare(strict_types=1);use function array_key_exists;
use function sprintf;
use function count;
use const JSON_THROW_ON_ERROR;#[Override]#[Override]final readonlyfinal readonlyreadonlyfinalarray<array-key, mixed>@phpstan-type/**
* @phpstan-type OrderContext array{orderId: int, shopId: int, items: list<LineItemData>}
*/phpstan-type-import@phpstan-ignore// @phpstan-ignore argument.type (We have already verified the type above)@phpstan-ignore-erOrderCreatorFinancialOutcomeDeterminerRefundCalculatorresolve()app()creatingsavedfinal class ShopifyFailure extends RuntimeException
{
public function __construct(
string $message,
public readonly Response $response,
public readonly bool $isRetryable = false,
) {
parent::__construct($message);
}
public static function fromResponse(Response $response): self
{
return new self(
message: sprintf('Shopify returned %d: %s', $response->status(), $response->body()),
response: $response,
isRetryable: $response->status() >= 500,
);
}
}// Given a user without permissions
$user = User::factory()->create(['role' => 'viewer']);
// When they attempt to update settings
$response = $this->actingAs($user)->put('/settings', ['theme' => 'dark']);
// Then the request is forbidden
$response->assertForbidden();GivenWhenThen{condition}_{theMethodBeingCalled}_{then}#[Test]test_$this->assertEquals()self::assertEquals()$this->assert*