fleetlint Policy for a fleet of repositories
v0.10
Getting started

repo/toolchain-pinned/php

Toolchain version is pinned

Implements repo/toolchain-pinned for php.

Severitywarning
Tiers1, 2
Stacksphp
Scopeeach
Kindexpr
Sourcelibrary v0.7.0
Selected byfleetlint-recommended@v0.7.0

Requirement

.php-version names a version, composer.json’s config.platform.php fixes the PHP version dependencies are resolved for, or .tool-versions/mise or devbox.json names php with a version. In devbox.json the package needs a version (php@8.4, php84); @latest does not count.

Why

Without a pin, every machine and every CI run builds with whatever compiler or runtime happens to be installed, and failures cannot be reproduced.

Check

["", "../", "../../", "../../../"].exists(d, file(d + ".php-version") && scan(d + ".php-version", r'^\s*\d').size() > 0) || (file("composer.json") && text("composer.json").matches(r'"platform"\s*:\s*\{[^}]*"php"\s*:\s*"\d')) || ["", "../", "../../", "../../../"].exists(d, file(d + ".tool-versions") && scan(d + ".tool-versions", r'^\s*(php)\s+\S*\d').size() > 0) || ["", "../", "../../", "../../../"].exists(d, ["mise.toml", ".mise.toml", ".config/mise.toml", ".config/mise/config.toml", "mise/config.toml"].exists(n,
     file(d + n) && scan(d + n, r'^\s*"?(php)"?\s*=\s*[^#\n]*\d').size() > 0))
|| ["", "../", "../../", "../../../"].exists(d, file(d + "devbox.json") && text(d + "devbox.json").matches(r'"(php)(@v?\d|"\s*:\s*("v?\d|\{[^}]*"version"\s*:\s*"v?\d))|"(php\d+)(@[^"]*)?"'))

Fix

Write the PHP version to .php-version (setup-php reads it).

Agent instruction: Add the stack’s toolchain pin set to the version currently installed; do not upgrade the toolchain in the same change.

A finding of this rule points at .php-version.

Sources


Generated by fleetlint docs from catalog v0.7.0.