Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unary operators inside functions don't work #16

Closed
valepu opened this issue Oct 27, 2018 · 7 comments
Closed

unary operators inside functions don't work #16

valepu opened this issue Oct 27, 2018 · 7 comments
Assignees
Labels

Comments

@valepu
Copy link

valepu commented Oct 27, 2018

if i run a function and the arguments after the first start with a unary operator (for example min(5, -10) or min(-5, -10) don't work while min(-5, 10) does ) i receive an error:

Notice: Undefined variable: leftOperand in /.../vendor/chriskonnertz/string-calc/src/ChrisKonnertz/StringCalc/Calculator/Calculator.php on line 117

If i wrap the arguments inside brackets it works min(5, (-10))
I have tested only with min and max. I'm gona do some more tests and report if i find something else

@valepu valepu changed the title unary operators inside functions unary operators inside functions don't work Oct 27, 2018
@valepu
Copy link
Author

valepu commented Oct 27, 2018

i have noticed, by debugging, that it tries to analyze the "-" symbol by itself and in this case isUnaryOperator is false so it enters in the else branch

@chriskonnertz chriskonnertz self-assigned this Oct 27, 2018
@chriskonnertz
Copy link
Owner

Hello, I will investigate.

@chriskonnertz
Copy link
Owner

Test code: 15cb960

Test result: https://travis-ci.org/chriskonnertz/string-calc/builds/447489420?utm_source=github_status&utm_medium=notification

Failing.

So it seems you are right. Unfortunately ;)

@valepu
Copy link
Author

valepu commented Oct 28, 2018

Thanks for your answer and for the great library (sorry if i sounded too cold on my first message but i was in a hurry). Is there anything i can do to help? Not sure i am knowledgeable enough to make a pull request

@chriskonnertz
Copy link
Owner

If you have any idea how to fix this issue do not hesitate to let me know :) I will try to find a solution on my own but I do not know when I will be able to do so - I'm quite busy these days.

@prohalexey
Copy link
Contributor

Hello!
I want to use your library as a dependency for my library, but there was a bug in this lib.
So i fixed it and made PR.
Please check it #17

@chriskonnertz
Copy link
Owner

chriskonnertz commented Nov 26, 2018

Hello prohalexey,

thank you for your contribution! Great to see you could find the spot where the issue is located and write an update that fixes it. Good work, thank you.

I've merged your pull request and will create a new release with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants