Basic Super Classes for PHP


License
MIT

Documentation

php-bsc

Basic Super Classes for PHP.

Install

composer require 4kizuki/php-bsc

Usage

StandardClass

Extending this class lets your class deny access to undefined properties. Make your class inherited from Akizuki\BSC\StandardClass and that's all OK.

Explanation written in Japanese is available: https://qiita.com/4kizuki/items/1c89061c3531fec6580f

class MyClass { }

$c = new MyClass;
$c->newProperty = '33.4';   // It works.
use Akizuki\BSC\StandardClass;
class MyClass extends StandardClass { }

$c = new MyClass;
$c->newProperty = '33.4';   // InaccessiblePropertyException will be thrown.

You can use those traits listed below instead.

  • Akizuki\BSC\Traits\StrictMethodAccess
  • Akizuki\BSC\Traits\StrictPropertyAccess

NonCreatable

Extending this class makes your class non-creatable. Make your class inherited from Akizuki\BSC\NonCreatable and that's all OK. Note that this class is derived from StandardClass.

You can use the trait listed below instead.

  • Akizuki\phpbsc\Traits\DisabledInstantiation