Commit graph

43 commits

Author SHA1 Message Date
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
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
Bruce Wells
7a36e07736
Merge branch 'master' into support_for_double_quoted_strings 2018-09-12 12:36:15 -04:00
Bruce Wells
00def17f0e Support for double quoted strings
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.
2018-09-12 12:33:17 -04:00
Alexander Kiryukhin
3011a1c556
Merge branch 'master' into getters_for_function_and_operators 2018-09-06 20:39:47 +03:00
ochi51
8d602b30dd Fixes exponentiation operator 2017-09-12 20:54:51 +09:00
Alexander Kiryukhin
fa935b0af6 + Test for division by zero 2016-04-01 17:25:29 +03:00
NeonXP
0b7e6b1b86 + added test for custom user functions 2013-09-18 20:34:51 +04:00
NeonXP
abc629a10b + Tests for scientific notation by AntonStoeckl 2013-09-06 16:43:45 +04:00
NeonXP
9cdc34290a Mass refactoring
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
2013-09-06 05:42:09 +04:00
zhukv
eb9c365161 Fix to PSR standart, fix tokenizer, fix function executor. 2013-08-03 13:47:47 +03:00