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

docblock is not recognized as belonging to closure when closure is immediately returned #56

Open
Xerkus opened this issue Nov 30, 2020 · 0 comments
Labels
Bug Something isn't working

Comments

@Xerkus
Copy link
Member

Xerkus commented Nov 30, 2020

Bug Report

Q A
Version(s) 2.1.4

Summary

Coding standard does not recognize docblock as belonging to a closure when closure is immediately returned.
Bug is likely in PSR12.Files.FileHeader.IncorrectOrder

Current behavior

While applying Laminas CS to newly installed mezzio skeleton application I discovered that pipeline.php and routes.php trigger
errors PSR12.Files.FileHeader.IncorrectOrder: Header blocks must be separated by a single blank line and PSR12.Files.FileHeader.IncorrectOrder: The file-level docblock must follow the opening PHP tag in the file header

How to reproduce

Run CS check against mezzio skeleton config file https://github.com/mezzio/mezzio-skeleton/blob/c268aac1a272ee20b9bceaa5715aac4174d388ae/src/MezzioInstaller/Resources/config/routes-fastroute-minimal.php#L9-L26

<?php

declare(strict_types=1);

use Mezzio\Application;
use Mezzio\MiddlewareFactory;
use Psr\Container\ContainerInterface;

/**
 * FastRoute route configuration
 *
 * @see https://github.com/nikic/FastRoute
 *
 * Setup routes with a single request method:
 *
 * $app->get('/', App\Handler\HomePageHandler::class, 'home');
 * $app->post('/album', App\Handler\AlbumCreateHandler::class, 'album.create');
 * $app->put('/album/{id:\d+}', App\Handler\AlbumUpdateHandler::class, 'album.put');
 * $app->patch('/album/{id:\d+}', App\Handler\AlbumUpdateHandler::class, 'album.patch');
 * $app->delete('/album/{id:\d+}', App\Handler\AlbumDeleteHandler::class, 'album.delete');
 *
 * Or with multiple request methods:
 *
 * $app->route('/contact', App\Handler\ContactHandler::class, ['GET', 'POST', ...], 'contact');
 */
return static function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void {
};

Expected behavior

This docblock should be accepted as closure level rather than file level

@Xerkus Xerkus added the Bug Something isn't working label Nov 30, 2020
@Xerkus Xerkus changed the title comment block is not recognized as belonging to closure when closure is immediately returned docblock is not recognized as belonging to closure when closure is immediately returned Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant