localheinz / classy
1.6.0
2023-11-27 16:46 UTC
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0
- ext-tokenizer: *
Requires (Dev)
- ergebnis/composer-normalize: ^2.39.0
- ergebnis/license: ^2.3.0
- ergebnis/php-cs-fixer-config: ~6.12.0
- ergebnis/phpunit-slow-test-detector: ^2.4.0
- fakerphp/faker: ^1.23.0
- infection/infection: ~0.27.8
- phpunit/phpunit: ^10.4.2
- psalm/plugin-phpunit: ~0.18.4
- rector/rector: ~0.18.11
- vimeo/psalm: ^5.16.0
README
此项目提供了一个带有 classy 构造(类、枚举、接口和 特质)查找器的 composer
包。
安装
运行
composer require ergebnis/classy
用法
从源代码收集 classy 构造
使用 Classy\Constructs::fromSource()
从源代码中收集 classy 构造
<?php declare(strict_types=1); use Ergebnis\Classy; $source = <<<'PHP' <?php namespace Example; class Foo {} enum Bar {} interface Baz {} trait Qux {} PHP; $constructs = Classy\Constructs::fromSource($source); $names = array_map(static function (Classy\Construct $construct): string { return $construct->name(); }, $constructs); var_dump($names); // ['Example\Bar', 'Example\Baz', 'Example\Foo', 'Example\Qux']
从目录中收集 classy 构造
使用 Classy\Constructs::fromDirectory()
从目录中收集 classy 构造
<?php declare(strict_types=1); use Ergebnis\Classy; $constructs = Classy\Constructs::fromDirectory(__DIR__ . '/example'); $names = array_map(static function (Classy\Construct $construct): string { return $construct->name(); }, $constructs); var_dump($names); // ['Example\Bar', 'Example\Bar\Baz', 'Example\Foo\Bar\Baz']
变更日志
此项目的维护者在一个 变更日志 中记录了此项目的显著变更。
贡献
此项目的维护者建议遵循 贡献指南。
行为准则
此项目的维护者要求贡献者遵循 行为准则。
一般支持政策
此项目的维护者提供有限的支持。
您可以通过 赞助 @localheinz 或 为此项目相关的服务请求发票 来支持此项目的维护。
PHP 版本支持政策
此项目支持具有 活动和安全支持 的 PHP 版本。
此项目的维护者在 PHP 版本最初发布后添加对其的支持,并在其达到安全支持结束时停止对其的支持。
安全政策
此项目有一个 安全政策。
许可证
此项目使用 MIT 许可证。
致谢
在 Constructs
中查找 PHP 文件中类的算法已从 Zend\File\ClassFileLocator
(最初以 BSD-3-Clause 许可)采纳。
社交
在 Twitter 上关注 @localheinz 和 @ergebnis。