NaifyViewExtension\Dialect\Smarty\Migration\SmartyFilterInventory クラス

SmartyFilterInventory — テンプレートで使われているフィルターを棚卸しする

組み込み・既知の独自フィルター・追加実装の候補に分類する。字句走査による調査なので、実行時の互換性判定には使わない。

使用例

use NaifyView\NaifyView;
use NaifyViewExtension\NaifyViewExtension;
use NaifyViewExtension\Dialect\Smarty\Migration\SmartyFilterInventory;

NaifyView::boot();
NaifyViewExtension::boot();
$report = SmartyFilterInventory::scanPaths(__DIR__ . '/views', [
    'extensions' => ['tpl'],
]);
echo SmartyFilterInventory::formatTextReport($report);

メソッド

メソッド説明
public static scanPaths(array|string $paths, array $options = '...'): array 指定したディレクトリを走査し、調査結果をまとめる
標準ではtplとhtmlを対象にする。独自の区切り文字はoptionsで指定する。
public static formatTextReport(array $report): string 棚卸し結果を、ターミナルで読めるテキストに整える
private static scanTemplate(string $template, string $filePath, string $openDelimiter, string $closeDelimiter): array
private static scanTagBodyForFilters(string $body, string $template, int $bodyOffset, string $filePath): array
private static builtInFilterNames(): array
private static classifyFilterName(string $filterName, array $builtInLookup, array $knownCustomLookup): string
private static normalizeRoots(array|string $paths): array
private static normalizeDelimiters(array $delimiters): array
private static normalizeExtensions(array $extensions): array
private static normalizeFilterNameList(array $filterNames): array
private static normalizeFilterName(string $filterName): string
private static iterateTemplateFiles(string $root, array $extensions): Generator
private static readFileContentsIfAvailable(string $path): ?string
private static readTagBody(string $template, int $offset, string $openDelimiter, string $closeDelimiter): array
private static consumeLiteralBlock(string $template, int $offset, string $openDelimiter, string $closeDelimiter): int
private static getTagName(string $body): string
private static trimSnippet(string $snippet): string
private static offsetToLine(string $source, int $offset): int
private static isEscaped(string $source, int $offset): bool
private static isIdentifierStart(string $char): bool
private static isIdentifierChar(string $char): bool
private static sortInventory(array $inventory): void