Conditions | 2 |
Paths | 2 |
Total Lines | 18 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
33 | public static function generateRandomString($length = 32) |
||
34 | { |
||
35 | $chars = 'abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ023456789'; |
||
36 | $charsCount = strlen($chars); |
||
37 | |||
38 | srand((double)microtime() * 1000000); |
||
39 | $i = 1; |
||
40 | $token = ''; |
||
41 | |||
42 | while ($i <= $length) { |
||
43 | $num = rand() % $charsCount; |
||
44 | $tmp = substr($chars, $num, 1); |
||
45 | $token .= $tmp; |
||
46 | $i++; |
||
47 | } |
||
48 | |||
49 | return $token; |
||
50 | } |
||
51 | |||
70 |
Let’s assume you have a class which uses late-static binding:
}
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: