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

Squiz.Commenting.FunctionComment.InvalidNoReturn with never return type #3798

Closed
SharkMachine opened this issue Apr 14, 2023 · 3 comments
Closed

Comments

@SharkMachine
Copy link

Describe the bug

Squiz.Commenting.FunctionComment doesn't seem to support PHP 8.1 never return type.

Code sample

<?php

/**
 * @return never
 */
function redirect(): never
{
    header('Location: /');
    exit();
}

Custom ruleset

<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <description>Coding standard.</description>
    <arg name="tab-width" value="4"/>

    <rule ref="PSR12" />

    <!-- PHPDoc and type hinting sniffs -->
    <rule ref="Squiz.Commenting.FunctionComment" />
    <exclude-pattern>vendor/*</exclude-pattern>
</ruleset>

To reproduce

Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above.
  2. Create a file called phpcs.xml with the custom ruleset above.
  3. Run phpcs test.php
  4. See error message displayed
FILE: test.php
------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------
 4 | ERROR | Function return type is not void, but function has no return statement
------------------------------------------------------------------------------------

Time: 34ms; Memory: 6MB

Expected behavior

never return type is detected and no error is shown.

Versions (please complete the following information):

  • OS: Ubuntu 22.04 LTS
  • PHP: 8.1
  • PHPCS: 3.7.2
  • Standard: Squiz
@fredden
Copy link
Contributor

fredden commented May 7, 2023

#3717 looks like it will fix this.

@jrfnl
Copy link
Contributor

jrfnl commented Dec 30, 2023

@SharkMachine Could you please verify ? The fix from #3717 was included in the 3.8.0 release from a few weeks ago.

@SharkMachine
Copy link
Author

The fix works

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