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

Missing PHP 8.0 detection for parameter with a default value that is followed by a required parameter #71

Open
aadmathijssen opened this issue Nov 29, 2022 · 2 comments

Comments

@aadmathijssen
Copy link

aadmathijssen commented Nov 29, 2022

The following code is deprecated in PHP 8.0 because the parameter with a default value is followed by a required parameter (see the Deprecated Features for PHP Core):

<?php
function test($a = [], $b) {}

This is not reported by the phpdd tool:

$ phpdd  -t 8.0 test.php
Max file size set to: 1.000 MiB

File test.php

Analyzer has not detected any issues in your code.
Peak memory usage: 2.430 MB

BTW The php executable does report on this deprecation:

$ php test.php
PHP Deprecated:  Optional parameter $a declared before required parameter $b is implicitly treated as a required parameter in /path/to/test.php on line 2

Deprecated: Optional parameter $a declared before required parameter $b is implicitly treated as a required parameter in /path/to/test.php on line 2
@aadmathijssen aadmathijssen changed the title Missing PHP 8.0 detection for parameter with default values that is followed by a required parameter Missing PHP 8.0 detection for parameter with a default value that is followed by a required parameter Nov 30, 2022
@jdiazgon55
Copy link

I agree, I was able to reproduce the same

@wapmorgan
Copy link
Owner

It's hard to implement

NathanGibbs3 added a commit to NathanGibbs3/PhpDeprecationDetector that referenced this issue Apr 24, 2023
Processing of PHP function declarations.
Allows phpdd to detect declaration of optional function
params before required params.
Required params must come before optional on PHP 8x.
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

3 participants