Completed
Pull Request — master (#116)
by Enrico
03:35
created

Casts   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 86
rs 10
c 1
b 0
f 0
wmc 14
lcom 0
cbo 0

14 Methods

Rating   Name   Duplication   Size   Complexity  
A testIntToInt() 0 5 1
A testStrToInt() 0 5 1
A testNullToUnset() 0 5 1
A testIntToUnset() 0 5 1
A testArrToArr() 0 5 1
A testIntToArr() 0 5 1
A testBoolToBool() 0 5 1
A testIntToBool() 0 5 1
A testDoubleToDouble() 0 5 1
A testIntToDouble() 0 5 1
A testStringToString() 0 5 1
A testIntToString() 0 5 1
A testObjectToObject() 0 5 1
A testIntToObject() 0 5 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
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 92.

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 Casts
6
{
7
    public function testIntToInt()
8
    {
9
        $a = 3;
10
        return (int) $a;
11
    }
12
13
    public function testStrToInt()
14
    {
15
        $a = "a";
16
        return (int) $a;
17
    }
18
19
    public function testNullToUnset()
20
    {
21
        $a = null;
22
        return (unset) $a;
23
    }
24
25
    public function testIntToUnset()
26
    {
27
        $a = 1;
28
        return (unset) $a;
29
    }
30
31
    public function testArrToArr()
32
    {
33
        $a = [1];
34
        return (array) $a;
35
    }
36
37
    public function testIntToArr()
38
    {
39
        $a = 1;
40
        return (array) $a;
41
    }
42
43
    public function testBoolToBool()
44
    {
45
        $a = true;
46
        return (bool) $a;
47
    }
48
49
    public function testIntToBool()
50
    {
51
        $a = 1;
52
        return (bool) $a;
53
    }
54
55
    public function testDoubleToDouble()
56
    {
57
        $a = 1.3;
58
        return (double) $a;
59
    }
60
61
    public function testIntToDouble()
62
    {
63
        $a = 1;
64
        return (double) $a;
65
    }
66
67
    public function testStringToString()
68
    {
69
        $a = "a";
70
        return (string) $a;
71
    }
72
73
    public function testIntToString()
74
    {
75
        $a = 1;
76
        return (string) $a;
77
    }
78
79
    public function testObjectToObject()
80
    {
81
        $a = $this;
82
        return (object) $a;
83
    }
84
85
    public function testIntToObject()
86
    {
87
        $a = 1;
88
        return (object) $a;
89
    }
90
}
91
?>
92
----------------------------
93
[
94
    {
95
        "type":"stupid.cast",
96
        "message":"You are trying to cast 'integer' to 'integer'.",
97
        "file":"Casts.php",
98
        "line":9
99
    },
100
    {
101
        "type":"stupid.cast",
102
        "message":"You are trying to cast 'unset' to 'null'.",
103
        "file":"Casts.php",
104
        "line":21
105
    },
106
    {
107
        "type":"stupid.cast",
108
        "message":"You are trying to cast 'array' to 'array'.",
109
        "file":"Casts.php",
110
        "line":33
111
    },
112
    {
113
        "type":"stupid.cast",
114
        "message":"You are trying to cast 'boolean' to 'boolean'.",
115
        "file":"Casts.php",
116
        "line":45
117
    },
118
    {
119
        "type":"stupid.cast",
120
        "message":"You are trying to cast 'double' to 'double'.",
121
        "file":"Casts.php",
122
        "line":57
123
    },
124
    {
125
        "type":"stupid.cast",
126
        "message":"You are trying to cast 'string' to 'string'.",
127
        "file":"Casts.php",
128
        "line":69
129
    },
130
    {
131
        "type":"stupid.cast",
132
        "message":"You are trying to cast 'object' to 'object'.",
133
        "file":"Casts.php",
134
        "line":81
135
    }
136
]
137