Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Distinguish number between int and float #19

Closed
chriskapp opened this issue Feb 10, 2017 · 5 comments · Fixed by #20
Closed

Distinguish number between int and float #19

chriskapp opened this issue Feb 10, 2017 · 5 comments · Fixed by #20

Comments

@chriskapp
Copy link

Hi, I have the case where I define javascript code which defines a number and on the PHP side I have to differentiate whether the value is an int or float. At the moment all defined numbers are float. I have looked a bit in the source and the check whether to return an integer or float from a number is already implemented (php_v8_value.cc:268) but commented. Do you have plans to activate this detection? Otherwise I have to perform this check on the PHP side with something like strpos('.', $value) === false ? (int) $value : $value which I think is not the best solution.

@pinepain
Copy link
Member

Hi, thanks for noticing!

I was not sure how good it would be when you pass NumberValue object with value, say, withing uint32 range and get back Uint32Value object.

Though later I also faces a need to somehow differ float from int. As I'm currently doing some wild changes on php-v8 so I will cover this issue in one of commits.

@pinepain
Copy link
Member

FTR, psx-v8/composer.json: if you do mean to require php-v8, it requires PHP >= 7.0, so I'd suggest to specify "php": ">=5.5", like in php-v8-stubs/composer.json.

@chriskapp
Copy link
Author

Thx for the info and the fix. Regarding the composer.json I have another project which requires this package and where the v8 engine is only a "nice" feature but not required for project to work. So users can still install it under 5.6. without v8. If they have PHP >= 7.0 they can also install the extension and use the v8 engine. This is only the reason for this "wrong" version constraint. But I will probably drop soon the 5.6 support thus I can set the correct constraint.

@chriskapp
Copy link
Author

Hi, thx for the fix! Do you have roughly any time plan for a first stable version or are there plans for any huge BC breaks. I think the current API looks really great.

@pinepain
Copy link
Member

pinepain commented Feb 18, 2017

0.1.2 was just released and it has numerous BC breaks, though it's less likely that you'll be affected, see release notice for details.

There will be more upcoming BC-breaking changes in forseable future, not specific details at this time, but I plan to perform some API simplification and performance optimization.

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

Successfully merging a pull request may close this issue.

2 participants