smuuf/strict-object
Composer 安装命令:
composer require smuuf/strict-object
包简介
Just a simple strict-object trait.
README 文档
README
Avoid annoying problems caused by PHP being too lax when dealing with undeclared object properties. Let's be more strict. Don't let typos in property names ruin your day ever again. 🌞
Installation
composer require smuuf/strict-object
Usage
Simple, just use the \Smuuf\StrictObject trait in your class to make it strict - and to throw \LogicException when someone tries to read or to write to an undeclared property.
<?php use \Smuuf\StrictObject; require __DIR__ . '/../bootstrap.php'; class Whatever { use StrictObject; public $someProperty; } $obj = new Whatever; $obj->someProperty = 1; // Ok. echo $obj->someProperty; // Ok. // But - and hold on to your hats... $obj->bogusProperty = 1; // Throws \LogicException. echo $obj->bogusProperty; // Throws \LogicException.
统计信息
- 总下载量: 656
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-01-16