dreamcat/property_analysis

类的属性分析

v2.2.0 2023-07-13 10:56 UTC

This package is auto-updated.

Last update: 2024-04-13 12:53:58 UTC


README

介绍

类的属性分析,确认是否有 set 函数,确认 set 函数调用时或直接为属性时使用什么类型的参数

从 2.0 开始,直接使用 PHP8 的注解功能

安装教程

composer require dreamcat/property_analysis

使用说明

<?php
use Dreamcat\PropertyAnalysis\PropertyAnalysis;
use DreamCat\PropertyAnalysis\DemoClass\Pojo1;

$analysis = new PropertyAnalysis();
$result = $analysis->analysis(new ReflectionClass(Pojo1::class));

特别说明

  1. 目前没有较好的办法区分属性是声明在类中还是 trait 中,所以如果在 trait 中使用注释说明属性的类型时,不可以使用短名称,否则可能无法解析。