localheinz/classy

此包已被废弃,不再维护。作者建议使用 ergebnis/classy 包。

提供对 classy 构造(类、枚举、接口和特质)的查找器。

1.6.0 2023-11-27 16:46 UTC

README

Integrate Merge Release Renew

Code Coverage Type Coverage

Latest Stable Version Total Downloads Monthly Downloads

此项目提供了一个带有 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