Completed
Push — master ( d8f6c8...9bf369 )
by Дмитрий
10s
created

RandomApi::testSrand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
cc 1
eloc 3
c 1
b 1
f 1
nc 1
nop 0
dl 0
loc 5
rs 9.4285
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 34.

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 RandomApi
6
{
7
    /**
8
     * @return integer
9
     */
10
    public function testRand()
11
    {
12
        return rand(0, 100);
13
    }
14
15
    /**
16
     * @return integer
17
     */
18
    public function testSrand()
19
    {
20
        srand();
21
        return 1;
22
    }
23
24
    /**
25
     * @return integer
26
     */
27
    public function testGetRandMax()
28
    {
29
        return getrandmax();
30
    }
31
}
32
33
?>
34
----------------------------
35
[
36
    {
37
        "type":"rand.api.migration",
38
        "message":"Function rand() is not recommended, please use random_int/random_bytes (PHP 7) or mt_rand (not cryptographically secure) instead.",
39
        "file":"RandomApi.php",
40
        "line":11
41
    },
42
    {
43
        "type":"rand.api.migration",
44
        "message":"Function srand() is not recommended, please use random_int/random_bytes (PHP 7) or mt_srand (not cryptographically secure) instead.",
45
        "file":"RandomApi.php",
46
        "line":19
47
    },
48
    {
49
        "type":"rand.api.migration",
50
        "message":"Function getrandmax() is not recommended, please use random_int/random_bytes (PHP 7) or mt_getrandmax (not cryptographically secure) instead.",
51
        "file":"RandomApi.php",
52
        "line":28
53
    }
54
]
55