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

« back to all changes in this revision

Viewing changes to PHP_CodeSniffer-1.5.4/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.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
 
 
3
 
// Valid
4
 
$var1    = 'var1';
5
 
$var10   = 'var1';
6
 
$var100  = 'var1';
7
 
$var1000 = 'var1';
8
 
 
9
 
// Invalid
10
 
$var1    = 'var1';
11
 
$var10 = 'var1';
12
 
$var100 = 'var1';
13
 
$var1000 = 'var1';
14
 
 
15
 
// Valid
16
 
$var1  = 'var1';
17
 
$var10 = 'var1';
18
 
 
19
 
$var100  = 'var1';
20
 
$var1000 = 'var1';
21
 
 
22
 
// Invalid
23
 
$var1     = 'var1';
24
 
$var10    = 'var1';
25
 
 
26
 
$var100   = 'var1';
27
 
$var1000  = 'var1';
28
 
 
29
 
// Valid
30
 
$var1    .= 'var1';
31
 
$var10   .= 'var1';
32
 
$var100  .= 'var1';
33
 
$var1000 .= 'var1';
34
 
 
35
 
// Invalid
36
 
$var1    .= 'var1';
37
 
$var10 .= 'var1';
38
 
$var100 .= 'var1';
39
 
$var1000 .= 'var1';
40
 
 
41
 
// Valid
42
 
$var1     = 'var1';
43
 
$var10   .= 'var1';
44
 
$var100   = 'var1';
45
 
$var1000 .= 'var1';
46
 
 
47
 
// Invalid
48
 
$var1    = 'var1';
49
 
$var10   .= 'var1';
50
 
$var100  = 'var1';
51
 
$var1000 .= 'var1';
52
 
 
53
 
// Valid
54
 
$var1  .= 'var1';
55
 
$var10 .= 'var1';
56
 
 
57
 
$var100  .= 'var1';
58
 
$var1000 .= 'var1';
59
 
 
60
 
// Invalid
61
 
$var1     .= 'var1';
62
 
$var10    .= 'var1';
63
 
 
64
 
$var100   .= 'var1';
65
 
$var1000  .= 'var1';
66
 
 
67
 
// Valid
68
 
$var = 100;
69
 
 
70
 
// InValid
71
 
$var  = 100;
72
 
 
73
 
$commentStart = $phpcsFile->findPrevious();
74
 
$commentEnd   = $this->_phpcsFile;
75
 
$expected    .= '...';
76
 
 
77
 
// Invalid
78
 
$this->okButton    = new Button();
79
 
$content = new MyClass();
80
 
 
81
 
 
82
 
$GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] = array();
83
 
 
84
 
class MyClass
85
 
{
86
 
    const MODE_DEBUG = 'debug';
87
 
    const MODE_DEBUG2 = 'debug';
88
 
 
89
 
    $array[$test] = 'anything';
90
 
    $var          = 'anything';
91
 
 
92
 
    const MODE_DEBUG2  = 'debug';
93
 
    $array[$test]    = 'anything';
94
 
    $var             = 'anything';
95
 
    $array[($test + 1)] = 'anything';
96
 
    $array[($blah + (10 - $test))] = 'anything';
97
 
}
98
 
 
99
 
function myFunction($var=true)
100
 
{
101
 
    if ($strict === true) {
102
 
        $length          = strlen($string);
103
 
        $lastCharWasCaps = ($classFormat === false) ? false : true;
104
 
 
105
 
        for ($i = 1; $i < $length; $i++) {
106
 
            $isCaps = (strtoupper($string{$i}) === $string{$i}) ? true : false;
107
 
            if ($isCaps === true && $lastCharWasCaps === true) {
108
 
                return false;
109
 
            }
110
 
 
111
 
            $lastCharWasCaps = $isCaps;
112
 
        }
113
 
    }
114
 
}
115
 
 
116
 
// Valid
117
 
for ($i = 0; $i < 10; $i += 2) {
118
 
    $i = ($i - 1);
119
 
}
120
 
 
121
 
// Invalid
122
 
foreach ($files as $file) {
123
 
    $saves[$file] = array();
124
 
    $contents = stripslashes(file_get_contents($file));
125
 
    list($assetid, $time, $content) = explode("\n", $contents);
126
 
    $saves[$file]['assetid'] = $assetid;
127
 
}
128
 
 
129
 
$i = ($i - 10);
130
 
$ip = ($i - 10);
131
 
for ($i = 0; $i < 10; $i += 2) {
132
 
    $i = ($i - 10);
133
 
}
134
 
 
135
 
// Valid
136
 
$variable = 12;
137
 
$var      = a_very(long_line('that', 'contains'),
138
 
                   a_bunch('of long', 'parameters'),
139
 
                   'that_need to be aligned with the equal sign');
140
 
$var2     = 12;
141
 
 
142
 
// Valid
143
 
$variable = 12;
144
 
$var      = 'a very long line of text that contains '
145
 
            .$someVar
146
 
            .' and some other stuff that is too long to fit on one line';
147
 
$var2     = 12;
148
 
 
149
 
// Invalid
150
 
$variable = 12;
151
 
$var      = a_very(long_line('that', 'contains'),
152
 
                   a_bunch('of long', 'parameters'),
153
 
                   'that_need to be aligned with the equal sign');
154
 
$var2 = 12;
155
 
 
156
 
// Invalid
157
 
$variable = 12;
158
 
$var      = 'a very long line of text that contains '
159
 
            .$someVar
160
 
            .' and some other stuff that is too long to fit on one line';
161
 
$var2 = 12;
162
 
 
163
 
// Valid
164
 
$variable = 12;
165
 
$var     .= 'a very long line of text that contains '
166
 
            .$someVar
167
 
            .' and some other stuff that is too long to fit on one line';
168
 
$var2     = 12;
169
 
 
170
 
// Valid
171
 
$variable += 12;
172
 
$var      .= 'a very long line of text that contains '
173
 
            .$someVar
174
 
            .' and some other stuff that is too long to fit on one line';
175
 
$var2      = 12;
176
 
 
177
 
// Invalid
178
 
$variable  = 12;
179
 
$var      .= 'a very long line of text that contains '
180
 
            .$someVar
181
 
            .' and some other stuff that is too long to fit on one line';
182
 
$var2      = 12;
183
 
 
184
 
// Valid
185
 
$error = false;
186
 
while (list($h, $f) = each($handle)) {
187
 
    $error = true;
188
 
}
189
 
 
190
 
// Valid
191
 
$value = false;
192
 
function blah ($value = true) {
193
 
    $value = false;
194
 
    if ($value === true) {
195
 
        $value = false;
196
 
    }
197
 
}
198
 
 
199
 
if (TRUE) {
200
 
    $args = array('foo' => 'foo');
201
 
    $res  = 'bar';
202
 
}
203
 
?>