skillfed

php

PHP guides you through modern language conventions, strict type declarations, and contemporary idioms for PHP 8.5+. It covers naming standards, type system rules, enumerations, class design patterns, and functional programming constructs to keep your code explicit and maintainable.

PHP helps you write and refactor code using modern conventions, strict typing, and PHP 8.5+ idioms.

AI-generated summary based on this skill's SKILL.md

18 0 MIT updated by xobotyi

Install

xobotyi/cc-foundry/php · repository language: JavaScript

git clone https://github.com/xobotyi/cc-foundry
cp -r cc-foundry/plugins/php/skills/php ~/.claude/skills/php
npx skillfed install xobotyi/cc-foundry/php

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

What does PHP help with regarding coding conventions and best practices?

PHP guides you through modern language conventions, strict type declarations, and contemporary idioms for PHP 8.5+. It covers naming standards, type system rules, enumerations, class design patterns, and functional programming constructs to keep your code explicit and maintainable.

How do I write PHP with strict types enabled?

PHP teaches strict typing by declaring `declare(strict_types=1);` at the top of your files. This enforces type coercion rules, requiring function parameters and return types to match exactly. PHP covers type declarations for scalars, union types, intersection types, and nullable types to catch errors early and improve code clarity.

What PHP 8.5 modern syntax and type system features does this cover?

PHP covers PHP 8.5+ features including readonly classes and properties, constructor promotion, property hooks, enums for type-safe constants, first-class callables, arrow functions, and match expressions. It explains the type system's variance rules, union and intersection types, and how these features reduce boilerplate while maintaining strict safety.

How should I structure a PHP project with Composer and autoloading?

PHP guides you through setting up composer.json with PSR-4 autoloading namespaces, organizing source code in src/ directories, and configuring require and require-dev dependencies. It covers best practices for project structure, version constraints, and how autoloading integrates with modern PHP tooling for clean dependency management.

What naming conventions does PHP recommend for classes, methods, and variables?

PHP teaches PascalCase for class names, camelCase for method and variable names, and UPPER_SNAKE_CASE for constants. It emphasizes descriptive, intention-revealing names and explains interface naming conventions (often prefixed with I or suffixed with Interface) to make code self-documenting and maintainable.

How can I refactor legacy PHP code to modern standards?

PHP provides strategies for incrementally modernizing legacy code: adding strict type declarations, replacing switch statements with match expressions, extracting magic values into enums, using constructor promotion to simplify class initialization, and applying dependency injection patterns. It covers LSP tools for safe navigation and refactoring of complex codebases.

SKILL.md

rendered from the published skill — quoted content, verbatim

PHP

Strict types, explicit contracts, no magic. If a class needs a docblock to explain what its properties do, the properties are named wrong.

PHP 8.5+ is the baseline. Use modern syntax unconditionally — union types, enums, readonly classes, property hooks, named arguments, match, pipe operator. No backward compatibility with older PHP versions unless the project explicitly requires it.

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

References

  • Type system${CLAUDE_SKILL_DIR}/references/typing.md — Union/intersection/DNF types, nullable patterns, typed properties and constants, coercion rules, variance
  • OOP patterns${CLAUDE_SKILL_DIR}/references/oop.md — Interfaces, traits, readonly, property hooks, enums, constructor promotion, lazy objects, magic methods
  • Concurrency${CLAUDE_SKILL_DIR}/references/concurrency.md — Fiber API, generator coroutines, comparison table, async library guidance -

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 6 files
plugins/php/skills/php/.dev/reference-inventory.json
plugins/php/skills/php/SKILL.md
plugins/php/skills/php/references/concurrency.md
plugins/php/skills/php/references/oop.md
plugins/php/skills/php/references/packaging.md
plugins/php/skills/php/references/typing.md

Related skills

Tags

type-safety modern-php code-style oop-patterns functional-programming static-analysis dependency-management immutability error-handling