jeremysells/class-detail-mapper

Class detail mapper. It retrieves information about classes (i.e. comments and properties).

This package's canonical repository appears to be gone and the package has been frozen as a result.

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

This package is auto-updated.

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


README

Library to provide details about classes. Currently only supports class properties and class header. It uses Doctrine annotations and PHP reflections (also handles @var comments). Later, it could be extended to functions (if anyone is keen).

Status

Status: Under Development

Usage

For usage, see: tests/integration Have a look at the interface in src/Interfaces (especially src/Interfaces/Entities) for details about the response. I suggest starting with the src/Interfaces/ClassDetailRepositoryInterface.php

Example:

Note: This library supports PHP-DI. Its advised to use that over the factory (below).

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);

Todo

  • Add function information
  • Make the collection classes extend/implement ArrayObject

QA

To run the QA tools (in development), you need Docker (and Docker-Compose) installed, then run ./qa-dev.sh To view the QA reports, see: build/reports