Download the PHP package xp-lang/php-is-operator without Composer
On this page you can find all versions of the php package xp-lang/php-is-operator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xp-lang/php-is-operator
More information about xp-lang/php-is-operator
Files in xp-lang/php-is-operator
Package php-is-operator
Short Description Is operator for PHP
License BSD-3-Clause
Homepage http://xp-framework.net/
Informations about the package php-is-operator
Is operator for PHP
Plugin for the XP Compiler which adds an is operator to the PHP language compatible with the PHP pattern matching RFC.
Before
A mix of operators, functions, syntax and XP core functionality is():
After
Anything that works as a parameter, property or return type can be used with the is operator.
Literal patterns
Tests using the identity comparison:
Numeric comparison patterns
With greater than (or equal) as well as less than (or equal) operators.
Structural patterns
Objects:
Arrays:
Maps:
Capturing values
Binding variables to object properties as well as array and map values:
Match statement
The operator can be used in the cases of a match statement:
Installation
After installing the XP Compiler into your project, also include this plugin.
No further action is required.
See also
- https://wiki.php.net/rfc/pattern-matching
- https://docs.hhvm.com/hack/expressions-and-operators/is
- https://kotlinlang.org/docs/reference/typecasts.html
- https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/is
- https://externals.io/message/120655 (Proposal to introduce is operator)
All versions of php-is-operator with dependencies
xp-framework/compiler Version ^9.0
xp-framework/ast Version ^12.0 | ^11.8
php Version >=7.4.0

