elegant-objects

Vérifie la conformité du code PHP aux principes Elegant Objects de Yegor Bugayenko. Analyse un fichier spécifique ou tous les fichiers modifiés dans la branche.

⭐6stars🔀0forks📁View on GitHub🕐Updated Jan 2, 2026⬇️1downloads

When & Why to Use This Skill

The Elegant Objects Reviewer is a specialized Claude skill designed to automate PHP code audits based on Yegor Bugayenko's 'Elegant Objects' philosophy. It performs deep static analysis on specific files or entire git branches to enforce strict object-oriented principles, such as mandatory final classes, the absence of getters/setters, and CQRS compliance. By providing a detailed report and a numerical quality score, it helps developers maintain high architectural standards and clean, maintainable codebases.

Use Cases

  • Pre-commit Code Auditing: Automatically verify if a specific PHP file complies with Elegant Objects rules before pushing changes to the repository.
  • Pull Request Quality Gates: Analyze all modified files within a branch to ensure new contributions don't introduce 'code smells' like static methods or null returns.
  • Legacy Code Refactoring: Identify non-compliant patterns in existing projects to prioritize refactoring tasks and move toward a more pure object-oriented architecture.
  • Developer Mentorship and Training: Use the generated reports and scores to teach team members about strict OO principles and best practices in PHP development.
nameelegant-objects
description>
allowed-tools[Bash, Read, Grep, Glob]
modelsonnet

Elegant Objects Reviewer Skill

Usage

/qa:elegant-objects [fichier.php]

Sans argument : analyse les fichiers PHP modifiés dans la branche.

Workflow

  1. Déterminer fichiers à analyser (argument ou git diff)
  2. Vérifier les règles Elegant Objects
  3. Générer rapport avec score

Règles vérifiées

Classes

  • Classes final (sauf abstraites)
  • Max 4 attributs
  • Pas de getters/setters
  • Pas de méthodes statiques
  • Noms sans -er (Manager, Handler, Helper...)
  • Constructeur unique et simple

Méthodes

  • Pas de retour null
  • Pas d'argument null
  • Corps sans lignes vides ni commentaires
  • CQRS : séparation commandes/queries

Tests

  • Une assertion par test (dernière instruction)
  • Noms en français décrivant le comportement
  • Pas de setUp/tearDown

Score

  • Violation critique: -10 points
  • Violation majeure: -5 points
  • Recommandation: -2 points
  • Base: 100

References

Notes

  • Ignorer vendor/, var/, cache/
  • Controllers Symfony tolérés
  • Prioriser par criticité