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.
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.
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...
}
Each file has a single purpose and fits easily on one screen.
<?php
namespace App;
class OrderProcessor
{
// ~50 lines
}
rules:
E0025:
max_loc: 500
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.