Completed
Push — feature/add-user-notice-about-... ( 05fef5 )
by Juliette
01:49
created

process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 2
1
<?php
2
/**
3
 * PHPCompatibility_Sniffs_Upgrade_Release716Sniff.
4
 *
5
 * @category PHP
6
 * @package  PHPCompatibility
7
 * @author   Juliette Reinders Folmer <[email protected]>
8
 */
9
10
/**
11
 * PHPCompatibility_Sniffs_Upgrade_Release716Sniff.
12
 *
13
 * Adds a temporary warning about the breaking changes in the upcoming 7.1.6
14
 * release of the PHPCompatibility standard.
15
 *
16
 * @category PHP
17
 * @package  PHPCompatibility
18
 * @author   Juliette Reinders Folmer <[email protected]>
19
 */
20
class PHPCompatibility_Sniffs_Upgrade_Release716Sniff extends PHPCompatibility_Sniff
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
21
{
22
	/**
23
	 * Keep track of whether the warning has been thrown yet.
24
	 *
25
	 * This warning should only be thrown once per run.
26
	 *
27
	 * @var bool
28
	 */
29
	protected $thrown = false;
30
31
    /**
32
     * Returns an array of tokens this test wants to listen for.
33
     *
34
     * @return array
35
     */
36
    public function register()
37
    {
38
        return array(
39
            T_OPEN_TAG,
40
        );
41
    }
42
43
    /**
44
     * Processes this test, when one of its tokens is encountered.
45
     *
46
     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
47
     * @param int                  $stackPtr  The position of the current token in the
48
     *                                        stack passed in $tokens.
49
     *
50
     * @return void
51
     */
52
    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
53
    {
54
		// Don't do anything if the warning has already been thrown once.
55
        if ($this->thrown === true) {
56
            return ($phpcsFile->numTokens + 1);
57
        }
58
59
        $phpcsFile->addWarning(
60
            "IMPORTANT NOTICE:\nPlease be advised that the upcoming 7.1.6 version of the PHPCompatibility standard will contain a breaking change.\n\nPlease read the changelog carefully when you upgrade and follow the instructions contained therein to retain uninterupted service.\n\nThank you for using PHPCompatibility!",
61
            0,
62
            'BreakingChange'
63
        );
64
65
        $this->thrown = true;
66
    }
67
}
68