MMOframework
Pourquoi l'IA Playground Bibliothèques Développeurs Agence
FR EN
Créer un projet en direct
Index

LinkAudit

MMO\admin\helpers · 1 symbole · générée le 30 Nov 2026

class

LinkAudit

LinkAudit.php:34

The hard-coded links audit of one package (a library of libs/, an application, one of its modules): the links and filenames written as they are on one machine, where the framework resolves them from where the package runs -- \MMO\url('{alias}/...') and \MMO\filename('{alias}/...') in php, MMO.url('{alias}/...') and MMO.filename('{alias}/...') in javascript. What the root hub's php tools/mmo.php links reports.

class MMO\admin\helpers\LinkAudit use MMO\admin\helpers\tIgnoreFile
Espace de noms
MMO\admin\helpers
Utilise les traits
tIgnoreFile
The rules ([`RULES`](https://mmoframework.fr/documentation/mmo.admin/php/helpers/LinkAudit.md#linkaudit-rules)), each on the kinds of file it says: - **machine-path**: an absolute path of a machine (`/home/...`, `~/dev/...`, `/var/www/...`, `C:\Users\...`); - **local-url**: a url of this machine (`http://localhost/...`, `http://127.0.0.1/...`); - **root-link**, **root-fetch**, **root-redirect**, **root-css**: a link from the root of the domain (`href="/x"`, `fetch('/api')`, `Location: /x`, `url(/font.woff2)`): wrong as soon as the site is not at the domain's root; - **host-concat**: a url glued from the request's host or the browser's location; - **dir-climb**: `__DIR__ . '/../../..'`, `dirname(__DIR__, 3)` climbing out of the package: another package's file. A climb that stays in the package (`__DIR__ . '/../templates'` from `src/`) is its own file: not reported. The boards and checklists are scanned too: a ticket, a check, a command name their pages relative to the site (`home/hse`), and their folders with aliases (`cd {root} && phpunit`) -- but a board's `*.sync.json`, GitHub's state. Not scanned: the folders [`SKIP_FOLDERS`](https://mmoframework.fr/documentation/mmo.admin/php/helpers/LinkAudit.md#linkaudit-skip-folders) anywhere, a `bin` folder (bundles built from the sources), a folder that is a package of its own (an `mmo.json`) or a symbolic link, the files [`SKIP_FILES`](https://mmoframework.fr/documentation/mmo.admin/php/helpers/LinkAudit.md#linkaudit-skip-files), a line that is a comment, the `require` of mmo.core's bootstrap (it runs before the application, and its aliases, exist), and what the package's `links.ignore` lists ([`tIgnoreFile`](https://mmoframework.fr/documentation/mmo.admin/php/helpers/tIgnoreFile.md#tignorefile)): a remote server's path, an external tool's configuration... It is regex and line based: pragmatic, made to have few false positives rather than to miss nothing.
$audit = new LinkAudit('/home/me/dev/src/my.oviepro'); $report = $audit->run(); // ['findings' => [['local-url', 'configs/config.json', 182, '...'], ...], 'counts' => [...]]

Index

COMMENTa line that is only a comment
EXTENSIONSthe extensions scanned
RULESrule => [regex, the extensions it applies to (null: every one scanned), what to write instead]
SKIP_FILESthe files never scanned: an external tool's, or a deployment's (a server's paths and urls are its data)
SKIP_FOLDERSthe folders never scanned, at any depth
files readonly
findings
folder readonlythe folder of the package, without its ending /
ignore
ignored
lines
scanned
Climbs($match) static
isIgnored($file, $line)
readIgnore($name)
run()Scan the package.
Scan($text, $extension, $depth) staticThe findings of one text, as the rules see it: what a test, or an editor, asks of a file without writing it.
scanFile($file, $rel)
Walk($folder) staticEvery file below a folder that is scanned.
__construct($folder, $files)

Constantes5

COMMENT

a line that is only a comment

const COMMENT = '~^\\s*(?://|/?\\*|#(?![\\w-]*\\s*\\{)|<!--)~'

EXTENSIONS

the extensions scanned

const EXTENSIONS = ['php', 'phtml', 'js', 'jhs', 'json', 'scs', 'css', 'html']

RULES

rule => [regex, the extensions it applies to (null: every one scanned), what to write instead]

const RULES = […8 items]

SKIP_FILES

the files never scanned: an external tool's, or a deployment's (a server's paths and urls are its data)

const SKIP_FILES = […6 items]

SKIP_FOLDERS

the folders never scanned, at any depth

const SKIP_FOLDERS = […12 items]

Propriétés7

files

readonly
readonly ?string $files
Type
null | string

findings

protected array $findings = []
Type
array

folder

readonly

the folder of the package, without its ending /

readonly string $folder
Type
string

ignore

protected array $ignore = []
Type
array

ignored

protected int $ignored = 0
Type
int

lines

protected array $lines = []
Type
array

scanned

protected int $scanned = 0
Type
int

Méthodes8

Climbs($match)

staticLinkAudit.php:148
protected static function Climbs(array $match): int
$matcharray
retourneinthow many folders a dir-climb match goes up from __DIR__

isIgnored($file, $line)

tIgnoreFile.php:38
protected function isIgnored(string $file, int $line): bool
$filestring
$lineint
retourneboolwhether the ignore file leaves out a finding of this file (relative to the package) and line

readIgnore($name)

tIgnoreFile.php:24
protected function readIgnore(string $name): void
$namestringthe ignore file, in the package's folder
retournevoid

run()

LinkAudit.php:112

Scan the package.

function run(): array
retournearraylist<array{0: string, 1: string, 2: int, 3: string}>, counts: array<string, int>}

Scan($text, $extension, $depth)

staticLinkAudit.php:133

The findings of one text, as the rules see it: what a test, or an editor, asks of a file without writing it.

static function Scan(string $text, string $extension, ?int $depth = null): array
$textstringthe file's content
$extensionstringits kind (php, jhs...)
$depth = nullnull | inthow deep the file is in its package (src/helpers/X.php: 2), for dir-climb; null: every climb of two levels or more is reported
retournearraystring, 1: int, 2: string}> rule, line, text

__construct($folder, $files)

LinkAudit.php:81
function __construct(string $folder, ?string $files = null)
$folderstringthe package's folder (its mmo.json)
$files = nullnull | stringonly the files whose path (relative to the package) matches this glob, or is under this folder