jeremysells / class-detail-mapper

类详情映射器。它检索有关类(例如注释和属性)的信息。

此包的规范存储库似乎已丢失,因此已冻结此包。

dev-develop 2018-12-30 15:54 UTC

This package is auto-updated.

Last update: 2023-12-16 22:42:07 UTC


README

提供类详细信息的库。目前仅支持类属性和类头。它使用 Doctrine 注解和 PHP 反射(也处理 @var 注释)。将来,它可以扩展到函数(如果有需要的话)。

状态

状态:开发中

使用

有关使用说明,请参阅:tests/integration 详细了解 src/Interfaces 中的接口(特别是 src/Interfaces/Entities),以获取有关响应的详细信息。建议从 src/Interfaces/ClassDetailRepositoryInterface.php 开始。

示例

注意:此库支持 PHP-DI。建议使用该库而不是工厂(以下)。

use JeremySells\Libraries\ClassDetailMapper\Factories\ClassDetailMapperFactory;
use JeremySells\Libraries\ClassDetailMapper\ClassDetailRepository;
use Something\Here\Product;

/** @var ClassDetailRepository $classDetailRepository */
$classDetailRepository = ClassDetailMapperFactory::createClassDetailRepository();
$productClassDetail = $classDetailRepository->getClassDetail(Product::class);

// Header annotation
$headerSomeDoctrineAnnotations = $productClassDetail->getHeader()->getClassAnnotations(SomeDoctrineAnnotation::class);

// Property annotation
$priceProperty = $productClassDetail->getProperties()->getProperty("price");
$types = $priceProperty->getTypeCollection()->getTypesList(); //@var list (with full namespaces resolved)
$someDoctrineAnnotations = $priceProperty->getClassAnnotations(SomeDoctrineAnnotation::class);

待办事项

  • 添加函数信息
  • 使集合类扩展/实现 ArrayObject

质量保证

要运行质量保证工具(在开发中),您需要安装 Docker(和 Docker-Compose),然后运行 ./qa-dev.sh。要查看质量保证报告,请参阅:build/reports