PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects.

Related tags

Miscellaneous yell
Overview

📢 Yell

Scrutinizer Code Quality Code Climate Latest Stable Version License

PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects.

Requirement

PHP >= 5.4.0.

Installation

You can install the library using the following ways:

Using Composer

You can install this through Composer, a dependency manager for PHP. Just run the below command:

composer require zeeshanu/yell

For further details you can find the package at Packagist.

Manual way

  • Copy src to your codebase, perhaps to the vendor directory.
  • Add the Zeeshanu\Yell\Scream class to your autoloader or require the file directly.

Getting Started

I'm going to create take an example to demonstrate the usage.

For example, you have a Person class like below:

class Person
{
    public $name;
    public $age;
}

$person = new Person();

$person->name = 'John Doe';
$person->age = 23;

// Will silently set the property `profession` on `Person` without any issue 
$person->profession = 'Teacher';

Here is how you can make your object strict i.e. not allow any other properties except $name and $age and throw exceptions for any other properties. Just use Zeeshanu\Yell\Scream trait in your class as follows

use Zeeshanu\Yell\Scream;

class Person
{
    use Scream;

    public $name;
    public $age;
}

$person = new Person();

$person->name = 'John Doe';
$person->age = 23;

// An exception will be thrown when showing message "Trying to set undefined property $profession in class Person"  
$person->profession = 'Teacher';

Feedback

If you notice that there might be some improvements in code you can create a pull request or report an issue. You can also contact me at [email protected].

License

The MIT License (MIT). Please see License File for more information.

You might also like...
provides a nested object property based user interface for accessing this configuration data within application code

laminas-config This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steeri

think-exception-handler
think-exception-handler

ThinkPHP6.0 exception 异常插件 安装 composer require tinywan/think-exception 配置 发布配置 php think tinywan:exception 这将自动生成 config/exception.php 配置文件。 配置异常类 a

Naive Bayes works by looking at a training set and making a guess based on that set.

Naive Bayes Naive Bayes works by looking at a training set and making a guess based on that set. It uses simple statistics and a bit of math to calcul

QuidPHP/Main is a PHP library that provides a set of base objects and collections that can be extended to build something more specific.

QuidPHP/Main is a PHP library that provides a set of base objects and collections that can be extended to build something more specific. It is part of the QuidPHP package and can also be used standalone.

meterN is a lightweight set of PHP/JS files that make a " Home energy metering & monitoring " solution.

meterN - Home energy monitor - (PHP/JS Energy Metering & Monitoring) What can meterN do for you ? meterN is a lightweight set of PHP/JS files that mak

A set of classes to create and manipulate HTML objects abstractions

HTMLObject HTMLObject is a set of classes to create and manipulate HTML objects abstractions. Static calls to the classes echo Element::p('text')-cla

Creating data transfer objects with the power of php objects. No php attributes, no reflection api, and no other under the hook work.

Super Simple DTO Creating data transfer objects with the power of php objects. No php attributes, no reflection api, and no other under the hook work.

Parse DSN strings into value objects to make them easier to use, pass around and manipulate

DSN parser Parse DSN strings into value objects to make them easier to use, pass around and manipulate. Install Via Composer composer require nyholm/d

The fixture plugin is really helpful if you want to create some static demo data for your shopware instance.

Fixture Plugin The fixture plugin is really helpful if you want to create some static demo data for your shopware instance. Installation Just add it t

Comments
  • Configure Renovate

    Configure Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    :vertical_traffic_light: To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • composer.json (composer)

    Configuration Summary

    Based on the default config's presets, Renovate will:

    • Start dependency updates only once this Configure Renovate PR is merged
    • Separate major versions of dependencies into individual branches/PRs
    • Do not separate patch and minor upgrades into separate PRs for the same dependency
    • Upgrade to unstable versions only if the existing version is unstable
    • Raise PRs immediately (after branch is created)
    • Use renovate/ as prefix for all branch names
    • If semantic commits detected, use semantic commit type fix for dependencies and chore for all others
    • Keep existing branches updated even when not scheduled
    • Disable automerging feature - wait for humans to merge all PRs
    • Ignore node_modules, bower_components, vendor and various test/tests directories
    • Update existing lock files only when package.json is modified
    • Autodetect whether to pin dependencies or maintain ranges
    • Rate limit PR creation to a maximum of two per hour
    • Limit to maximum 20 open PRs at any time
    • Group known monorepo packages together
    • Use curated list of recommended non-monorepo package groupings

    :abcd: Would you like to change the way Renovate is upgrading your dependencies? Simply edit the renovate.json in this branch with your custom config and the list of Pull Requests in the "What to Expect" section below will be updated the next time Renovate runs.


    What to Expect

    With your current configuration, Renovate will create 3 Pull Requests:

    Pin dependency phpunit/phpunit to 4.2.6
    Update dependency phpunit/phpunit to v4.8.36
    • Schedule: "at any time"
    • Branch name: renovate/phpunit-phpunit-4.x
    • Upgrade phpunit/phpunit to 4.8.36
    Update dependency phpunit/phpunit to v8
    • Schedule: "at any time"
    • Branch name: renovate/phpunit-phpunit-8.x
    • Upgrade phpunit/phpunit to 8.0.4

    :children_crossing: Branch creation will be limited to maximum 2 per hour, so it doesn't swamp any CI resources or spam the project. See docs for prhourlylimit for details.


    :question: Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by Renovate Bot. View repository job log here.

    opened by renovate[bot] 1
Owner
Zeeshan Ahmad
Engineering at Smart Dubai. Full Stack Developer. Tech guy with an entrepreneurial spirit and knack for getting things done.
Zeeshan Ahmad
Find undefined and unused variables with the PHP Codesniffer static analysis tool.

PHP_CodeSniffer VariableAnalysis Plugin for PHP_CodeSniffer static analysis tool that adds analysis of problematic variable use. Warns if variables ar

Payton Swick 116 Dec 14, 2022
WPForms coding standards are based on the WordPress Coding Standards and the PHPCompatibility Coding Standards and help create strict and high-quality code.

WPForms coding standards are based on the WordPress Coding Standards and the PHPCompatibility Coding Standards and help create strict and high-quality code.

Awesome Motive, Inc. 7 Nov 29, 2022
Adds a header to every response to try and twart Google's usage of your site in it's FLoC tracking method.

Laravel No FLoC This package will add the Permissions-Policy: interest-cohort=() to try and twart Google's usage of your site in it's FLoC tracking me

Jean-Philippe Murray 11 Jul 14, 2022
The Barista explores every Latte (file) for strict quality, helps with Latte 2 to 3 upgrade

The Barista makes Your Perfectly Tasty Latte Do you drink Latte with your templates? Get it from Barista that knows his job: explore Latte via node vi

Tomas Votruba 5 Sep 7, 2022
All PHP functions, rewritten to throw exceptions instead of returning false

Safe PHP This project is deprecated Because of how this project needs to be in sync with the official PHP documentation, maintaining a set of function

TheCodingMachine 2.1k Dec 28, 2022
All PHP functions, rewritten to throw exceptions instead of returning false, now for php8

A set of core PHP functions rewritten to throw exceptions instead of returning false when an error is encountered.

TheCodingMachine 106 Nov 21, 2022
This is a plugin for pocketmine-mp, when locking a player's items helps players not to lose items or throw things around causing server lag.

[] LockedItem| v1.0.0 Player's item lock Features Player's item lock Players aren't afraid of losing items For Devolopers You can access to LockedItem

JeroGamingYT 3 Jan 4, 2022
Next generation airdrop tooling. try me!

Supporting Airdrop Task Solver Singkatnya, project ini terinspirasi oleh Viloid, tapi ini jauh lebih kompleks. Airdrop Task Solver adalah Aplikasi ber

Yuza 25 Jul 31, 2022
A library for property-based policy evaluation

PropAuth: Property-based policy evaluation Performing evaluations on credentials for authentication or sets of permissions on users has its limitation

psec.io 59 Nov 29, 2021