PHP 4 — Zend Engine 1, Classes Without OOP
debt(d3/e3/b3/t7)
Closest to 'default linter catches the common case' (d3). The term's detection_hints list rector and phpcs, both of which can flag PHP 4 patterns like the `var` keyword via code patterns (\bvar \$). These are standard tools commonly run in CI pipelines, placing detection squarely at the linter/default-tool level rather than requiring specialist analysis or manual review.
Closest to 'simple parameterised fix' (e3). The quick_fix summary describes replacing `var` with visibility modifiers, adding type hints, and removing pass-by-reference object hacks — a pattern-level replacement within a file or small component. It is more than a single-line patch but does not span architectural concerns, aligning with e3.
Closest to 'localised tax' (b3). The applies_to scope is PHP 4.0–4.4 web contexts only, meaning this is legacy code that, if present, is contained to a specific (and obsolete) codebase segment. Modern codebases won't carry this weight at all; it only burdens teams maintaining very old PHP code, making it a localised rather than system-wide tax.
Closest to 'serious trap' (t7). The misconception field explicitly states that PHP 4 objects were passed by value (copied), not by reference — directly contradicting how modern PHP 5+ OOP works and how developers from other OO languages (Java, Python, Ruby) expect objects to behave. This is a behavioral contradiction versus a similar concept in the same language's later version, making it a serious trap that can cause subtle, hard-to-diagnose bugs in any code ported from PHP 4.
TL;DR
Explanation
PHP 4 (May 2000) introduced: Zend Engine 1.0 (rewrote by Suraski and Gutmans), sessions, output buffering, basic class syntax (class Foo { var $x; function bar() {} }). Critical limitation: objects were copied by value on assignment, not by reference — $b = $a cloned the object. This made OOP impractical at scale. PHP 4 reached End of Life in 2007. The era defined PHP as a web scripting language: register_globals on by default, magic_quotes active, mysql_ functions prevalent. Many legacy codebases still carry PHP 4 patterns.
Common Misconception
Why It Matters
Common Mistakes
- Using PHP 4 class patterns (var keyword, no visibility, no type hints) in modern code.
- Forgetting PHP 4 had no try/catch — error handling was purely procedural.
Code Examples
<?php
class User {
var $name; // PHP 4 style
function getName() {
return $this->name;
}
}
<?php
class User {
public function __construct(
private readonly string $name
) {}
public function getName(): string {
return $this->name;
}
}