~ubuntu-branches/ubuntu/utopic/php-codesniffer/utopic-proposed

« back to all changes in this revision

Viewing changes to PHP_CodeSniffer-1.3.4/CodeSniffer/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc

  • Committer: Package Import Robot
  • Author(s): Thomas Goirand
  • Date: 2012-05-31 16:37:24 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120531163724-u6aiaubu8ks5dh5z
Tags: 1.3.4-0.1
* Non-maintainer upload.
* New upstream release (Closes: #599617, #634825).
* Swtiched debian/copyright to format 1.0 (rewrite was needed anyway, as the
upstream license changed).
* Switched package to pkg-php-tools and debhelper 8 sequencer.
* Now running unit tests at build time (so depends on phpunit (>= 3.6)).
* Section is now PHP.
* Added missing Build-Depends-Indep: php-pear.
* Added missing ${misc:Depends}.
* Added Vcs fields.
* Added homepage field.
* Reviewed short and long description.
* Added dependency on php-timer.
* Standards-Version: is now 3.9.3 (lots of changes, see above...).

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
?>