Download the PHP package jblo/operator without Composer

On this page you can find all versions of the php package jblo/operator. 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 operator

PHP Operator Overloading

This extension provides operator overloading for PHP 8.

There is an extension for operator overloading in PHP 7, pecl-php-operator, but it has been broken since PHP 7.4. This extension is a rewrite of that extension, but for PHP 8.

Regular Operators

These operators are the ones that make the most sense to overload. They are assignment, unary, binary, and comparison operators.

Arithmetic Operators

Operator Name Operator Implemented Function Call
Identity +$a Maybe[^1]
Negation -$a Maybe[^1]
Addition $a + $b Yes $a::__add($b)
Subtraction $a - $b Yes $a::__sub($b)
Multiplication $a * $b Yes $a::__mul($b)
Division $a / $b Yes $a::__div($b)
Modulo $a % $b Yes $a::__mod($b)
Exponent $a ** $b Yes $a::__pow($b)

Assignment Operators

Operator Name Operator Implemented Function Call
Assignment $a = $b Yes $a::__assign($b)

Bitwise Operators

Operator Name Operator Use Implemented Function Call
And $a & $b Yes $a::__bw_and($b)
Or $a \| $b Yes $a::__bw_or($b)
Xor $a ^ $b Yes $a::__bw_xor($b)
Not ~$a Yes $a::__bw_not($b)
Shift left $a << $b Yes $a::__sl($b)
Shift right $a >> $b Yes $a::__sr($b)

Comparison Operators

Operator Name Operator Use Implemented Function Call
Equal $a == $b Yes $a::__is_equal($b)
Identical $a === $b Yes $a::__is_identical($b)
Not equal $a != $b Yes $a::__is_not_equal($b)
Not equal $a <> $b Yes $a::__is_not_equal($b)
Not identical $a !== $b Yes $a::__is_not_identical($b)
Less than $a < $b Yes $a::__is_smaller($b)
Greater than $a > $b Yes[^4] $a::__is_greater($b)
Less than or equal $a <= $b Yes $a::__is_smaller_or_equal($b)
Greater than or equal $a >= $b Yes[^4] $a::__is_greater_or_equal($b)
Spaceship $a <=> $b Yes $a::__spaceship($b)
Ternary $a ?: $b No
Null coalescing $a ?? $b No[^3]

Incrementing/Decrementing Operators

Operator Name Operator Use Implemented Function Call
Pre-increment ++$a Yes $a::__pre_inc
Post-increment $a++ Yes $a::__post_inc
Pre-decrement --$a Yes $a::__pre_dec
Post-decrement $a-- Yes $a::__post_dec

Logical Operators

Operator Name Operator Use Implemented Function Call
And $a and $b Maybe[^1]
Or $a or $b Maybe[^1]
Xor $a xor $b Maybe[^1]
Not $a ! $b Maybe[^1]
And $a && $b Maybe[^1]
Or $a \|\| $b Maybe[^1]

String Operators

Operator Name Operator Use Implemented Function Call
Concatenation $a . $b Yes $a::__concat($b)

Combination Assignment Operators

There are a few assignment operators that are overloaded. These are an operator and an assignment operator combined[^2]. For example, += is an addition assignment operator.

Operator Name Operator Use Implemented Function Call
Addition Assignment $a += $b Yes $a::__assign_add($b)
Subtraction Assignment $a -= $b Yes $a::__assign_sub($b)
Multiplication Assignment $a *= $b Yes $a::__assign_mul($b)
Division Assignment $a /= $b Yes $a::__assign_div($b)
Modulo Assignment $a %= $b Yes $a::__assign_mod($b)
Exponent Assignment $a **= $b Yes $a::__assign_pow($b)
And Assignment $a &= $b Yes $a::__assign_and($b)
Or Assignment $a \|= $b Yes $a::__assign_or($b)
Xor Assignment $a ^= $b Yes $a::__assign_xor($b)
Shift left Assignment $a <<= $b Yes $a::__assign_sl($b)
Shift right Assignment $a >>= $b Yes $a::__assign_sr($b)
Coalesce Assignment $a ??= $b No
Concat Assignment $a .= $b Yes $a::__assign_concat($b)

Other Opcodes

There are a number of opcodes, more than 200 in total. Many of them don't make sense to overload. The full opcode list can be found in the php-src repo here.

[^1]: This might be the same as other opcodes, or maybe there is no opcode for it, but I'm not sure. I haven't tested it yet.

[^2]: There isn't a separate opcode for +=, it's just ZEND_ADD as the extra-details within the ZEND_ASSIGN_OP opcode. Those separate opcodes were removed in PHP 7.4. This is one of the things that broke the original operator overloading extension.

[^3]: I've tried to implement this one, but no matter what I return the PHP engine doesn't want to take the left hand argument. This might be kinda moot to do though, since if an object is null-ish, it wouldn't be able to check if it's null, right? (The object wouldn't be initialized, is what I'm getting at.) I'm not sure what to have the function return to satisfy the PHP engine, and if I can't write the PHP correctly, then that also means that I'd need to write up a special documentation note just for that function to describe how to implement it and what to return to get it to work in the userland (since I can't get it to work in userland myself).

[^4]: Internally in the PHP engine, the > and >= operators are just the < and <= operators with the arguments swapped. This extension swaps the operands back to the correct order before calling the function. This might cause some issues comparing objects to objects when not overloading the operator. Further testing is required.


All versions of operator with dependencies

PHP Build Version
Package Version
Requires php Version >= 8.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 jblo/operator contains the following files

Loading the files please wait ...