Shouldn't in @return string|void the 'void' be treated like null when asking to order nulls first ?
$ php -v
PHP 7.3.22-1+ubuntu18.04.1+deb.sury.org+1
$ vendor/bin/php-cs-fixer -V
PHP CS Fixer 2.16.4 Yellow Bird by Fabien Potencier and Dariusz Ruminski
E.g. something like the following .php_cs:
php
<?php
return PhpCsFixer\Config::create()
->setRules([
'phpdoc_types_order' => [
'null_adjustment' => 'always_first',
'sort_algorithm' => 'alpha'
]
])
Should sort this (pretty stock from Laravel, just vimeo/psalm replacing null with void in the past):
<?php declare(strict_types=1);
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Http\Request;
use function route;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param Request $request
* @return string|void
*/
protected function redirectTo($request)
{
if (!$request->expectsJson()) {
return route('login');
}
}
}
as @return void|string, since return void is null-ish.
For now I replaced 'void|' with 'null|' in my code, as that might be more propper.
.. this could be a fixer in and of itself 馃檴
Mixing void with other possible return types does not make sense: void specifically means the function never returns any value, including null. I'm closing as I don't think this should be implemented.
Fine with me. I fixed the annotation bug at Laravel too.
Most helpful comment
Mixing
voidwith other possible return types does not make sense:voidspecifically means the function never returns any value, includingnull. I'm closing as I don't think this should be implemented.