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 strings are incorrectly converted to integers #11

Open
ocean90 opened this issue Jul 29, 2022 · 1 comment
Open

Octal strings are incorrectly converted to integers #11

ocean90 opened this issue Jul 29, 2022 · 1 comment

Comments

@ocean90
Copy link

ocean90 commented Jul 29, 2022

This is about values like 0755 or 0664 which are used for file permissions. When using DIR_PERM=0755 then env() will convert this to int(755) but the correct value should have been int(493).

php > var_dump( ctype_digit( '0755' ) );
bool(true)
php > var_dump( (int) '0755' );
int(755)
php > var_dump( (int) 0755 );
int(493)

To support this a self::CONVERT_OCTAL option is probably needed which can be used to run before the current integer conversion. https://www.php.net/manual/de/function.octdec.php#85170 might be helpful.

Thoughts?

@oscarotero
Copy link
Owner

A workaround is using quotes to keep the values as strings: DIR_PERM="0755".

I'm OK with self::CONVERT_OCTAL but not sure if there's a good way to detect if a number is octal. Does all octal numbers start with zero?

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

No branches or pull requests

2 participants