php-specialist
PHP Specialist guides you through modern PHP 8.x development with language features like enums, readonly properties, and match expressions. It covers the complete toolchain: PSR interoperability, Composer dependency management, static analysis configuration, and coding standards enforcement. Apply it whenever you're authoring, reviewing, or refactoring PHP code to ensure type safety and architectural correctness.
PHP Specialist helps you write type-safe, modern PHP 8.x code using enums, readonly properties, PSR standards, and SOLID principles.
AI-generated summary based on this skill's SKILL.md
Install
Pixel-Process-UG/superkit-agents/php-specialist · repository language: TypeScript
git clone https://github.com/Pixel-Process-UG/superkit-agents
cp -r superkit-agents/templates/skills/php-specialist ~/.claude/skills/php-specialistnpx skillfed install Pixel-Process-UG/superkit-agents/php-specialistFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I write modern PHP 8 code with type safety?
PHP Specialist teaches you to leverage PHP 8.x's type system through union and intersection types, strict type declarations, and constructor promotion. Use `declare(strict_types=1)` at file start, apply named arguments for clarity, and adopt match expressions over switch for exhaustive pattern matching. Combine readonly properties (PHP 8.1+) and enums to build immutable, self-documenting structures that static analyzers can verify.
What are PHP 8.1 enums and readonly properties?
PHP Specialist covers enums as type-safe alternatives to class constants, supporting both pure and backed variants (string/int). Readonly properties prevent reassignment after initialization, enforcing immutability at the language level. Together they eliminate entire categories of bugs: enums guarantee valid states, readonly prevents accidental mutation. Use backed enums for database mapping; combine readonly with constructor promotion for concise, safe value objects.
How do I set up PHPStan static analysis?
PHP Specialist guides PHPStan configuration from baseline through level 9 (strictest). Create `phpstan.neon`, set your desired level, and exclude test/vendor directories. Integrate with your CI pipeline to catch type mismatches, undefined methods, and logic errors before runtime. Pair PHPStan with Psalm for complementary checks. Both tools enforce the type contracts your code declares, making refactoring safer and reducing production bugs.
How should I configure PSR-4 autoloading with Composer?
PHP Specialist recommends defining PSR-4 namespaces in your `composer.json` autoload section, mapping namespace prefixes to directory paths. Run `composer dump-autoload` to generate optimized class maps. This standard ensures your code integrates seamlessly with any PHP ecosystem tool. Combine PSR-4 with strict_types and static analysis to create a foundation where classes load predictably and type violations surface immediately.
How do I apply SOLID principles and interface-driven design in PHP?
PHP Specialist teaches dependency injection through constructor parameters typed to interfaces, not concrete classes. Define narrow, focused interfaces; implement them in multiple concrete classes. Use type hints everywhere to enforce contracts. This approach decouples components, simplifies testing (mock interfaces easily), and makes refactoring safe. Combined with static analysis, interface-driven design catches violations at analysis time, not runtime.
What's the best way to build immutable value objects and DTOs?
PHP Specialist advocates readonly properties (PHP 8.2 readonly classes for full immutability) paired with constructor promotion for compact syntax. Validate state in the constructor; throw custom exceptions for invalid input. Use backed enums for constrained fields. Build custom exception hierarchies inheriting from base exceptions for fine-grained error handling. These patterns create self-validating, type-safe data structures that static analyzers trust implicitly.
SKILL.md
rendered from the published skill — quoted content, verbatim
PHP Specialist
Overview
Write modern, type-safe, and maintainable PHP 8.x code adhering to PSR standards and SOLID principles. This skill covers the full modern PHP toolchain: language features introduced in PHP 8.0 through 8.4, PSR interoperability standards, Composer dependency management, static analysis with PHPStan and Psalm, coding style enforcement with PHP CS Fixer and Pint, and architectural patterns that leverage the type system for correctness at compile time rather than runtime.
Apply this skill whenever PHP code is being written, reviewed, or refactored in any framework or standalone context.
Multi-Phase Process
Phase 1: Environment Assessment
- Identify PHP version
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
templates/skills/php-specialist/SKILL.md