定制 tbn/getter-trait-bundle 二次开发

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

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

tbn/getter-trait-bundle

最新稳定版本:4.1.0

Composer 安装命令:

composer require tbn/getter-trait-bundle

包简介

README 文档

README

Symfony Bundle that generates getters and setters inside a trait.

Why ? Basics getters brings no information about the class.

The classes are quickly long for no "business" reason.

Having only the redefined method allows to spot the method with business purpose.

Installation

composer require --dev "tbn/getter-trait-bundle"

In config/bundles.php, add the bundle to the dev environment

return [
    ...
    tbn\GetterTraitBundle\GetterTraitBundle::class => ['dev' => true,],
];

Usage

Add the GetSetTrait attribute to your class

use tbn\GetterTraitBundle\Attributes\GetSetTrait; // add this line

#[GetSetTrait] // add this line
class MyClass
{
    private String $name;
}

Run the ./bin/console generate:getter:traits command

A new file is automatically generated in the same folder and contains the getters and setters for the MyClass class.

When a property is modified or added, you have to re-run the command in order to update the traits.

Use the generated trait.

#[GetSetTrait]
class MyClass
{
    use MyClassTrait; // add this line

    private String $name;
}

I need to redefine the method

Just copy/paste the generated code inside your class and update it to your needs.

More examples

Example folder

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-09