Skip to content

Instantly share code, notes, and snippets.

@sukhoy94
Created April 3, 2025 06:00
Show Gist options
  • Save sukhoy94/a44b1b971dd95b6a397e24431bcebdd6 to your computer and use it in GitHub Desktop.
Save sukhoy94/a44b1b971dd95b6a397e24431bcebdd6 to your computer and use it in GitHub Desktop.
php 7.4 for claude
**General Rules
- Follow PSR-12 coding standards for consistent code style
- Use PHP 7.4.28 features (typed properties, arrow functions, null coalescing assignment operator, typed property declarations)
- Always declare strict types with declare(strict_types=1);
- Use namespaces to organize code logically
- Avoid using globals and superglobals directly
- Try to use spread operator in array expressions where appropriate
- Do not write unnecessary comments if it's obvious from code what the code does
**Plan Before Coding
- Never write new code before providing clear file structure for new classes
- First explain your idea, clearly describing class hierarchy and relationships
- Use DocBlocks for type annotations as PHP 7.4.28 doesn't support attributes
- Briefly explain the purpose and role of each class before writing code
**Code Generation Rules
- Only generate code when explicitly asked and always stick to planned structure
- Keep your code modular, extensible and clean
- Prefer composition over inheritance
- Create small, focused functions with single responsibilities
- Return early to avoid deep nesting
- Prefer immutable objects when possible
- Use iterators and generators for memory efficiency with large datasets
- Try to use value objects and DTOs instead of raw arrays and primitive types
- Leverage typed properties available in PHP 7.4
**Editing Existing Code
- Provide only necessary changes, don't rewrite entire file
- Clearly state what's been changed and why, keeping your edits minimal and precise
- Maintain the original coding style and structure
**Request Additional Information if Needed:
- If there's not enough information about existing APIs (interfaces or classes mentioned in provided code), don't guess or proceed immediately
- Always ask explicitly for the missing information before starting to write any code
- When more info is needed, request files like this:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment