keradus/traits
最新稳定版本:v1.0
Composer 安装命令:
composer require keradus/traits
包简介
Traits: general usage traits
README 文档
README
Traits - general usage traits.
Traits List
InaccessiblePropertiesProtectorTrait
Trait, that protects accessing inaccessible (unknown) properties to help keeping code clean and safe.
class Foo { public $baz; } $foo = new Foo(); $foo->vaz = 123; // PHP claims that code is OK, even if you misspelled variable name! class Bar { use InaccessiblePropertiesProtectorTrait; public $baz; } $bar = new Bar(); $bar->vaz = 123; // now PHP throws \LogicException
InnerClassCacheTrait
Trait, that adds functionality of inner class cache.
class Foo { use InnerClassCacheTrait; public function square($x) { if (!isset($this->cache[$x])) { $this->cache[$x] = $x * $x; } return $this->cache[$x]; } }
InstanceCreationDisallowerTrait
Trait, that disallow to create instance of class. Use for protecting static classes (only static members).
class Foo { use InstanceCreationDisallowerTrait; public static function createInstance() { return new static(); } } $foo = new Foo(); // PHP throws fatal error $foo = Foo::createInstance(); // PHP throws \LogicException
PropertyTrait
Property trait.
SingletonTrait
StaticPropertyTrait
Property trait in static way.
统计信息
- 总下载量: 180
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-10