simplecomplex/explorable 问题修复 & 功能扩展

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

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

simplecomplex/explorable

Composer 安装命令:

composer require simplecomplex/explorable

包简介

Foreach'ing protected members made simple

关键字:

README 文档

README

composer namespace: simplecomplex/explorable

Foreach'ing protected members made simple

An interface, base class and traits making it a breeze to expose a class' protected members.

Extending Explorable facilitates:

  • isset()
  • count()
  • foreach (...
  • var_dump()
  • toObject(), toArray()
  • json_encode()

Usage

Class declaring it's properties

Property names hardcoded in constant EXPLORABLE_VISIBLE.

<?php

use SimpleComplex\Explorable\Explorable;
use SimpleComplex\Explorable\ExplorableTrait;

/**
 * @property-read string $foo
 * @property-read string $bar
 */
class ExplorablesDeclared extends Explorable
{
    use ExplorableTrait;

    public const EXPLORABLE_VISIBLE = [
        'foo' => true,
        'bar' => true,
    ];

    protected string $foo;

    protected string $bar;
}

Class relying on property table discovery

The properties will be discovered on-demand, via explorablePrepare().

All instance vars must be nullable and declared as null (protected ?string $foo = null;).
Otherwise risk of getting "::$foo must not be accessed before initialization" error, or the instance vars simply won't get discovered (because not set to a value (null)).

<?php

use SimpleComplex\Explorable\Explorable;
use SimpleComplex\Explorable\ExplorableTrait;

/**
 * @property-read string $foo
 * @property-read string $bar
 */
class ExplorablesDiscoverable extends Explorable
{
    use ExplorableTrait;

    protected ?string $foo = null;

    protected ?string $bar = null;
}

MIT licensed

License and copyright. Explained.

Requirements

  • PHP ^7.4 || ^8.0

Development (require-dev)

  • phpunit ^8 || ^9

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-04-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固