- Date: 2026-08-16
- Method: Laravel Auditor (Discover → Scope → Verify → Report). Read-only; no application code modified.
- Auditor output: All findings verified against code, routes, schema, configuration, and the running test suite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use PhpParser\Comment; | |
| use PhpParser\Comment\Doc; | |
| use PhpParser\Node; | |
| use Rector\Core\Rector\AbstractRector; | |
| final class RemoveUnnecessaryCommentsRector extends AbstractRector | |
| { | |
| private const ALLOWED = [ |
A clean and categorized reference of the most useful constants in PHP.
Includes descriptions and sample outputs for context. Fully valid for PHP 8.3 and safe for PHP 8.4.
| Constant | Description | Example Output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * TimeoutGuard — A lightweight timeout wrapper using PHP ticks. | |
| * | |
| * This lets you interrupt execution of any callable if it exceeds a time limit. | |
| * Works even on Windows (unlike pcntl). | |
| * | |
| * ⚠️ Requires `declare(ticks=1);` | |
| */ |
- Laravel's model scopes don't work with Scout (search).
- Reusing scopes across models means copying code OR using traits (but Scout still breaks).
- Leads to duplicate query logic.
Instead of defining scopes inside models, create scope classes that can be used in both Eloquent & Scout queries!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Artisan::command('generate-tests', function () { | |
| // Define the base path where class files are located | |
| $files = File::allFiles(base_path('app/Classes')); | |
| foreach ($files as $file) { | |
| // Get the relative path of the current class file and apply string manipulations | |
| $path = str($file->getRelativePathname()) | |
| ->replace('.php', '') // Remove the .php extension | |
| ->replace('/', '\\') // Replace directory slashes with namespace slashes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // In Laravel, we have the $with property to automatically load a relationship every time. | |
| // However, selecting a specific column by default for every model query doesn't seem possible... | |
| // but here's a hack I found! | |
| class Post extends Model | |
| { | |
| // To automatically load the 'author' relationship on every query | |
| protected $with = ['author']; |
NewerOlder