Commit graph

59 commits

Author SHA1 Message Date
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
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
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
71eda0b535 Better unit testing 2020-09-15 21:24:02 -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
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
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
b95ab24f36 setDivisionByZeroIsZero 2020-05-19 22:36:55 -04:00
Alexander Kiryukhin
cab8e2d38a Massive refactoring
More clean structure
Parsing without regular expressions
2020-05-15 21:51:23 +03:00
Bruce Wells
4d50343330
Negative expression start (#60)
* Update documentation for PHPFUI/InstaDoc

* Support for negative numbers starting paren enclosed expressions
2020-04-21 11:12:55 -04:00
Bruce Wells
4955c639e1
PHP 7.4 support (#57)
* Merge in neonxp master (#9)

* Version 1.1 (#51)

* Update README.md and more function support

* Removing phpunit symbolic link (#53)

* Left bracket and minus fix (#55)

* Left bracket and minus fix (#54)

* Add test for left bracket and minus fix #55

* Fix substraction by zero bug (#56)

Co-authored-by: franksl <info@streamlake.com>
Co-authored-by: Clément Lafont <johnrazeur@gmail.com>

* Docs and test updates

* Update composer

Co-authored-by: franksl <info@streamlake.com>
Co-authored-by: Clément Lafont <johnrazeur@gmail.com>
2020-02-07 17:45:33 -05:00
Bruce Wells
0eeed45566
Merge branch 'master' into master 2020-02-07 12:27:48 -05:00
Clément Lafont
43790a456e
Fix substraction by zero bug (#56) 2020-02-07 11:05:26 -05:00
Clément Lafont
707e22029d Left bracket and minus fix (#55)
* Left bracket and minus fix (#54)

* Add test for left bracket and minus fix #55
2020-01-13 12:09:18 -05:00
Bruce Wells
2db48eff95 PHP 7.4 support 2019-11-30 18:47:04 -05:00
Bruce Wells
f240380438
Version 1.1 (#51)
* Update README.md and more function support
2019-11-27 12:39:25 -05:00
Bruce Wells
84f3f967b7 Update README.md and more function support 2019-11-27 12:33:50 -05:00
franksl
29c5b5006c Logicandcompare (#50)
* 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.
2019-11-26 09:00:24 -05:00
Bruce Wells
b8456057af
Upgrading to PHP 7.1 (#48)
* Subtraction fix (#46) (#7)

* Updated unit tests
* Fixed docs
* Better unary minus support

* Subtraction fix (#46) (#8)

* Updated unit tests
* Fixed docs
* Better unary minus support

* Upgrading PHPUnit and dropping support for 5.6 and 7.0
2019-10-30 22:14:36 -04:00
Bruce Wells
ce50015732
Subtraction fix (#46)
* Updated unit tests
* Fixed docs
* Better unary minus support
2019-08-16 10:27:44 -04:00
Bruce Wells
2e847d6b81 Fixed merge error 2019-01-15 20:12:24 -05:00
Bruce Wells
01a0c8e627
Merge branch 'master' into master 2019-01-15 20:07:49 -05:00
Bruce Wells
47df3edbb6 Fixed comma operator
Added unit tests for expressions in function arguments.
Changed array_push to $var[] = native code.
2019-01-15 20:04:16 -05:00
Bruce Wells
265cff175e 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
2019-01-15 18:36:10 -05:00
Bruce Wells
816c112fcd Fixed function parameter order (#42)
* 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
2019-01-12 16:23:25 +03:00
Bruce Wells
c7f937c002
Merge branch 'master' into master 2019-01-12 00:05:03 -05:00
Bruce Wells
44e2bb192e 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
2019-01-11 23:56:39 -05:00
Bruce Wells
18b12aeeff
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
2019-01-10 20:18:10 -05:00
Alexander Kiryukhin
76517641f7 Fix single quotes parsing (#41)
* Fix single quotes parsing
Fix e-mails
Some small fixes

* Mistake in test

* More PHP versions
2019-01-10 19:27:45 -05:00
Bruce Wells
d50b665927
Fixed Lexor to correctly generate reverse polish notation (#33)
* Updated from NeonXP/MathExecutor

* Fixed function in () block issue
2018-11-26 10:06:26 -05:00
Bruce Wells
5bdc27efdb Fixed function in () block issue 2018-11-26 10:01:01 -05:00
Bruce Wells
f0d4562b9e Division By Zero Exception support
Updated the documentation.
Unit tests for strings.
DivisionByZeroException support.
2018-10-31 09:35:40 -04:00
Bruce Wells
334dd26e3c Removing DivisionByZeroException testing for now
Added more unit tests.
2018-10-25 11:43:57 -04:00
Bruce Wells
b9f72a001b Additional validation for bad expressions (*+ for example) 2018-10-24 16:01:01 -04:00