phanalist

E0025: The “Stuffed Filing Cabinet” Rule (Lines of Code per File)

Imagine opening a filing cabinet drawer and finding 1000 pages crammed in. Good luck finding what you need. LOC per File measures the total number of lines in a PHP file. Files that are too large force you to scroll endlessly and make it hard to find anything.

How the rule works

We count every line in the file. The default threshold is 500 lines. A file exceeding this should probably be split into multiple files, each with a single responsibility.


❌ The “Massive File” Example

One file containing everything — this is a maintenance nightmare.

<?php

namespace App;

class OrderManager
{
    // 300 lines of order logic...
    // 200 lines of billing logic...
    // 150 lines of shipping logic...
}

✅ The “Split APart” Example

Each file has a single purpose and fits easily on one screen.

<?php

namespace App;

class OrderProcessor
{
    // ~50 lines
}

Configuration

rules:
  E0025:
    max_loc: 500

The Junior’s Rule of Thumb:

If Phanalist flags your file as too long, you are stuffing too many responsibilities into one drawer. Split it into smaller files organized by feature or responsibility.