team-mate-pro/tmp-standards

TMP coding standards, PHPStan rules, and architectural guidelines

Maintainers

Package info

github.com/team-mate-pro/tmp-standards

Type:symfony-bundle

pkg:composer/team-mate-pro/tmp-standards

Statistics

Installs: 823

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.1.0 2026-03-27 12:41 UTC

This package is auto-updated.

Last update: 2026-03-29 12:38:26 UTC


README

A Composer package aggregating coding standards, architectural guidelines, and PHPStan rules for TMP organization.

Check Methods

Each standard defines HOW it should be verified. Use this table to understand how to check compliance:

┌─────────────┬──────────────────────────────────────────────────────────────┐
│ Method      │ How to Check                                                 │
├─────────────┼──────────────────────────────────────────────────────────────┤
│ PHPSTAN     │ composer phpstan                                             │
│             │ Rule configured in phpstan-extension.neon                    │
├─────────────┼──────────────────────────────────────────────────────────────┤
│ SCRIPT      │ ./vendor/team-mate-pro/tmp-standards/definitions/            │
│             │    {category}/{STANDARD_ID}.sh                               │
├─────────────┼──────────────────────────────────────────────────────────────┤
│ AI          │ claude -p "$(cat vendor/team-mate-pro/tmp-standards/         │
│             │    definitions/{category}/{STANDARD_ID}.prompt.txt)"         │
│             │    --cwd .                                                   │
├─────────────┼──────────────────────────────────────────────────────────────┤
│ MANUAL      │ Human review required - see standard definition              │
└─────────────┴──────────────────────────────────────────────────────────────┘

Project Structure

tmp-standards/
├── definitions/                    # Standard definitions (markdown + scripts/prompts)
│   ├── clean-code/
│   │   ├── CC-001-no-persist-in-creational-patterns.md
│   │   └── CC-001-no-persist-in-creational-patterns.prompt.txt  # AI prompt
│   ├── design-patterns/
│   │   └── solid/
│   │       ├── SOLID-001-single-responsibility-principle.md
│   │       ├── SOLID-001-single-responsibility-principle.prompt.txt
│   │       ├── SOLID-002-open-closed-principle.md
│   │       ├── SOLID-002-open-closed-principle.prompt.txt
│   │       ├── SOLID-003-liskov-substitution-principle.md
│   │       ├── SOLID-003-liskov-substitution-principle.prompt.txt
│   │       ├── SOLID-004-interface-segregation-principle.md
│   │       ├── SOLID-004-interface-segregation-principle.prompt.txt
│   │       ├── SOLID-005-dependency-inversion-principle.md
│   │       └── SOLID-005-dependency-inversion-principle.prompt.txt
│   ├── infrastructure/
│   │   ├── INF-001-infrastructure-local-makefile.md
│   │   └── INF-001-infrastructure-local-makefile.sh  # Validation script
│   └── use-case-bundle/
│       ├── UCB-001-use-case-abstract-dto.md
│       ├── UCB-002-use-case-invoke-method.md
│       ├── UCB-003-no-auth-in-use-case.md
│       ├── UCB-004-controller-must-use-response-method.md
│       └── UCB-005-controller-action-method-suffix.md
├── src/                            # Source code
│   ├── Command/                    # Symfony console commands
│   │   ├── RunStandardCommand.php
│   │   └── RunStandardSuiteCommand.php
│   ├── PHPStan/
│   │   └── Rules/
│   │       ├── ControllerActionMethodSuffixRule.php
│   │       ├── UseCaseMustHaveInvokeMethodRule.php
│   │       └── UseCaseParameterMustBeInterfaceRule.php
│   ├── Standard/                   # Standard runner infrastructure
│   │   ├── CheckType.php
│   │   ├── StandardDefinition.php
│   │   ├── StandardRegistry.php
│   │   ├── StandardRunner.php
│   │   └── SuiteRegistry.php
│   └── TmpStandardsBundle.php
├── tests/                          # PHPUnit tests
├── docker/                         # Docker configuration
├── bin/console                     # Symfony console entrypoint
├── composer.json
├── phpstan-extension.neon          # PHPStan extension config
├── phpstan.neon                    # PHPStan config for this package
├── phpunit.xml.dist                # PHPUnit config
└── readme.md

Standard Definitions

Naming Convention

Each standard must follow the format: {PREFIX}-{NUMBER}, e.g., UCB-001 (UseCase Bundle). The standard name can be extended with a longer description.

Prefixes

Prefix Category
CC Clean Code - general coding best practices
INF Infrastructure - local development, CI/CD, tooling
SOLID Design Patterns - SOLID principles
UCB UseCase Bundle - rules for UseCase pattern

Requirements

Each standard definition should clearly specify:

  • What it applies to
  • Usage examples (correct implementation)
  • Violation examples (what to avoid)
  • Rationale for the standard

Available Standards

Code Title Check Method
CC-001 No Persistence in Creational Patterns AI
INF-001 Local Development Makefile SCRIPT
SOLID-001 Single Responsibility Principle (SRP) AI
SOLID-002 Open/Closed Principle (OCP) AI
SOLID-003 Liskov Substitution Principle (LSP) AI
SOLID-004 Interface Segregation Principle (ISP) AI
SOLID-005 Dependency Inversion Principle (DIP) AI
UCB-001 UseCase Parameters Must Be Interfaces PHPSTAN
UCB-002 UseCase Must Have Invoke Method PHPSTAN
UCB-003 No Authorization in UseCase Layer AI
UCB-004 Controller Must Use $this->response() MANUAL
UCB-005 Controller Action Methods Must Have "Action" Suffix PHPSTAN

Console Commands

The bundle provides Symfony console commands to run standard checks from your project.

Run a Single Standard

php bin/console tmp:standard {id}

Examples:

php bin/console tmp:standard test-001    # Run TEST-001 (script-based)
php bin/console tmp:standard ucb-001     # Run UCB-001 (PHPStan-based)
php bin/console tmp:standard cc-001      # Run CC-001 (AI prompt-based)
php bin/console tmp:standard inf-004     # Run INF-004 (manual — skipped with warning)

The command exits with code 1 if the check fails.

Run a Suite

php bin/console tmp:standard:suite {name}

Available suites:

Suite Standards Description
php-sf-app ARCH, CC, SOLID, INF, TEST, UCB Full check for Symfony applications
php-lib CC, SOLID, TEST Lighter check for PHP libraries
frontend FE Frontend standards
infra INF Infrastructure standards

Example:

php bin/console tmp:standard:suite php-sf-app

The suite prints a summary table at the end and exits with code 1 if any check fails.

Options

Both commands accept --project-dir to specify the project root (defaults to current directory):

php bin/console tmp:standard test-001 --project-dir=/path/to/project

Check Types

Type Requires Behavior
script bash Runs the .sh validation script
prompt Claude CLI Runs AI review via Claude CLI
phpstan composer phpstan Runs PHPStan analysis (deduplicated across suite)
manual human Skips with warning (does not fail the suite)

Bundle Registration

If your project uses Symfony Flex, the bundle registers automatically. Otherwise, add to config/bundles.php:

TeamMatePro\TmpStandards\TmpStandardsBundle::class => ['all' => true],

Validation Scripts

Some standards include validation scripts that can be run to check project compliance.

INF-001: Makefile Validator

Validates that your project's Makefile conforms to INF-001 standard.

# Run from project root
./vendor/team-mate-pro/tmp-standards/definitions/infrastructure/INF-001-infrastructure-local-makefile.sh

# Or specify a different path
./vendor/team-mate-pro/tmp-standards/definitions/infrastructure/INF-001-infrastructure-local-makefile.sh /path/to/project

What it checks:

  • Required targets: start, stop, fast, check
  • Recommended targets: help, check_fast, fix, tests
  • Required variables: docker-compose, main-container-name, vendor-dir
  • Optional include syntax (-include)
  • Self-documenting ### comments
  • Common aliases (c, cf, f, t)

Exit codes: 0 = passed, 1 = failed

PHPStan

This package provides PHPStan rules that enforce TMP coding standards.

Installation

Add the package to your project using Composer:

composer require team-mate-pro/tmp-standards --dev

For private repository, add to your composer.json:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "git@github.com:team-mate-pro/tmp-standards.git"
        }
    ]
}

Configuration

The PHPStan rules are auto-discovered via the phpstan/extension-installer. If you have it installed, no additional configuration is needed.

If you don't use the extension installer, include the extension manually in your phpstan.neon:

includes:
    - vendor/team-mate-pro/tmp-standards/phpstan-extension.neon

Available Rules

Rule Identifier Standard
UseCaseMustHaveInvokeMethodRule useCase.missingInvoke UCB-002
UseCaseParameterMustBeInterfaceRule useCase.parameterMustBeInterface UCB-001
ControllerActionMethodSuffixRule controller.actionMethodSuffix UCB-005

Disabling Rules

All rules are auto-discovered via phpstan/extension-installer. If you need to skip a specific rule in your project, disable it in your phpstan.neon using the ignoreErrors parameter with the rule identifier:

parameters:
    ignoreErrors:
        # Disable a rule entirely
        -
            identifier: controller.actionMethodSuffix

        # Disable a rule for specific paths
        -
            identifier: useCase.missingInvoke
            paths:
                - src/Legacy/*

        # Disable a rule with a message pattern
        -
            identifier: useCase.parameterMustBeInterface
            message: '#UseCase "Legacy.*" parameter#'

Available rule identifiers:

Identifier Rule
useCase.missingInvoke UseCaseMustHaveInvokeMethodRule
useCase.parameterMustBeInterface UseCaseParameterMustBeInterfaceRule
controller.actionMethodSuffix ControllerActionMethodSuffixRule

You can also ignore errors inline with PHPStan comments:

/** @phpstan-ignore controller.actionMethodSuffix */
public function legacyEndpoint(): JsonResponse
{
    // ...
}

Rule Details

UseCaseMustHaveInvokeMethodRule

Every class ending with UseCase must have an __invoke() method. Abstract classes are exempt.

// CORRECT
final readonly class CreateUserUseCase
{
    public function __invoke(CreateUserDtoInterface $dto): Result
    {
        // ...
    }
}

// VIOLATION - missing __invoke()
final readonly class CreateUserUseCase
{
    public function execute(CreateUserDtoInterface $dto): Result
    {
        // ...
    }
}

See UCB-002 for detailed documentation.

UseCaseParameterMustBeInterfaceRule

UseCase __invoke() method parameters must be interfaces or scalar types. Concrete classes are not allowed.

// CORRECT - interface parameter
public function __invoke(CreateUserDtoInterface $dto): Result

// CORRECT - scalar parameters
public function __invoke(string $userId, int $limit): Result

// VIOLATION - concrete class parameter
public function __invoke(CreateUserRequest $request): Result

See UCB-001 for detailed documentation.

ControllerActionMethodSuffixRule

Public methods in controllers extending AbstractRestApiController must end with the Action suffix. Private, protected, static, and magic methods are exempt.

// CORRECT - public methods have "Action" suffix
final class ShopController extends AbstractRestApiController
{
    public function getShopAction(): JsonResponse { /* ... */ }
    public function createShopAction(): JsonResponse { /* ... */ }

    private function logPayload(): void { /* ... */ } // exempt
}

// VIOLATION - missing "Action" suffix
final class CustomerController extends AbstractRestApiController
{
    public function importAllExternalCustomers(): JsonResponse { /* ... */ }
}

See UCB-005 for detailed documentation.

Development

Requirements

  • Docker & Docker Compose

Setup

make start

Running All Checks

make check

This runs PHPCS, PHPStan, and unit tests with 100% coverage enforcement.

Individual Commands

make phpcs          # Code style
make phpstan        # Static analysis
make tests_unit     # Unit tests with coverage
make fix            # Auto-fix code style

License

Proprietary - Team Mate Pro