NodeAbstract implements Node, \JsonSerializable interface Node { public function getType() : string; public function getSubNodeNames() : array; public function getLine() : int; public function getStartLine() : int; public function getEndLine() : int; public function getStartTokenPos() : int; public function getEndTokenPos() : int; public function getStartFilePos() : int; public function getEndFilePos() : int; public function getComments() : array; public function getDocComment(); public function setDocComment(Comment\Doc $docComment); public function setAttribute(string $key, $value); public function hasAttribute(string $key) : bool; public function getAttribute(string $key, $default = null); public function getAttributes() : array; public function setAttributes(array $attributes); }
$nodes); public function enterNode(Node $node); public function leaveNode(Node $node); public function afterTraverse(array $nodes); } ノードを見つけると、enterNode()が呼び出される。 一方、leaveNode()はすべての子ノードを走査した後に呼び出される。 A B C enterNode(A) enterNode(B) leaveNode(B) enterNode(C) leaveNode(C) leaveNode(A)
lines of code 13108 Object oriented programming Classes 1006 Interface 65 Methods 2588 Lack of cohesion of methods 1.5 Coupling Average instability 0.57 Complexity Average Cyclomatic complexity by class 22.81 Average Relative system complexity 210.65 Average Difficulty 8.71
Union Type. Type1, Type2 and Type3 are all acceptable possible types of that union type. Type1, Type2 and Type3 are each atomic types.” (Union Types) 分析工程
is never referenced in this method (see https://psalm.dev/135) function unUsedParam(string $foo): void <?php function unusedParam(string $foo): void { return; }
function int(): int { return string(); } 型の不一致 ERROR: InvalidReturnType - 略 - The declared return type 'int' for int is incorrect, got 'string' (see https://psalm.dev/011) function int(): int ERROR: InvalidReturnStatement - 略 - The inferred type 'string' does not match the declared return type 'int' for int (see https://psalm.dev/128) return string();
function int(): int { return string(); } 型の不一致 ERROR: InvalidReturnType - 略 - The declared return type 'int' for int is incorrect, got 'string' (see https://psalm.dev/011) function int(): int ERROR: InvalidReturnStatement - 略 - The inferred type 'string' does not match the declared return type 'int' for int (see https://psalm.dev/128) return string(); 検出の流れを確認する
Psalm\Internal\Analyzer\FileAnalyzer->analyze Psalm\Internal\Codebase\Analyzer->Psalm\Internal\Codebase\{closure:/略/Analyzer.php:357-368} Psalm\Internal\Codebase\Analyzer->doAnalysis Psalm\Internal\Codebase\Analyzer->analyzeFiles // 分析工程の入口 Psalm\Internal\Analyzer\ProjectAnalyzer->checkPaths Psalm\Internal\Cli\Psalm::run {main} ERROR: InvalidReturnType - 略 - The declared return type 'int' for int is incorrect, got 'string' (see https://psalm.dev/011) function int(): int
has completed its analysis. Use this hook if you want to do something with the analysis results.” (Psalm API) interface AfterAnalysisInterface { /** * Called after analysis is complete */ public static function afterAnalysis(AfterAnalysisEvent $event): void; }