• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PHPCSStandards / PHP_CodeSniffer / 17483947696

05 Sep 2025 04:45AM UTC coverage: 78.507% (-0.7%) from 79.184%
17483947696

push

github

web-flow
Merge pull request #1213 from PHPCSStandards/feature/remove-filelist-tests

:fire: Hot Fix: remove FileList tests

25309 of 32238 relevant lines covered (78.51%)

73.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.0
/src/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php
1
<?php
2
/**
3
 * Warns when function values are returned directly.
4
 *
5
 * @author    Greg Sherwood <gsherwood@squiz.net>
6
 * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
 * @license   https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
 *
9
 * @deprecated 3.9.0
10
 */
11

12
namespace PHP_CodeSniffer\Standards\MySource\Sniffs\PHP;
13

14
use PHP_CodeSniffer\Sniffs\DeprecatedSniff;
15
use PHP_CodeSniffer\Sniffs\Sniff;
16
use PHP_CodeSniffer\Files\File;
17

18
class ReturnFunctionValueSniff implements Sniff, DeprecatedSniff
19
{
20

21

22
    /**
23
     * Returns an array of tokens this test wants to listen for.
24
     *
25
     * @return array<int|string>
26
     */
27
    public function register()
3✔
28
    {
29
        return [T_RETURN];
3✔
30

31
    }//end register()
32

33

34
    /**
35
     * Processes this sniff, when one of its tokens is encountered.
36
     *
37
     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
38
     * @param int                         $stackPtr  The position of the current token in
39
     *                                               the stack passed in $tokens.
40
     *
41
     * @return void
42
     */
43
    public function process(File $phpcsFile, $stackPtr)
3✔
44
    {
45
        $tokens = $phpcsFile->getTokens();
3✔
46

47
        $functionName = $phpcsFile->findNext(T_STRING, ($stackPtr + 1), null, false, null, true);
3✔
48

49
        while ($functionName !== false) {
3✔
50
            // Check if this is really a function.
51
            $bracket = $phpcsFile->findNext(T_WHITESPACE, ($functionName + 1), null, true);
3✔
52
            if ($tokens[$bracket]['code'] !== T_OPEN_PARENTHESIS) {
3✔
53
                // Not a function call.
54
                $functionName = $phpcsFile->findNext(T_STRING, ($functionName + 1), null, false, null, true);
3✔
55
                continue;
3✔
56
            }
57

58
            $error = 'The result of a function call should be assigned to a variable before being returned';
3✔
59
            $phpcsFile->addWarning($error, $stackPtr, 'NotAssigned');
3✔
60
            break;
3✔
61
        }
62

63
    }//end process()
2✔
64

65

66
    /**
67
     * Provide the version number in which the sniff was deprecated.
68
     *
69
     * @return string
70
     */
71
    public function getDeprecationVersion()
×
72
    {
73
        return 'v3.9.0';
×
74

75
    }//end getDeprecationVersion()
76

77

78
    /**
79
     * Provide the version number in which the sniff will be removed.
80
     *
81
     * @return string
82
     */
83
    public function getRemovalVersion()
×
84
    {
85
        return 'v4.0.0';
×
86

87
    }//end getRemovalVersion()
88

89

90
    /**
91
     * Provide a custom message to display with the deprecation.
92
     *
93
     * @return string
94
     */
95
    public function getDeprecationMessage()
×
96
    {
97
        return 'The MySource standard will be removed completely in v4.0.0.';
×
98

99
    }//end getDeprecationMessage()
100

101

102
}//end class
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc