GithubHelp home page GithubHelp logo

thorewi / strictobjects Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kdyby/strictobjects

0.0 0.0 0.0 65 KB

Simple trait to make your class strict, when calling or accessing undefined member (property or method).

Home Page: https://packagist.org/packages/kdyby/strict-objects

License: Other

PHP 100.00%

strictobjects's Introduction

Kdyby/StrictObjects

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\Scream combines all screamers into one.

Homepage https://www.kdyby.org and repository https://github.com/Kdyby/StrictObjects.

strictobjects's People

Contributors

fprochazka avatar majkl578 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.