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
Php Code
symkit/bundle-ai-kit
cursor
code-style
phpstan
strict-types
composer-plugin
dependency-injection
readonly-classes
typing

Strict PHP code style for Composer plugin source code

Install
php artisan boost:add-skill symkit/bundle-ai-kit

Save this content to: .cursor/rules/php-code.mdc

# PHP Code Style — Composer Plugin

## Mandatory Header

Every PHP file starts with `declare(strict_types=1)`.

## Classes

- `final readonly class` for: value objects (`SyncContext`), resolvers
- `final class` (without `readonly`) for: `AiRulesInstaller`, `Plugin`
- `Plugin` is `final class` — Composer instantiates with no args, optional constructor params for tests

## Typing

- All parameters, return types, and properties must be typed
- No `mixed` except with a comment justifying why
- PHPStan level 9: `@param list<string>` for skill name lists
- Nullable optional params: `?SyncContextResolverInterface $contextResolver = null`
- Return `?SyncContext` from resolver

## Constructor Patterns

```php
final readonly class DefaultSyncContextResolver implements SyncContextResolverInterface
{
    public function __construct(
        private string $packageName,
    ) {
    }
}
```

Plugin (tests may inject resolver/installer):

```php
public function __construct(
    ?SyncContextResolverInterface $contextResolver = null,
    ?AiRulesInstaller $installer = null,
) {
    $this->contextResolver = $contextResolver ?? DefaultSyncContextResolver::forBundleAiKit();
    $this->installer = $installer ?? new AiRulesInstaller();
}
```

## Language Features

- Native function prefix: `\is_dir()`, `\mkdir()`, `\copy()`, etc.
- Early return, trailing commas in multiline

## Namespace Organization

- `Contract/` — `SyncContextResolverInterface`
- `Context/` — `SyncContext`, resolver, `SkillNamesDiscoverer`
- `Installer/` — `AiRulesInstaller`
- Root — `Plugin` only

## Forbidden

- `new ConcreteService()` outside Plugin constructor (except tests)
- Setter injection
- `@phpstan-ignore` without comment

## After Every Change

`make cs-fix` then `make phpstan`

PHP Code Style — Composer Plugin

Mandatory Header

Every PHP file starts with declare(strict_types=1).

Classes

  • final readonly class for: value objects (SyncContext), resolvers
  • final class (without readonly) for: AiRulesInstaller, Plugin
  • Plugin is final class — Composer instantiates with no args, optional constructor params for tests

Typing

  • All parameters, return types, and properties must be typed
  • No mixed except with a comment justifying why
  • PHPStan level 9: @param list<string> for skill name lists
  • Nullable optional params: ?SyncContextResolverInterface $contextResolver = null
  • Return ?SyncContext from resolver

Constructor Patterns

final readonly class DefaultSyncContextResolver implements SyncContextResolverInterface
{
    public function __construct(
        private string $packageName,
    ) {
    }
}

Plugin (tests may inject resolver/installer):

public function __construct(
    ?SyncContextResolverInterface $contextResolver = null,
    ?AiRulesInstaller $installer = null,
) {
    $this->contextResolver = $contextResolver ?? DefaultSyncContextResolver::forBundleAiKit();
    $this->installer = $installer ?? new AiRulesInstaller();
}

Language Features

  • Native function prefix: \is_dir(), \mkdir(), \copy(), etc.
  • Early return, trailing commas in multiline

Namespace Organization

  • Contract/ — SyncContextResolverInterface
  • Context/ — SyncContext, resolver, SkillNamesDiscoverer
  • Installer/ — AiRulesInstaller
  • Root — Plugin only

Forbidden

  • new ConcreteService() outside Plugin constructor (except tests)
  • Setter injection
  • @phpstan-ignore without comment

After Every Change

make cs-fix then make phpstan

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.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib