aboutsummaryrefslogtreecommitdiff
path: root/src/NXP/MathExecutor.php
Commit message (Collapse)AuthorAgeFilesLines
* Full support for arrays => min, max and avg funcs accept array argument. ↵Fatih Kızmaz2022-05-171-1/+2
| | | | | | | | Also array function is defined which return arguments as array. Square bracket arrays are also supported. (#108) valid expression -> "max([1,2,3])" valid expression -> "max(array(1,2,3))" valid expression -> "max($ages_arr)" valid expression -> "max(ages_arr())"
* Small support for arrays => min, max and avg funcs accept array argument. ↵Fatih Kızmaz2022-05-161-5/+29
| | | | | | | (handwritten arrays not supported yet, can be used for array variables or functions returning an array) (#107) invalid expression -> "max([1,2,3])" valid expression -> "max($ages_arr)" valid expression -> "max(ages_arr())"
* Support unlimited args for min, max default funcs. (#106)Fatih Kızmaz2022-05-131-7/+6
| | | | | | | | | * Support unlimited args for min, max default funcs. Default functions max and min were requiring 2 arguments strictly. Now they supoort unlimited args, same as php's min, max funcs. * Improved functions: support unlimited parameters (see min, max funcs), optional parameters (see round func), parameters with types (see round func, throws IncorrectFunctionParameterException on unmatched type, union types and intersection types not supported because of min php level! there is a todo for this, to support them later @see CustomFunction@execute) Also added unittests for improvements. * Run php-cs-fixer fix
* Two more tests + some code refactoring (#104)Javier Marín2022-05-091-310/+87
| | | | | | | | | | | * test: add testNullReturnType and testUnsupportedOperands * refactor: fix PhpDoc comments and use PHP 7.4 arrow functions * refactor: fix PHP-CS-Fixer issues * test: run testUnsupportedOperands() only on PHP8+ Co-authored-by: Javier Marín <contacto@ideatic.net>
* Phpcs fixer (#103)Bruce Wells2022-04-271-416/+430
| | | | | | | * Configuring PHP CS Fixer Dropping PHP 7,3 support * Fixing merge issue
* Add a custom variable validator + protected props (#98)Matthijs Meulenbrug2022-04-251-10/+46
|
* Adding varExists method and support for undefined var handler in getVar (#96)V2.1.112.0.4Bruce Wells2022-03-211-16/+29
| | | | | | | | | | | | | | | * Added varExists method * getVar now respects VarNotFoundHandler setting * Use local version of PHP-CS-Fixer Instead of hard coded version from github actions * Fixing actions * Fixing actions * Dropping testing for 7.3, as it is no longer supported
* PhpStan support, consts visibilty and name for tokens (#89)Javier Marín2021-07-141-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | * Added handler to define not found variables Added support for string variables Fixed strings and ints comparison error * Check if variables have scalar types (int, float, string and bool) Better $onVarNotFound logic * Better support for null variables * Better support for null variables * Better support for null variables * Allow null values in `setVar` method * Support for unary positive operator * Add PhpStan config file Fix PhpStan warnings Set consts visibility Add name info to variable tokens for easier debugging Co-authored-by: Javier Marín <contacto@ideatic.net>
* Support for unary positive expressions (#85)Javier Marín2021-03-051-20/+27
| | | * Support for unary positive operator
* Unary Minus (#84)V2.1.7Bruce Wells2021-02-171-0/+7
| | | Fixed unary minus to allow a minus sign in front of functions and parentheses.
* Cache-control improvements (#81)Mirosław Sztorc2021-01-061-5/+26
| | | | | | | | | | | | | | | | | * cache-control improvements * Update src/NXP/MathExecutor.php yeah, you're right. Co-authored-by: Alexander Kiryukhin <a.kiryukhin@mail.ru> * Update MathExecutor.php braces qfix * Update MathExecutor.php Co-authored-by: Alexander Kiryukhin <a.kiryukhin@mail.ru>
* add new functions and aliases to the old functions (#76)diman32102020-10-201-1/+64
| | | | | * add new functions and aliases to the old functions * add tests for new functions
* Allow null values in `setVar` method (#73)V2.1.3Javier Marín2020-09-161-1/+1
| | | | | | | | | | | | | | | | * Added handler to define not found variables Added support for string variables Fixed strings and ints comparison error * Check if variables have scalar types (int, float, string and bool) Better $onVarNotFound logic * Better support for null variables * Better support for null variables * Better support for null variables * Allow null values in `setVar` method
* Improved support for null variables (#72)V2.1.2Javier Marín2020-09-151-1/+1
| | | | | | | | | | | | | | * Added handler to define not found variables Added support for string variables Fixed strings and ints comparison error * Check if variables have scalar types (int, float, string and bool) Better $onVarNotFound logic * Better support for null variables * Better support for null variables * Better support for null variables
* Better setVar error message (#70)V2.1.1Bruce Wells2020-07-271-1/+2
| | | | Additional unit tests Readme update
* Handler for not found variables (#68)Javier Marín2020-07-261-10/+38
| | | | | | | | * Added handler to define not found variables Added support for string variables Fixed strings and ints comparison error * Check if variables have scalar types (int, float, string and bool) Better $onVarNotFound logic
* Code style fixes & Github Actions (#65)V2.0.2Alexander Kiryukhin2020-06-011-4/+5
| | | | | | | | | | | | * Code style fixes Up phpunit to v8 New CI * Remove travis * Fix CI badge * Added php-cs-fixer action
* Packagist tag (#64)V2.0.1Bruce Wells2020-05-211-1/+1
| | | | | * $variables should be private * Add Packagist tag
* Merge branch 'master' into neonxp-ngBruce Wells2020-05-201-2/+2
|\
| * WIP: New generation (#62)Alexander Kiryukhin2020-05-201-218/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Massive refactoring More clean structure Parsing without regular expressions * Cleanup unused imports * Fix version string for Travis * 7.1 downgrade * Fix readme
* | Null parameters allowedBruce Wells2020-05-201-1/+1
| |
* | Adding setVars back inBruce Wells2020-05-201-0/+19
| |
* | setDivisionByZeroIsZeroBruce Wells2020-05-201-0/+16
| |
* | Private membersBruce Wells2020-05-201-4/+90
| |
* | typed parameters and return typesBruce Wells2020-05-201-9/+9
| |
* | 7.1 downgradeAlexander Kiryukhin2020-05-151-2/+0
| |
* | Massive refactoringAlexander Kiryukhin2020-05-151-217/+169
|/ | | | | More clean structure Parsing without regular expressions
* Update documentation for PHPFUI/InstaDoc (#58)Bruce Wells2020-04-111-14/+30
|
* PHP 7.4 supportBruce Wells2019-12-011-2/+2
|
* Update README.md and more function supportBruce Wells2019-11-271-15/+108
|
* Logicandcompare (#50)franksl2019-11-261-3/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * TokenFactory: allowing multicharacter tokens * Added logical and compare operators: <, <=, >, >=, ==, !=, ||, && * Fixed operator priorities * Error messages fixes * Fixed operators priority The priorities are assigned by following the php language standard (https://www.php.net/manual/en/language.operators.precedence.php) I've assigned precedence in steps of 10 units by following the linked page: 230 clone new 220 ** 210 ++ -- ~ (int) (float) (string) (array) (object) (bool) @ 200 instanceof 190 ! 180 * / % 170 + - . 160 << >> 150 < <= > >= 140 == != === !== <> <=> 130 & 120 ^ 110 | 100 && 90 || 80 ?? 70 ? : 60 = += -= *= **= /= .= %= &= |= ^= <<= >>= 50 yield from 40 yield 30 and 20 xor 10 or * Added if() function * Cache key fix There are cases where the cache key creation raised an error, for example while evaluating the expression "if(cos(2), cos(2), 0)", because the if() function was passing a float to the MathExecutor:execute() method.
* Fixed function parameter order (#42)v0.7.1Bruce Wells2019-01-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fixed parsing for () * sync (#5) * Documentation fixes (#34) Fixing typos in and clarifying documentation. * MathExecutor allow override default operators, functions and vars (#36) * Added simple coc (#37) * Added simple coc * Fix * Replaceable operators (#38) * Updated from NeonXP/MathExecutor * Fixed function in () block issue * Fixing typos in and clarifying documentation. * Syncing from origin (#3) * Documentation fixes (#34) Fixing typos in and clarifying documentation. * MathExecutor allow override default operators, functions and vars (#36) * Allow for operators to be replaced based on regex expression * Fix md typo (#39) * Updated from NeonXP/MathExecutor * Fixed function in () block issue * Fixing typos in and clarifying documentation. * Syncing from origin (#3) * Documentation fixes (#34) Fixing typos in and clarifying documentation. * MathExecutor allow override default operators, functions and vars (#36) * Syncing to origin (#4) * Documentation fixes (#34) Fixing typos in and clarifying documentation. * MathExecutor allow override default operators, functions and vars (#36) * Added simple coc (#37) * Added simple coc * Fix * Replaceable operators (#38) * Updated from NeonXP/MathExecutor * Fixed function in () block issue * Fixing typos in and clarifying documentation. * Syncing from origin (#3) * Documentation fixes (#34) Fixing typos in and clarifying documentation. * MathExecutor allow override default operators, functions and vars (#36) * Allow for operators to be replaced based on regex expression * \\ instead of \ * Update README.md Some small fixes * Fix single quotes parsing (#41) * Fix single quotes parsing Fix e-mails Some small fixes * Mistake in test * More PHP versions * Update README.md Deleted `dev` branch * Fixed function parameter order Corrected $places default value for addFunction to match TokenFactory Added function order test and put expected order first in assertEquals If else blocks in calculator Updated docs
* Merge branch 'master' into masterBruce Wells2019-01-111-1/+1
|\
| * Syncing from origin (#3)Bruce Wells2019-01-101-29/+70
| | | | | | | | | | | | | | | | * Documentation fixes (#34) Fixing typos in and clarifying documentation. * MathExecutor allow override default operators, functions and vars (#36)
* | Fix single quotes parsing (#41)Alexander Kiryukhin2019-01-111-12/+15
| | | | | | | | | | | | | | | | | | | | * Fix single quotes parsing Fix e-mails Some small fixes * Mistake in test * More PHP versions
* | MathExecutor allow override default operators, functions and vars (#36)Timur2019-01-101-29/+70
|/
* Division By Zero Exception supportBruce Wells2018-10-311-0/+23
| | | | | | Updated the documentation. Unit tests for strings. DivisionByZeroException support.
* Merge branch 'master' into support_for_double_quoted_stringsBruce Wells2018-09-121-1/+5
|\
| * Merge branch 'master' into devAlexander Kiryukhin2018-09-061-0/+21
| |\
| | * Merge branch 'master' into getters_for_function_and_operatorsAlexander Kiryukhin2018-09-061-4/+0
| | |\
| | * | Add ability to get functions and operators that have been registeredBruce Wells2018-08-311-0/+21
| | | |
| * | | Added variable type to diagnostic messageBruce Wells2018-09-061-1/+1
| | | |
| * | | Exception MessagesBruce Wells2018-08-281-1/+1
| |/ / | | | | | | | | | Basically the token that is causing the exception for better diagnostics.
| * | ~ remove callable for PHP 5.3NeonXP2013-09-181-1/+1
| | |
* | | Support for double quoted stringsBruce Wells2018-09-121-6/+53
| |/ |/| | | | | | | | | | | | | Changed array() to [] syntax. Added variable in question to unknown variable exception. Added getVar and getVars accessor functions. Added getOperators and getFunctions accessor functions for completeness. Extended all Exceptions off MathExecutorException.
* | Removing the numeric test on setVar.charles VILLETTE2016-07-071-4/+0
|/
* + Added cache, which speeds up the repetitive calculationsNeonXP2013-09-061-5/+88
| | | | + Returned variables, because they need for cached expressions
* ~ PHP CS fixerNeonXP2013-09-061-3/+3
|
* Mass refactoringNeonXP2013-09-061-316/+35
| | | | | | | | | | | Some changes: + Added support of functions with multiple arguments + Added some default function (min, max, avg). just example of multiple arguments :) - Removed variables support (I think they pointless) ~ All tokens now in individual classes ~ Parsing based on regular expressions ~ Fix negative numbers ~ Fix grouping with brackets
* Fix to PSR standart, fix tokenizer, fix function executor.zhukv2013-08-031-0/+393