承接 selfiens/property-alias 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

selfiens/property-alias

最新稳定版本:1.0

Composer 安装命令:

composer require selfiens/property-alias

包简介

Enables property alias via ClassDoc

README 文档

README

PHPUnit Status

This package enables you to create aliases for existing class properties with a simple ClassDoc setup.

Below is an example of creating an alias to $this->foo.

/**
 * @property $my_alias = foo
 *              ^
 *              |
 *      This is how you define an alias to "$foo".
 *      Valid PHP identifiers will work, including UTF-8 $한글.
 */
 class MyClass {
    use \Selfiens\PropertyAliasTrait;

    public string $foo = 'foo';
 }

Then you can read/write properties via alias.

$my = new MyClass();

// read
echo $my->my_alias; // 'foo'

 // write
$my->my_alias = 'bar';
echo $my->foo; // 'bar';

Install

composer require selfiens/property-alias:^1.0

Setup

This package's \Selfiens\PropertyAliasTrait uses ClassDoc as the source of alias definitions. You can create aliases using the @property syntax, as shown in the following example:

/**
 * @property $alias_name = target_property
 */

You can define as many aliases as you desire. Aliases can point to the other aliases.

Background

Aliases on existing properties

This package aims to assist in accessing poorly named properties by better names. It is designed to help in situations where you are unable to rename a property due to reasons such as its origin from an external API, a poorly named database field, or the high risk associated with refactoring the name.

Defining aliases in ClassDoc with @property

The @property definitions in ClassDoc are understood by many IDEs, and these IDEs will provide auto-completions and refactorings as if the aliases were real properties.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固