Php-cs-fixer: Default value for parameters with a class type hint can only be NULL in

Created on 16 Feb 2017  路  9Comments  路  Source: FriendsOfPHP/PHP-CS-Fixer

I have code:

function joinIfNot(\Illuminate\Database\Eloquent\Builder $builder, string $table, string $one, string $operator = null, string $two = null, string $type = 'inner', bool $where = false)
{
    foreach ($builder->getQuery()->joins as $joinClause) {
        if ($joinClause->table === $table) {
            return $builder;
        }
    }

    return $builder->join($table, $one, $operator, $two, $type, $where);
}

I am getting error:

"vendor/bin/php-cs-fixer" fix

Fatal error: Default value for parameters with a class type hint can only be NULL in C:\xampp\htdocs\www\laravel\am2\green-rush\app\helpers.php on line 59

statuto verify

Most helpful comment

Actualizar la versi贸n de php lo resuelve, era problema de las bibliotecas de php en mi caso.

All 9 comments

Using scalar type hints like string is supported since PHP 7. I suppose you run this code with a lower version which expects a string _class_ and thus does not allow a string (scalar) default value.

https://3v4l.org/FP2vH

My guess is you are running PHP-CS-Fixer on a version lower than PHP 7.

Closing for now as this issue staled,
@fico7489 please feel free to comment here more if you think the issue was not properly analyzed.

I am on PHP 7.1.7 and I am getting the same error from this peace of code:

function create(Product $entity = NULL, boolean $allowedLockPrice = FALSE){}

please make a full report using following template:
https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/.github/ISSUE_TEMPLATE

Actualizar la versi贸n de php lo resuelve, era problema de las bibliotecas de php en mi caso.

sorry @JairVel , we provide support here only in english.

Actualizar la versi贸n de php lo resuelve, era problema de las bibliotecas de php en mi caso.

Gracias, era eso tambien. 馃憤馃徎

sorry @JairVel , we provide support here only in english.

Are you serious?

hi @Oxicode and @JairVel , we would like to support any language... but if people don't know the langange and therefore don't understand someone how can we help?

Was this page helpful?
0 / 5 - 0 ratings