~ubuntu-branches/ubuntu/vivid/php-codesniffer/vivid

« back to all changes in this revision

Viewing changes to PHP_CodeSniffer-1.5.5/CodeSniffer/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc

  • Committer: Package Import Robot
  • Author(s): David Prévot, Greg Sherwood, Alexey, Emily, David Prévot
  • Date: 2014-09-26 13:44:35 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140926134435-wvjq16miqq4d60y0
Tags: 1.5.5-1
[ Greg Sherwood ]
* Improved closure support in Generic ScopeIndentSniff
* Improved indented PHP tag support in Generic ScopeIndentSniff
* Standards can now be located within hidden directories
 (further fix for bug #20323)
* Fixed bug #20373 : Inline comment sniff tab handling way
* Fixed bug #20378 : Report appended to existing file if no errors
  found in run
* Fixed bug #20381 : Invalid "Comment closer must be on a new line"
* PHP tokenizer no longer converts class/function names to special
  tokens types
* Fixed bug #20386 : Squiz.Commenting.ClassComment.SpacingBefore
  thrown if first block comment
* Squiz and PEAR FunctionCommentSnif now support _()
* PEAR ValidFunctionNameSniff no longer throws an error for _()
* Fixed bug #248 : FunctionCommentSniff expects ampersand on param name
* Fixed bug #248 in Squiz sniff as well
* Fixed bug #265 : False positives with type hints in ForbiddenFunctionsSniff
* Prepare for 1.5.5 release

[ Alexey ]
* Allowed single undersored methods and functions

[ Emily ]
* Added var_dump to discouraged functions sniff

[ David Prévot ]
* Revert "Add XS-Testsuite still needed for ci.d.n"
* Add self to uploaders
* Bump standards version to 3.9.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
$value = ($one + $two);
 
3
$value = $one + $two;
 
4
 
 
5
$value = ($one - $two);
 
6
$value = $one - $two;
 
7
 
 
8
$value = ($one * $two);
 
9
$value = $one * $two;
 
10
 
 
11
$value = ($one / $two);
 
12
$value = $one / $two;
 
13
 
 
14
$value = ($one % $two);
 
15
$value = $one % $two;
 
16
 
 
17
$value = ($one + $two + $three);
 
18
$value = $one + $two + $three;
 
19
$value = ($one + ($two + $three));
 
20
$value = $one + ($two + $three);
 
21
 
 
22
$value++;
 
23
$value--;
 
24
$value = -1;
 
25
$value = - 1;
 
26
 
 
27
$value = (1 + 2);
 
28
$value = 1 + 2;
 
29
 
 
30
$value = (1 - 2);
 
31
$value = 1 - 2;
 
32
 
 
33
$value = (1 * 2);
 
34
$value = 1 * 2;
 
35
 
 
36
$value = (1 / 2);
 
37
$value = 1 / 2;
 
38
 
 
39
$value = (1 % 2);
 
40
$value = 1 % 2;
 
41
 
 
42
$value = (1 + 2 + 3);
 
43
$value = 1 + 2 + 3;
 
44
$value = (1 + (2 + 3));
 
45
$value = 1 + (2 + 3);
 
46
 
 
47
$value = $one + 2 + 3 - ($four * $five * (6 + 7)) + $nine + 2;
 
48
$value = myFunction($tokens[$stackPtr - 1]);
 
49
 
 
50
for ($i = 1 + 2; $i < 4 + 5; $i++) {
 
51
}
 
52
 
 
53
function myFunction()
 
54
{
 
55
    $value = ($one + 1) + ($two + 2) + (myFunction() + 2);
 
56
    $value = myFunction() + 2;
 
57
    $value = (myFunction($var) + myFunction2($var));
 
58
    return -1;
 
59
}
 
60
 
 
61
$line  = substr($line, 0, -2);
 
62
$words = preg_split('|(\s+)|', $line."\n", -1, $flags);
 
63
if (!isset($this->words[$wordPos-1]) || $this->words[$wordPos-1] !== ' ') {
 
64
} else if ($this->tokens[$pos + 1] === "\n") {
 
65
}
 
66
 
 
67
if ($pos === count($this->tokens) - 1) {
 
68
    $file = '...'.substr($file, (($padding * -1) + 3));
 
69
}
 
70
 
 
71
if (substr($basename, -5) !== 'Sniff') {
 
72
    $i = ($this->_tokens[$i]['parenthesis_closer'] + 1);
 
73
}
 
74
 
 
75
$pos = $this->_getShortCommentEndPos();
 
76
if ($pos === -1) {
 
77
    $stackPtr = ($tokens[$next][$to] - 1);
 
78
    $stackPtr = ($tokens[$next][$pattern[$i]['to']] + 1);
 
79
    $var = (($var1 + $var2) + $var3 + $var4)
 
80
}
 
81
 
 
82
$commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1);
 
83
$commentEnd   = ($this->_phpcsFile->findNext(T_DOC_COMMENT, ($commentStart + 1), null, true) - 1);
 
84
$expected    .= '...'.substr($tokens[($stackPtr - 2)]['content'], -5).$tokens[$stackPtr]['content'];
 
85
 
 
86
if (($tokens[$nextToken - 1]['code']) !== T_WHITESPACE) {
 
87
    $errorPos = ($params[(count($params) - 1)]->getLine() + $commentStart);
 
88
}
 
89
 
 
90
while (($nextSpace = $phpcsFile->findNext(T_WHITESPACE, $nextSpace + 1, $nextBreak)) !== false) {
 
91
}
 
92
 
 
93
foreach ($attributes as $id => &$attribute) {
 
94
}
 
95
 
 
96
class MyClass
 
97
{
 
98
 
 
99
 
 
100
    public function &myFunction(array &$one, array &$two)
 
101
    {
 
102
 
 
103
    }//end myFunction()
 
104
 
 
105
 
 
106
}//end class
 
107
 
 
108
if ($index < -1) $index = 0;
 
109
if ($index < - 1) $index = 0;
 
110
 
 
111
$three = ceil($one / $two);
 
112
$three = ceil(($one / $two) / $four);
 
113
$three = ceil($one / ($two / $four));
 
114
 
 
115
$four = -0.25;
 
116
 
 
117
$three = ceil($one[1] / $two);
 
118
 
 
119
switch ($number % 10) {
 
120
    case -1:
 
121
        $suffix = 'st';
 
122
    break;
 
123
}
 
124
 
 
125
$expectedPermission = array(
 
126
                       'granted'        => 4,
 
127
                       'denied'         => 1,
 
128
                       'cascade'        => TRUE,
 
129
                       'blockergranted' => 2,
 
130
                       'blockerdenied'  => - 3,
 
131
                       'effective'      => TRUE,
 
132
                      );
 
133
?>