For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 5 and the first side effect is on line 117.
The PSR-1: Basic Coding Standard recommends that a file should either introduce
new symbols, that is classes, functions, constants or similar, or have side effects.
Side effects are anything that executes logic, like for example printing output,
changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state
of an application. It also promotes a cleaner style of programming and makes your code
less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the
PSR-1.
Loading history...
2
3
namespace Tests\Compiling\Statements;
4
5
class DebugCode
6
{
7
/**
8
* @return bool
9
*/
10
public function testVarDumpUnexpected()
11
{
12
var_dump(1);
13
14
return true;
15
}
16
17
/**
18
* @return bool
19
*/
20
public function testVarDumpExpected()
21
{
22
/**
23
* @expected
24
*/
25
var_dump(1);
26
27
return true;
28
}
29
30
/**
31
* @return bool
32
*/
33
public function testVarDumpWithSimpleComment()
34
{
35
/**
36
* Expected
37
*/
38
var_dump(1);
39
40
return true;
41
}
42
43
/**
44
* @return bool
45
*/
46
public function testVarExportUnexpected()
47
{
48
var_export(1);
49
50
return true;
51
}
52
53
/**
54
* @return bool
55
*/
56
public function testVarExportExpected()
57
{
58
/**
59
* @expected
60
*/
61
var_export(1);
62
63
return true;
64
}
65
66
/**
67
* @return bool
68
*/
69
public function testVarExportWithSimpleComment()
70
{
71
/**
72
* Expected
73
*/
74
var_export(1);
75
76
return true;
77
}
78
79
/**
80
* @return bool
81
*/
82
public function testDebugZvalDumpUnexpected()
83
{
84
debug_zval_dump(1);
85
86
return true;
87
}
88
89
/**
90
* @return bool
91
*/
92
public function testDebugZvalDumpExpected()
93
{
94
/**
95
* @expected
96
*/
97
debug_zval_dump(1);
98
99
return true;
100
}
101
102
/**
103
* @return bool
104
*/
105
public function testDebugZvalDumpWithSimpleComment()
106
{
107
/**
108
* Expected
109
*/
110
debug_zval_dump(1);
111
112
return true;
113
}
114
}
115
116
?>
117
----------------------------
118
[
119
{
120
"type":"debug.code",
121
"message":"Function var_dump() is a debug function, please don`t use it in production.",
122
"file":"DebugCode.php",
123
"line":11
124
},
125
{
126
"type":"debug.code",
127
"message":"Function var_dump() is a debug function, please don`t use it in production.",
128
"file":"DebugCode.php",
129
"line":37
130
},
131
{
132
"type":"debug.code",
133
"message":"Function var_export() is a debug function, please don`t use it in production.",
134
"file":"DebugCode.php",
135
"line":47
136
},
137
{
138
"type":"debug.code",
139
"message":"Function var_export() is a debug function, please don`t use it in production.",
140
"file":"DebugCode.php",
141
"line":73
142
},
143
{
144
"type":"debug.code",
145
"message":"Function debug_zval_dump() is a debug function, please don`t use it in production.",
146
"file":"DebugCode.php",
147
"line":83
148
},
149
{
150
"type":"debug.code",
151
"message":"Function debug_zval_dump() is a debug function, please don`t use it in production.",
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.