ytake / lom
PHP代码生成器,类似lombok风格
0.2
2018-05-05 17:07 UTC
Requires
- php: ^7.1
- andrewsville/php-token-reflection: 1.*
- doctrine/annotations: ^1.2
- nikic/php-parser: 4.*
- symfony/console: ^4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.11
- phploc/phploc: *
- phpunit/phpunit: ^7.1
- satooshi/php-coveralls: 2.0
- sebastian/phpcpd: *
- sensiolabs/security-checker: ^4.1.8
This package is auto-updated.
Last update: 2024-09-04 23:39:37 UTC
README
用于PHP代码生成器
安装
$ composer require ytake/lom --dev
用法
生成命令
$ vendor/bin/lom generate [scan target dir]
功能
@数据注释
use Ytake\Lom\Meta\Data; /** * Class DataAnnotation * @Data */ class DataAnnotation { /** * @var string $message */ protected $message; /** * @var string $testing */ protected $testing; }
之后
use Ytake\Lom\Meta\Data; /** * Class DataAnnotation * @Data */ class DataAnnotation { /** * @var string $message */ protected $message; public function getMessage() { return $this->message; } public function setMessage($message) { $this->message = $message; } }
@NoArgsConstructor 注解
use Ytake\Lom\Meta\NoArgsConstructor; /** * Class DataAnnotation * @NoArgsConstructor */ class DataAnnotation { public function __construct($message) { $this->message = $message; } }
之后
use Ytake\Lom\Meta\NoArgsConstructor; /** * Class DataAnnotation * @NoArgsConstructor */ class DataAnnotation { }
@AllArgsConstructor 注解
use Ytake\Lom\Meta\AllArgsConstructor; /** * Class DataAnnotation * @AllArgsConstructor */ class DataAnnotation { protected $arg1; protected $arg2; }
之后
use Ytake\Lom\Meta\AllArgsConstructor; /** * Class DataAnnotation * @AllArgsConstructor */ class DataAnnotation { protected $arg1; protected $arg2; public function __construct($arg1, $arg2) { $this->arg1 = $arg1; $this->arg2 = $arg2; } }
@Getter/@Setter 注解
use Ytake\Lom\Meta\Getter; use Ytake\Lom\Meta\Setter; class GetterSetterAnnotation { /** * @Getter @Setter * @var string $message */ private $message; /** * @Getter @Setter * @var string $testing */ private $testing; }
@Value 注解
/** * Class ValueAnnotation * @\Ytake\Lom\Meta\Value */ class ValueAnnotation { /** * @var string $message */ protected $message; /** * @var string $testing */ protected $testing; /** @var string $hello */ protected $hello; }