thenlabs/meta-parser 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

thenlabs/meta-parser

Composer 安装命令:

composer require thenlabs/meta-parser

包简介

README 文档

README

Extract metadata from attributes and/or annotations.

If you like this project gift us a ⭐.

Installation.

composer require thenlabs/meta-parser dev-main

Usage example.

/**
 * @MyMetadata(data1="value1")
 */
#[MyMetadata(data1: 'value2')]
class MyClass
{
}

$myClass = new ReflectionClass(MyClass::class);

/**
 * Reading from annotations only.
 */
$annotationParser = new ThenLabs\MetaParser\AnnotationParser();
$annotationParserResult = $annotationParser->parse($myClass);

$annotationParserResult->get(MyMetadata::class)->get('data1') === 'value1'; // true

/**
 * Reading from attributes only.
 */
$attributeParser = new ThenLabs\MetaParser\AttributeParser();
$attributeParserResult = $attributeParser->parse($myClass);

$attributeParserResult->get(MyMetadata::class)->get('data1') === 'value2'; // true

/**
 * Reading both.
 */
$parser = new ThenLabs\MetaParser\Parser();
$parserResult = $parser->parse($myClass);

// this returns true becouse attributes override annotations.
$parserResult->get(MyMetadata::class)->get('data1') === 'value2';

Highlights about ThenLabs\MetaParser\Parser class.

1. For read annotations it's necessary to install Doctrine Annotations:

$ composer require doctrine/annotations

2. The attribute parser require a PHP version grater than 8.0.

3. The parse() methods accept an instance of Reflector, so that, for parse a method of a class(for example), you can use a ReflectionMethod instance.

Development.

Clone this repository and install the Composer dependencies.

$ composer install

Running the tests.

All the tests of this project was written with our testing framework PyramidalTests wich is based on PHPUnit.

Run tests:

$ composer test

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固