1 | <?php |
||
5 | class UseCast |
||
6 | { |
||
7 | /** |
||
8 | * @return bool |
||
9 | */ |
||
10 | public function testIntval() |
||
11 | { |
||
12 | intval(1); |
||
13 | |||
14 | return true; |
||
15 | } |
||
16 | |||
17 | /** |
||
18 | * @return bool |
||
19 | */ |
||
20 | public function testBoolval() |
||
21 | { |
||
22 | boolval(1); |
||
23 | |||
24 | return true; |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * @return bool |
||
29 | */ |
||
30 | public function testFloatval() |
||
31 | { |
||
32 | floatval(1); |
||
33 | |||
34 | return true; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @return bool |
||
39 | */ |
||
40 | public function testDoubleval() |
||
41 | { |
||
42 | doubleval(1); |
||
43 | |||
44 | return true; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @return bool |
||
49 | */ |
||
50 | public function testStrval() |
||
51 | { |
||
52 | strval(1); |
||
53 | |||
54 | return true; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @return bool |
||
59 | */ |
||
60 | public function testIntvalTwoArguments() |
||
61 | { |
||
62 | intval(7,2); |
||
63 | |||
64 | return true; |
||
65 | } |
||
66 | } |
||
67 | ?> |
||
101 |
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.