gabrielfs7/annotation 问题修复 & 功能扩展

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

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

gabrielfs7/annotation

最新稳定版本:1.0.0

Composer 安装命令:

composer require gabrielfs7/annotation

包简介

A PHP library to parse annotations

README 文档

README

Create and retrieve content from your own PHP Class Annotations!

Samples

<?php
namespace GSoares\Annotation\Sample;

/**
 * @package GSoares\Annotation\Sample
 * @myAnnotationBoolean(true)
 * @myAnnotationString('String name')
 * @myAnnotationString2(String name)
 * @myAnnotationNumber(123)
 * @myAnnotationNumber2(-123.84)
 * @myAnnotationNumber3(123.456)
 * @myAnnotationArray(
 *     [
 *         'a' => 'b',
 *         'c' => 'c',
 *         [
 *             'd' => ['e', 'f']
 *         ]
 *     ]
 * )
 * @myAnnotationArray2(
 *     'a' => 'b',
 *     'c' => 'c',
 *     [
 *         'd' => ['e', 'f']
 *     ]
 * )
 */
class SampleClass
{

    /**
     * @myAnnotationBoolean(true)
     * @myAnnotationString('String name')
     * @myAnnotationString2(String name)
     * @myAnnotationNumber(123)
     * @myAnnotationNumber2(-123.84)
     * @myAnnotationNumber3(123.456)
     * @myAnnotationArray(
     *     [
     *         'a' => 'b',
     *         'c' => 'c',
     *         [
     *             'd' => ['e', 'f']
     *         ]
     *     ]
     * )
     * @myAnnotationArray2(
     *     'a' => 'b',
     *     'c' => 'c',
     *     [
     *         'd' => ['e', 'f']
     *     ]
     * )
     * @var teste
     */
    private $mySampleProperty;

    /**
     * @myAnnotationBoolean(true)
     * @myAnnotationString('String name')
     * @myAnnotationString2(String name)
     * @myAnnotationNumber(123)
     * @myAnnotationNumber2(-123.84)
     * @myAnnotationNumber3(123.456)
     * @myAnnotationArray(
     *     [
     *         'a' => 'b',
     *         'c' => 'c',
     *         [
     *             'd' => ['e', 'f']
     *         ]
     *     ]
     * )
     * @myAnnotationArray2(
     *     'a' => 'b',
     *     'c' => 'c',
     *     [
     *         'd' => ['e', 'f']
     *     ]
     * )
     */
    public function mySampleMethod()
    {

    }
}

?>

Read Class Annotations

<?php
$reader = new GSoares\Annotation\Reader();
$annotationBag = $reader->readClass('GSoares\Annotation\Sample\SampleClass');

$annotationBag->get('myAnnotationBoolean'); //(boolean) true
$annotationBag->get('myAnnotationString'); //(string) String name
$annotationBag->get('myAnnotationString2'); //(string) String name
$annotationBag->get('myAnnotationNumber'); //(int) 123
$annotationBag->get('myAnnotationNumber2'); //(int) -123.84
$annotationBag->get('myAnnotationNumber3'); //(float) 123.456
$annotationBag->get('myAnnotationArray'); //(Array) ['a' => 'b', 'c' => 'c', ['d' => ['e', 'f']]]
$annotationBag->get('myAnnotationArray2'); //(Array) ['a' => 'b', 'c' => 'c', ['d' => ['e', 'f']]]
?>

Read Class Property Annotations

<?php
$reader = new GSoares\Annotation\Reader();
$annotationBag = $reader->readProperty(
    'GSoares\Annotation\Sample\SampleClass',
    'mySampleProperty'
);

$annotationBag->get('myAnnotationBoolean'); //(boolean) true
$annotationBag->get('myAnnotationString'); //(string) String name
$annotationBag->get('myAnnotationString2'); //(string) String name
$annotationBag->get('myAnnotationNumber'); //(int) 123
$annotationBag->get('myAnnotationNumber2'); //(int) -123.84
$annotationBag->get('myAnnotationNumber3'); //(float) 123.456
$annotationBag->get('myAnnotationArray'); //(Array) ['a' => 'b', 'c' => 'c', ['d' => ['e', 'f']]]
$annotationBag->get('myAnnotationArray2'); //(Array) ['a' => 'b', 'c' => 'c', ['d' => ['e', 'f']]]
?>

Read Class Method Annotations

<?php
$reader = new GSoares\Annotation\Reader();
$annotationBag = $reader->readMethod(
    'GSoares\Annotation\Sample\SampleClass',
    'mySampleMethod'
);

$annotationBag->get('myAnnotationBoolean'); //(boolean) true
$annotationBag->get('myAnnotationString'); //(string) String name
$annotationBag->get('myAnnotationString2'); //(string) String name
$annotationBag->get('myAnnotationNumber'); //(int) 123
$annotationBag->get('myAnnotationNumber2'); //(int) -123.84
$annotationBag->get('myAnnotationNumber3'); //(float) 123.456
$annotationBag->get('myAnnotationArray'); //(Array) ['a' => 'b', 'c' => 'c', ['d' => ['e', 'f']]]
$annotationBag->get('myAnnotationArray2'); //(Array) ['a' => 'b', 'c' => 'c', ['d' => ['e', 'f']]]
?>

Installation

  1. Project available in https://packagist.org/packages/gabrielfs7/annotation to install via composer.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-10-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固