Pages

Saturday, June 26, 2021

Code inspection warning : Optional parameter is provided before required

I am used to inspect my source code and tried to solve warning. I've had the warning : Optional parameter is provided before required

This warning occured on this line  : 

function generateMenu($level=1, $label, $code, $labos) {

}

The explanation of this warning is quite simple.Optional parameters (with default values) always should be at the end, otherwise they are not optional !

So you have to write your function like this : 

function generateMenu($label, $code, $labos, $level=1) {

}

PHP Storm 2021.1.3
PHP 7.1

No comments:

Post a Comment

How to add internationalization to your android application ?

  Configure your project First, you need to add the following configuration in your file build.gradle (Module : app) : android { ..... andr...