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

Octal values is malformed #31

Closed
adambisek opened this issue Jun 14, 2016 · 9 comments
Closed

Octal values is malformed #31

adambisek opened this issue Jun 14, 2016 · 9 comments

Comments

@adambisek
Copy link

@adambisek adambisek commented Jun 14, 2016

When I write chmod octal value, leading zero is stripped and an integer returned:

Example code:
fileMode: 0777 -> returns int(777)

In PHP (and eg. Symfony Container as well) is it intepreted as an octal value and converted to integer:
var_dump(0777); // int(511)

I hope this is not intended behaviour, may we solve it?

@dg

This comment has been minimized.

Copy link
Member

@dg dg commented Jun 17, 2016

This is intended

['0777', 777],

@adambisek

This comment has been minimized.

Copy link
Author

@adambisek adambisek commented Jun 17, 2016

I suppose that is an method to make neon syntax more user-friendly.

What would you recommend please?

At this moment is only suitable solution to make it string, but it not so smart and easy to use (we're using it for chmod function and we have to cast that string to octal everywhere we use it).

@Majkl578

This comment has been minimized.

Copy link

@Majkl578 Majkl578 commented Jun 17, 2016

@adambisek you can enter decimal value I guess, e.g. 511 for 777.

@dg

This comment has been minimized.

Copy link
Member

@dg dg commented Jun 25, 2016

The question is whether to add support for octal numbers. It is BC break and they are used rarely (probably only for chmod and chmod is configured via neon rarely too).

Or we can introduce new syntax like octal(777).

@adambisek

This comment has been minimized.

Copy link
Author

@adambisek adambisek commented Jun 25, 2016

Thanks for replies guys.
On the other side, I admit that PHP behaviour is a bit tricky.

But, my personal opinion is, the behaviour should be like PHP variable (for example config in an array).
By the way, it is not about PHP only, for example Javascript does the same thing: https://jsfiddle.net/yz5wagvg/
Stripping leading zeros and creating an int is a mathematical solution, not programmatical.
When anybody writes var: 0123 and expects an int(123), it is wrong.

Anyway, if you really don't want BC break, the introduced new syntax is less painful than string value (and calling octdec in PHP script).

@dg

This comment has been minimized.

Copy link
Member

@dg dg commented Jun 25, 2016

hex 0x123 and binary 0b10110 syntax is clearly distinguished from decimal numbers, but octal 0123 is not. It is historic convention (programmatical, not mathematical) from the sixties and makes a lot of complications in JavaScript (and is deprecated). So I don't like to adopt it.

Other possible syntax is 0o777.

@adambisek

This comment has been minimized.

Copy link
Author

@adambisek adambisek commented Jun 25, 2016

Yes, syntax 0o777 I like, that's good.
What`s next? Some voting or have I to send PR?

@dg

This comment has been minimized.

Copy link
Member

@dg dg commented Jun 25, 2016

0o777 is the same as 0o0777. Leading zeros has no meaning.

@dg dg closed this in 53147bd Jun 25, 2016
@adambisek

This comment has been minimized.

Copy link
Author

@adambisek adambisek commented Jun 25, 2016

Wow, that was quick. Thank you!

dg added a commit that referenced this issue Jun 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.