Download the PHP package imliam/php-modifiers without Composer

On this page you can find all versions of the php package imliam/php-modifiers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-modifiers

PHP Modifiers

Latest Version on Packagist Build Status Code Quality Code Coverage Total Downloads

Adds the ability to apply a range of optional modifiers ! @ ~ + - when calling your class methods to augment them with a unique syntax.

For example, we may have a class where each of the following may do different things:

💾 Installation

You can install the package with Composer using the following command:

📝 Usage

This package's functionality is exposed through the HasModifiers trait, which can be applied to a class:

With the trait applied to the class, you must also define the class methods that can have modifiers used. This can be done by setting a static $modifierAliases property on the class.

This property should be an array that contains pairs of the class and method name that can be used.

For example if we wanted the say method on the current class to be able to use modifiers:

With this set up, inside the method we can now check if certain modifiers have been used by calling the static::hasModifier() method:

With it all in place, we can now call our method either with or without the modifier to get the desired behaviour:

Global Functions

If we wanted to register a global function that can accept modifiers, we can use one to call our class method, as well as registering it as an alias by adding it to the $modifierAliases property.

The function will now work in the same way as before:

The Modifiers

There are five modifiers available to use. It is very important to note that as they are all also regular operators in PHP, each of them have their own quirks that might change the expected behaviour and return values of the methods.

Using them

Due to this, it would make sense to only use these modifiers on void functions that are not expected to return anything of use.

! Exclamation Mark

Do not use the return value with this modifier.

The exclamation mark is a logical operator in PHP that negates the value to the opposite boolean. This means that any truthy value that is returned will be false, and any falsy value returned will be true.

+ Plus Symbol

Do not use the return value with this modifier.

The plus symbol is an identity arithmetic operator in PHP. Used as a modifier, it will attempt to cast the return value to an integer or float.

- Minus Symbol

Do not use the return value with this modifier.

The plus symbol is a negative identity arithmetic operator in PHP. Used as a modifier, it will attempt to cast the return value to an integer or float.

~ Tilde Symbol

Do not use the return value with this modifier.

The tilde symbol is a bitwise operator in PHP. However, as the operator itself performs a bitwise operation, any method using this operator must return an integer value, or something that can be cast to one.

@ "At" Symbol

You can use the return value with this modifier.

The "at" symbol is an error suppression operator in PHP that hides and ignores any errors that occur in the proceeding statement - meaning errors that might be within your method will be unexpectedly ignored.

However, this is the only one of the operators that does not alter the return value of the method.

How It Works

✨ Magic ✨

The modifier functionality works by taking a stack trace at the point the method was called, finding the point aliased method was called further up in the stack trace. Once these aliases are found, the file is read as a string and the PHP source tokens are parsed to find the operators that came before it.

This was originally seen in the Kint package as a way to quickly augment how your variables are displayed while debugging. Because it was designed for this environment, great performance was not a huge concern. Following stack traces and parsing source code are generally slow operations in PHP, so take it with a grain of salt and don't abuse it in large production applications.

Check the source code to see how it works in more depth. This package is a stripped down version of Kint's implementation that fits in a couple of small source files.

✅ Testing

🔖 Changelog

Please see the changelog file for more information on what has changed recently.

⬆️ Upgrading

Please see the upgrading file for details on upgrading from previous versions.

🎉 Contributing

Please see the code of conduct for details on contributing to the project.

🔒 Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

👷 Credits

♻️ License

The MIT License (MIT). Please see the license file for more information.


All versions of php-modifiers with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package imliam/php-modifiers contains the following files

Loading the files please wait ....