automattic / jetpack-stub-generator
从代码库中提取特定函数/类等占位符。
v1.0.0
2024-05-22 16:31 UTC
Requires
- php: >=7.4
- composer/xdebug-handler: ^3.0.4
- nikic/php-parser: ^5.0.2
- phpstan/phpdoc-parser: ^1.28.0
- symfony/console: ^5.3 || ^6.0 || ^7.0
Requires (Dev)
- automattic/jetpack-changelogger: ^4.2.4
- yoast/phpunit-polyfills: 1.1.0
This package is auto-updated.
Last update: 2024-09-18 03:17:53 UTC
README
从代码库中提取特定函数/类等占位符。
适用于您需要为大型代码库的特定部分生成占位符的情况。如果您想提取所有内容的占位符,那么像 php-stubs/generator 这样的工具可能更适合您。
用法
这是一个相对简单的命令行应用程序
vendor/bin/jetpack-stub-generator definition-file.php
选项
--json : 定义文件是JSON而不是PHP。
--output <file> : 将占位符写入指定的文件,而不是标准输出。
定义文件
定义文件指定从哪些文件中提取占位符,以及一些其他配置。
此处注释的示例是以PHP格式。可以使用 --json
标志使用等效的JSON结构。
<?php return [ // Text to put at the top of the output, after the opening `<?php`. Default empty. 'header' => '', // Text to put at the end of the output. Default empty. 'footer' => '', // Set true to strip descriptions and unrecognized tags from the phpdoc. 'strip-docs' => false, // Path which `files` are relative to. Defaults to the directory containing the definition file, // and if it's relative it's relative to that. 'basedir' => '.', // Files to process, and what to extract from them. 'files' => [ 'path/to/file.php' => [ // Constants to extract, by name. 'constant' => [ 'CONSTANT_ONE', 'CONSTANT_TWO' ], // Functions to extract, by name. 'function' => [ 'functionOne', 'functionTwo' ], // Classes to extract, 'class' => [ 'ClassName' => [ 'constant' => [ 'CLASS_CONSTANT' ], 'property' => [ 'propertyName' ], 'method' => [ 'methodName', 'staticOrDynamicNoDifference' ], ], ], 'interface' => [ /* constants, properties, and methods, just like classes */ ], 'trait' => [ /* constants, properties, and methods, just like classes */ ], ], // A `'*'` can be used to avoid having to list everything, if you want everything in a file. 'path/to/file2.php' => [ // If you want to extract everything in a category from the file, you can do it like this. 'function' => '*', 'class' => [ // It also works for extracting parts of classes, interfaces, and traits. 'ClassName' => [ 'property' => '*', 'method' => '*', ], // And for whole classes, interfaces, and traits for that matter. 'ClassName2' => '*', ], ], // This works too. 'path/to/file3.php' => '*', // OTOH, there's no globbing or "entire directory" functionality for filenames. // Since this is a PHP file, you can easily do that yourself. ], ];
安全
需要报告安全漏洞?请访问 https://automattic.com/security/ 或直接访问我们的安全漏洞赏金网站 https://hackerone.com/automattic。
许可证
stub-generator 在 GNU通用公共许可证第2版(或更高版本)下授权