Conditions | 26 |
Paths | 14784 |
Total Lines | 67 |
Code Lines | 39 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
33 | public function getPath() |
||
34 | { |
||
35 | $tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(); |
||
36 | |||
37 | if (!isset($this->config[ 'path' ]) || $this->config[ 'path' ] == '') { |
||
38 | if (self::isPHPModule()) { |
||
39 | $path = $tmp_dir; |
||
40 | } else { |
||
41 | $document_root_path = rtrim($_SERVER[ 'DOCUMENT_ROOT' ], '/') . '/../'; |
||
42 | $path = isset($_SERVER[ 'DOCUMENT_ROOT' ]) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . '/'; |
||
43 | } |
||
44 | |||
45 | if ($this->config[ 'path' ] != '') { |
||
46 | $path = $this->config[ 'path' ]; |
||
1 ignored issue
–
show
|
|||
47 | } |
||
48 | |||
49 | } else { |
||
50 | $path = $this->config[ 'path' ]; |
||
51 | } |
||
52 | |||
53 | $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : ''; |
||
54 | if ($securityKey == "" || $securityKey == 'auto') { |
||
55 | $securityKey = $this->config[ 'securityKey' ]; |
||
56 | if ($securityKey == 'auto' || $securityKey == '') { |
||
57 | $securityKey = isset($_SERVER[ 'HTTP_HOST' ]) ? preg_replace('/^www./', '', strtolower($_SERVER[ 'HTTP_HOST' ])) : "default"; |
||
58 | } |
||
59 | } |
||
60 | if ($securityKey != '') { |
||
61 | $securityKey .= '/'; |
||
62 | } |
||
63 | |||
64 | $securityKey = $this->cleanFileName($securityKey); |
||
65 | |||
66 | $full_path = rtrim($path, '/') . '/' . $securityKey; |
||
67 | $full_pathx = md5($full_path); |
||
68 | |||
69 | |||
70 | if (!isset($this->tmp[ $full_pathx ])) { |
||
71 | |||
72 | if (!@file_exists($full_path) || !@is_writable($full_path)) { |
||
73 | if (!@file_exists($full_path)) { |
||
74 | @mkdir($full_path, $this->setChmodAuto(), true); |
||
1 ignored issue
–
show
|
|||
75 | } |
||
76 | if (!@is_writable($full_path)) { |
||
77 | @chmod($full_path, $this->setChmodAuto()); |
||
1 ignored issue
–
show
|
|||
78 | } |
||
79 | if (!@is_writable($full_path)) { |
||
80 | // switch back to tmp dir again if the path is not writeable |
||
81 | $full_path = rtrim($tmp_dir, '/') . '/' . $securityKey; |
||
82 | if (!@file_exists($full_path)) { |
||
83 | @mkdir($full_path, $this->setChmodAuto(), true); |
||
1 ignored issue
–
show
|
|||
84 | } |
||
85 | if (!@is_writable($full_path)) { |
||
86 | @chmod($full_path, $this->setChmodAuto()); |
||
1 ignored issue
–
show
|
|||
87 | } |
||
88 | } |
||
89 | if (!@file_exists($full_path) || !@is_writable($full_path)) { |
||
90 | throw new phpFastCacheCoreException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!', 92); |
||
91 | } |
||
92 | } |
||
93 | |||
94 | $this->tmp[ $full_pathx ] = true; |
||
95 | $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
||
96 | } |
||
97 | |||
98 | return realpath($full_path); |
||
99 | } |
||
100 | |||
214 | } |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.