1 | <?php |
||
29 | class FileAgeCheck implements EnvironmentCheck |
||
30 | { |
||
31 | /** |
||
32 | * @var int |
||
33 | */ |
||
34 | const CHECK_SINGLE = 1; |
||
35 | |||
36 | /** |
||
37 | * @var int |
||
38 | */ |
||
39 | const CHECK_ALL = 2; |
||
40 | |||
41 | /** |
||
42 | * Absolute path to a file or folder, compatible with glob(). |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $path; |
||
47 | |||
48 | /** |
||
49 | * Relative date specification, compatible with strtotime(). |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $relativeAge; |
||
54 | |||
55 | /** |
||
56 | * The function to use for checking file age: so filemtime(), filectime(), or fileatime(). |
||
57 | * |
||
58 | * @var string |
||
59 | */ |
||
60 | protected $checkFn; |
||
61 | |||
62 | /** |
||
63 | * Constant, check for a single file to match age criteria, or all of them. |
||
64 | * |
||
65 | * @var int |
||
66 | */ |
||
67 | protected $checkType; |
||
68 | |||
69 | /** |
||
70 | * Type of comparison (either > or <). |
||
71 | * |
||
72 | * @var string |
||
73 | */ |
||
74 | protected $compareOperand; |
||
75 | |||
76 | /** |
||
77 | * @param string $path |
||
78 | * @param string $relativeAge |
||
79 | * @param string $compareOperand |
||
80 | * @param null|int $checkType |
||
81 | * @param string $checkFn |
||
82 | */ |
||
83 | public function __construct($path, $relativeAge, $compareOperand = '>', $checkType = null, $checkFn = 'filemtime') |
||
91 | |||
92 | /** |
||
93 | * {@inheritDoc} |
||
94 | * |
||
95 | * @return array |
||
96 | */ |
||
97 | public function check() |
||
141 | |||
142 | /** |
||
143 | * Gets a list of absolute file paths. |
||
144 | * |
||
145 | * @return array |
||
146 | */ |
||
147 | protected function getFiles() |
||
151 | } |
||
152 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.