定制 fivepercent/reflection 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

fivepercent/reflection

最新稳定版本:v1.0

Composer 安装命令:

composer require fivepercent/reflection

包简介

Reflection helpers

README 文档

README

This package add helper methods for work with PHP Reflection

Installation

Add FivePercent/Reflection in your composer.json:

{
    "require": {
        "fivepercent/reflection": "~1.0"
    }
}

Now tell composer to download the library by running the command:

$ php composer.phar update fivepercent/reflection

Basic usage

The class FivePercent\Component\Reflection\Reflection is final, and can not use as object. All methods in this class statically.

Examples for work with this package:

use FivePercent\Component\Reflection\Reflection

// Get class reflection
$reflection = Reflection::loadClassReflection('MyClass');

// Get method reflection
$reflection = Reflection::loadMethodReflection('MyClass', 'myMethod');

// Get object reflection
$object = new MyClass();
$reflection = Reflection::loadObjectReflection($object);

// Get all properties from class
$properties = Reflection::getClassProperties('MyClass');

// Get all properties from class with gets from parents classes
$properties = Reflection::getClassProperties('MyClass', true);

// Get only private properties from class
$properties = Reflection::getClassProperties('MyClass', false, \ReflectionProperty::IS_PRIVATE);

// Set value to property in object
$object = new MyClass();
Reflection::setPropertyValue($object, 'myProperty', 'FooBar');

// Get value from property
$object = new MyClass();
$value = Reflection::getPropertyValue($object, 'myProperty');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-04