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

PHP linting problem when using PHP 7. #115

Closed
Otto42 opened this issue Aug 31, 2016 · 4 comments
Closed

PHP linting problem when using PHP 7. #115

Otto42 opened this issue Aug 31, 2016 · 4 comments

Comments

@Otto42
Copy link

Otto42 commented Aug 31, 2016

Some people want to write their code for a variety of systems, running a variety of PHP versions. This is exactly what this library is made for, to provide a backwards compatible way to generate random numbers.

However, if you do any kind of automatic linting to check for errors, then all the various random_bytes_* files will throw an error if you're using PHP 7 to do that linting. The specific error it will throw looks like this:

Fatal error: Cannot redeclare random_bytes() in .../random_compat/lib/random_bytes_com_dotnet.php on line 81.

..and similar.

Suggest that all these functions be wrapped in function_exists checks, or something equivalent, to prevent PHP 7's Lint process (php -l) from marking these as errors, even though they would not actually be used on a PHP 7 installation.

@paragonie-scott
Copy link
Member

We already do that here: https://github.com/paragonie/random_compat/blob/master/lib/random.php#L56

Would you be happier if we wrapped every implementation with redundant function_exists() checks just to stop linters from reporting false positives?

@glensc
Copy link
Contributor

glensc commented Oct 13, 2016

👎 for #115

your should fix your project linter to exclude stub includes.

what could be done here is to move those stubs that get loaded on condition to subdirs, then it would be simpler to exclude them in various lint tool configuration files.

@GrahamCampbell
Copy link

👎

@paragonie-scott
Copy link
Member

1788eb2

While the performance hit of an extra is_callable() check is nonzero, it's almost certainly negligible.

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

4 participants