kdyby/strict-objects
Simple trait to make your class strict, when calling or accessing undefined member (property or method).
Maintainers
Requires
- php: ^7.1
Requires (Dev)
- jakub-onderka/php-parallel-lint: ^1.0
- kdyby/coding-standard: ^1.0@dev
- nette/tester: ~2.3.1
- phpstan/phpstan-shim: ^0.11
Suggests
None
Provides
None
Conflicts
None
Replaces
None
BSD-3-Clause, GPL-2.0, GPL-3.0 d865874e4d5676067bae5243b15d99700b6a29cb
- Filip ProchΓ‘zka <filip.woop@prochazka.su>
exceptionsobjectkdybypropertiesmagicstrictmethodsmembersaccessorsscream
This package is auto-updated.
Last update: 2026-06-08 04:05:28 UTC
README
Simple set of traits to make your classes strict, when calling or accessing an undefined member (property or method).
π Build Status
π Downloads this Month
π Latest stable
π Coverage Status
This library is heavily inspired by Nette\ObjectMixin.
Installation
The best way to install Kdyby/StrictObjects is using Composer:
composer require kdyby/strict-objects
Usage
Simply include the trait in your class and it will behave strictly!
use Kdyby\StrictObjects\Scream; class MyClass { use Scream; // my code }
If you for some reason can't or don't want to make all undefined property and method access strict, you can enable the behavior selectively by using specific traits:
Kdyby\StrictObjects\PropertyReadScreamer: Will throw when attempting to read an undeclared property.Kdyby\StrictObjects\PropertyWriteScreamer: Will throw when attempting to write to an undeclared property.Kdyby\StrictObjects\PropertyExistsScreamer: Will throw when attempting to check existence of an undeclared property.Kdyby\StrictObjects\PropertyRemovalScreamer: Will throw when attempting to unset an undeclared property.Kdyby\StrictObjects\InstanceMethodCallScreamer: Will throw when attempting to call an undefined instance method.Kdyby\StrictObjects\StaticMethodCallScreamer: Will throw when attempting to call an undefined static method.
For convenience, there are also:
Kdyby\StrictObjects\PropertyScreamer: Combines all property access, will throw on any interaction.Kdyby\StrictObjects\MethodCallScreamer: Combines both method call types, will throw for all methods.Kdyby\StrictObjects\Screamcombines all screamers into one.
Homepage https://www.kdyby.org and repository https://github.com/Kdyby/StrictObjects.
