patbator / lachesis
Requires
- composer-runtime-api: ^2.2
- nikic/php-parser: ^5.1
- symfony/console: ^7.1
- symfony/finder: ^7.1
Requires (Dev)
- phpunit/phpunit: ^11.2
This package is auto-updated.
Last update: 2024-09-29 19:52:24 UTC
README
拉赫西斯(/ˈlækɪsɪs/ LAK-iss-iss;古希腊语:Λάχεσις,拉丁化:Lákhesis,意为“掷骰者”;来自λανχανω lanchánō,意为“通过掷骰、命运或神的意志获得”),在古希腊宗教中,是三位命运女神或莫伊赖中的中位女神;她的姐妹是克罗托和安特洛波斯。通常穿着白色衣服的拉赫西斯是克罗托纺轮上线的测量者,在一些文献中,她决定了命运或生命线。
-- 维基百科编辑者,“拉赫西斯”,维基百科,自由百科全书,https://en.wikipedia.org/w/index.php?title=Lachesis&oldid=1169650823(2024年7月28日访问)。
一个用于发现您的PHP代码如何编织的工具。
安装
获取此源代码,然后使用Composer
composer install
用法
此工具在其bin目录提供了一个命令。
bin/lachesis analyze <baseDirectory>
Lachesis将从指定的基本目录递归地找到所有PHP文件。对于每个文件,它将检测类定义并将它们以及它们的协作者(例如)收集起来:
- 父类(扩展),将当前类设置为它的子类
- 实现接口,将当前类/接口设置为它们的实现者
- 接收类型作为方法参数,将当前类/接口设置为它们的接收者
- 返回类型作为方法返回值,将当前类/接口设置为它们的返回者
我们以一个织物结束,描述了
- 父类 <-> 子类(扩展)之间的相互链接
- 实现 <-> 实现者
- 接收 <-> 接收者
- 返回 <-> 返回者
分析命令输出代表织物的JSON数组,您可以将它保存到文件中
bin/lachesis analyze /path/to/php/source/code > /path/to/desired/output_file.json
Lachesis织物类的输出示例
{
"id": "47c7f147c86ec190a6cb3b700bc9fd31b8688b85", // generated id from FQN
"name": "Lachesis\\Fabric",
"parent": null, // extends nothing
"implementations": [
{ // implement PhpParser\NodeVisitor
"id": "05bef068d987505bdfc10cb371a8f5bb84e73e16",
"name": "PhpParser\\NodeVisitor"
}
],
"implementors": [], // implemented by nothing as it is not an interface
"received": [
{ // received in __construct
"id": "88bc6161bb25a2869d6980ee6fb71c6276959c01",
"name": "PhpParser\\Parser"
},
{ // received in __construct
"id": "b55c17f51da4bc7cee24c1234d7b2fae57f156fb",
"name": "PhpParser\\NodeTraverserInterface"
},
{ // received in eachNodeDo
"id": "84e77ec95c5a92eb909c6ac217e1a65e9bf9d350",
"name": "Closure"
},
{ // received in enterNode and leaveNode
"id": "00eb6b01a21c654b4ad34ba160edb47d4fe4f960",
"name": "PhpParser\\Node"
}
],
"receivers": [], // nobody receive it
"returned": [], // return nothing
"returners": [] // nobody return it
}
许可证
版权(c)2024 Patrick Barroca patrick.barroca@gmail.com
本程序是自由软件:您可以在自由软件基金会发布的GNU Affero通用公共许可证的条款下重新分发和/或修改它,许可证版本为3。
本程序的分发是希望它会有用,但没有任何保证;甚至没有关于其可销售性或适用于特定目的的暗示保证。有关详细信息,请参阅GNU Affero通用公共许可证。
您应已收到GNU Affero通用公共许可证的副本。如果没有,请参阅https://gnu.ac.cn/licenses/gpl-3.0.html。