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.
Requires
- php: >=7.2
- doctrine/annotations: ^1.6
- ocramius/proxy-manager: ^2.2
- php-di/phpdoc-reader: ^2.1
Requires (Dev)
- jakub-onderka/php-parallel-lint: ^1.0
- phan/phan: ^1.1
- php-di/php-di: ^6.0
- phploc/phploc: ^4.0
- phpmd/phpmd: ^2.6
- phpmetrics/phpmetrics: ^v2.4
- phpstan/phpstan: ^0.10
- phpunit/phpunit: ^7.5
- sebastian/phpcpd: ^4.1
- sensiolabs/security-checker: ^5.0
- squizlabs/php_codesniffer: ^3.4
- vimeo/psalm: ^3.0
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