CursorPHPCode Style

PHP Cursor Rules

Cursor rules for PHP: modern PHP 8 patterns, strict types, type declarations, and secure PHP development.

.cursorrules
- Add declare(strict_types=1) at the top of every PHP file
- Use union types, intersection types, and enums (PHP 8.1+) for expressiveness
- Use constructor property promotion to reduce boilerplate in classes
- Use named arguments for clarity when calling functions with many parameters
- Never use extract() or eval(); avoid variable variables
- Use the null coalescing operator (??) and nullsafe operator (?->) consistently
- Use Composer for all dependency management; never manual file includes
- Follow PSR-12 coding standard; use PHP-CS-Fixer in CI

How to use with Cursor

Create a `.cursorrules` file in your project root and paste these rules. Cursor reads this automatically on every AI interaction.

#php#php8#strict-types#cursor#coding-rules

Related Rules