Commit graph

181 commits

Author SHA1 Message Date
Bruce Wells
a041bb58ad
More code style fixes (#118) 2022-08-04 08:18:48 -04:00
madman-81
9538001a42
Throw an IncorrectNumberOfFunctionParametersException if a function gets more arguments than it supports (#117)
* Throw an IncorrectNumberOfFunctionParametersException if a function gets more arguments than it supports

* Update CustomFunction.php

Code Style

Co-authored-by: Bruce Wells <brucekwells@gmail.com>
2022-08-04 08:07:41 -04:00
Bruce Wells
08b432e09d
Update README.md 2022-06-02 10:40:00 -04:00
Bruce Wells
a944fe4e56
Bcmath (#115)
* Add useBCMath

* Support for % operator (mod)
2022-06-01 18:11:51 -04:00
Bruce Wells
cbada2b920
Space should end open numbers (#113) 2022-05-28 16:02:04 -04:00
Bruce Wells
d1b060749e
Update readme with non redundant example (concat) (#111) 2022-05-21 13:38:58 -04:00
Fatih Kızmaz
3e6700d157
Added ability to escape quotes in strings. (#110)
* Added ability to escape quotes in strings.

* Removed type checking for customfunc arguments. It was a bad idea to check types, because php automatically tries to convert a parameter to required type and throws if it failures. On the other hand, we can check types also in callables if required.

* Update phpdoc

* Fix some typos + improve min, max, avg funcs.

* Update readme + improvements.

* Fix a typo in sample.

* Fix unshown backslash in readme.
2022-05-18 22:03:44 -04:00
Bruce Wells
f71b77a62e
Update README.md
Support for variable number of function parameters
2022-05-16 18:28:53 -04:00
Bruce Wells
ddf9dbfe0f
Release Prep (#109) 2022-05-16 18:18:37 -04:00
Fatih Kızmaz
5d6b4a5dfd
Full support for arrays => min, max and avg funcs accept array argument. 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())"
2022-05-16 17:57:37 -04:00
Fatih Kızmaz
2874b11341
Small support for arrays => min, max and avg funcs accept array argument. (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())"
2022-05-16 11:12:36 -04:00
Fatih Kızmaz
e21d59c9de
Support unlimited args for min, max default funcs. (#106)
* 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
2022-05-13 08:55:52 -04:00
Bruce Wells
da506a7ce0
Remove extra line (#105) 2022-05-09 14:26:21 -04:00
Javier Marín
645f1dfbc6
Two more tests + some code refactoring (#104)
* 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>
2022-05-09 14:13:30 -04:00
Bruce Wells
b7b46bfc47
Phpcs fixer (#103)
* Configuring PHP CS Fixer

Dropping PHP 7,3 support

* Fixing merge issue
2022-04-26 17:31:50 -04:00
Bruce Wells
c396a882ff
Prep for V2.2.0 release (#99) 2022-04-26 16:14:59 -04:00
Matthijs Meulenbrug
ef82911187
Add a custom variable validator + protected props (#98) 2022-04-25 10:50:51 -04:00
Bruce Wells
a0ff7a79af
Adding varExists method and support for undefined var handler in getVar (#96)
* 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
2022-03-21 12:52:25 -04:00
Mirosław Sztorc
6ebe4849ff
PHP 8.1 support (#94)
* php 8.1

* upgrading phpunit

* removing php7.2 support

* removing php7.2 from test matrix
2022-02-14 09:59:33 -05:00
Alex
9442a6f471
Merge pull request #92 from ideatic/fix-scientific-notation
fix: broken support for positive exponent numbers
2022-01-06 12:59:10 +03:00
Javier Marín
20f8cabf10 fix: broken support for positive exponent numbers 2022-01-05 09:53:06 +01:00
Javier Marín
d1d27b494d
PhpStan support, consts visibilty and name for tokens (#89)
* 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>
2021-07-13 22:12:41 -04:00
Bruce Wells
aa37abbaeb
Release prep (#86) 2021-03-04 20:08:57 -05:00
Bruce Wells
16dde01158
Merge branch 'master' into master 2021-03-04 19:47:04 -05:00
Javier Marín
d99491c1f4
Support for unary positive expressions (#85)
* Support for unary positive operator
2021-03-04 19:42:01 -05:00
Bruce Wells
17cc5b9dc4
Unary Minus (#84)
Fixed unary minus to allow a minus sign in front of functions and parentheses.
2021-02-16 22:13:44 -05:00
Chun-Sheng, Li
936ee5caca
Improve autoloading, asssertions and CI trigger (#79) 2021-01-05 19:07:33 -05:00
Mirosław Sztorc
2f043ba2b2
CI - new workflow for GitHub actions (#82)
* php>=7.2

* CI workflow - added php matrix
2021-01-05 19:07:15 -05:00
Mirosław Sztorc
a4b0fac121
Cache-control improvements (#81)
* 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>
2021-01-05 19:06:04 -05:00
Bruce Wells
5ed72fda6f
PHPUnit 8 or higher for PHP 8.0 support (#78) 2020-11-28 11:50:32 -05:00
Bruce Wells
761ac50344
Additional tests Hacktoberfest (#77)
* Additional tests

Co-authored-by: diman3210 <diman-3210@mail.ru>
2020-10-19 19:25:48 -04:00
diman3210
e28c1bf9e7
add new functions and aliases to the old functions (#76)
* add new functions and aliases to the old functions

* add tests for new functions
2020-10-19 18:48:30 -04:00
Bruce Wells
d9eb39e38d
Improved unit tests (#74)
* Variable fixes (#67)

* Reproduce if throws UnknownOperatorException

* Fix variable detection

* Adding IncorrectNumberOfFunctionParametersException

* Removing tabs

* Better exception message text

* Handler for not found variables (#68)

* 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

* Release prep (#69)

* String comparison unit tests

* getVars and getFunctions sanity checks

* Add dynamic variable documentation

* Better setVar error message (#70)

Additional unit tests
Readme update

* Improved support for null variables (#72)

* 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 (#73)

* 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

* Better unit testing

Co-authored-by: Javier Marín <javier@marinros.com>
2020-09-15 21:27:43 -04:00
Bruce Wells
c20f18d7a3
Merge branch 'master' into master 2020-09-15 21:27:15 -04:00
Bruce Wells
71eda0b535 Better unit testing 2020-09-15 21:24:02 -04:00
Javier Marín
80726f2bd5 Allow null values in setVar method (#73)
* 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
2020-09-15 21:14:44 -04:00
Javier Marín
8fc77e54e0 Improved support for null variables (#72)
* 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
2020-09-15 21:14:44 -04:00
Bruce Wells
8a2cae984f Better setVar error message (#70)
Additional unit tests
Readme update
2020-09-15 21:14:44 -04:00
Bruce Wells
92d1a4524b Release prep (#69)
* String comparison unit tests

* getVars and getFunctions sanity checks

* Add dynamic variable documentation
2020-09-15 21:14:44 -04:00
Javier Marín
462d6e4ddc Handler for not found variables (#68)
* 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
2020-09-15 21:14:44 -04:00
Bruce Wells
a0e0f405a9 Variable fixes (#67)
* Reproduce if throws UnknownOperatorException

* Fix variable detection

* Adding IncorrectNumberOfFunctionParametersException

* Removing tabs

* Better exception message text
2020-09-15 21:14:44 -04:00
Javier Marín
8aa6674831
Allow null values in setVar method (#73)
* 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
2020-09-15 21:08:14 -04:00
Javier Marín
f8faf3fa8d
Improved support for null variables (#72)
* 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
2020-09-14 20:47:26 -04:00
Bruce Wells
44d72cc252
Better setVar error message (#70)
Additional unit tests
Readme update
2020-07-27 12:25:59 -04:00
Bruce Wells
b38893d672
Release prep (#69)
* String comparison unit tests

* getVars and getFunctions sanity checks

* Add dynamic variable documentation
2020-07-26 22:14:51 -04:00
Javier Marín
c1e07f254a
Handler for not found variables (#68)
* 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
2020-07-25 22:27:26 -04:00
Bruce Wells
aa8ffe19f2
Variable fixes (#67)
* Reproduce if throws UnknownOperatorException

* Fix variable detection

* Adding IncorrectNumberOfFunctionParametersException

* Removing tabs

* Better exception message text
2020-06-04 11:43:16 -04:00
Bruce Wells
333a52e9aa
Merge pull request #4 from neonxp/master
Latest from master
2020-06-03 09:59:55 -04:00
Alexander Kiryukhin
ea898d7a7b
Code style fixes & Github Actions (#65)
* Code style fixes

Up phpunit to v8
New CI

* Remove travis

* Fix CI badge

* Added php-cs-fixer action
2020-05-31 20:50:39 -04:00
Bruce Wells
7852fc7d04
Packagist tag (#64)
* $variables should be private

* Add Packagist tag
2020-05-21 14:45:25 -04:00