Download the PHP package gisostallenberg/bitwise-constant-calculator without Composer
On this page you can find all versions of the php package gisostallenberg/bitwise-constant-calculator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gisostallenberg/bitwise-constant-calculator
More information about gisostallenberg/bitwise-constant-calculator
Files in gisostallenberg/bitwise-constant-calculator
Package bitwise-constant-calculator
Short Description Calculates the value of bitwise operations on a list of constants
License MIT
Informations about the package bitwise-constant-calculator
Bitwise Constant Calculator
Calculates the value of bitwise operations on a list of constants
⚠️ Avoid in new code
This is not a security problem, but the calculation is wrong for mixed operators. It folds strictly left to right, while PHP binds bitwise operators
&>^>|. So the result can silently disagree with the equivalent PHP expression this package is meant to mirror:It also passes parsed input straight to
constant(), where an undefined constant is a fatalErroron PHP 8.What to use instead
There is no like-for-like replacement package, so pick by use case:
Only OR-ing flags from config (
A | B | C) needs no package:Arbitrary
& ^ | ~expressions with correct precedence — use symfony/expression-language, which has a real parser. It does not resolve constant names on its own, so register aconstant()function (or pass the values in as variables):- Specifically an
error_reportinglevel from config — use neither. PHP's own ini parser already evaluates strings likeE_ALL & ~E_DEPRECATED.