haphpiness

These are things in PHP which make me genuinely_happy();

Heredoc/Nowdoc Flexibility

PHP 7.3 made heredocs and nowdocs actually usable by allowing the closing marker to be indented, and letting heredocs be used in any expression context. No more breaking your code's indentation for multi-line strings.

// Before PHP 7.3: closing marker must be at column 0
// This breaks indentation in methods, conditions, everywhere
function render() {
    $html = <<<HTML
<div class="card">
    <h2>{$title}</h2>
    <p>{$body}</p>
</div>
HTML;  // ← HAD to be here, column 0. Ugly.
}

// After PHP 7.3: indented closing marker, content is de-indented
function render() {
    $html = <<<HTML
        <div class="card">
            <h2>{$title}</h2>
            <p>{$body}</p>
        </div>
        HTML;  // ← indented with the code. Clean.
}

// Can now be used in function arguments directly
$response = response(<<<JSON
    {
        "status": "ok",
        "data": {$payload}
    }
    JSON);

// Nowdoc (no interpolation) works the same way
$query = <<<'SQL'
    SELECT users.*, COUNT(orders.id) as order_count
    FROM users
    LEFT JOIN orders ON orders.user_id = users.id
    GROUP BY users.id
    SQL;

This seemingly small change had a huge impact on code readability. SQL queries, HTML templates, JSON fixtures, and multi-line strings can now live inside your code without destroying the visual structure.

Significance: Readability

Code formatting isn't cosmetic — it's a communication tool. When multi-line strings forced you to break indentation, they made the surrounding code harder to read. Flexible heredocs let your string literals live harmoniously within your code's visual structure.