1 | <?php |
||
12 | class Stencil_Upgrader { |
||
13 | |||
14 | /** |
||
15 | * Check for upgrades once a day. |
||
16 | */ |
||
17 | const DAY_TIMESTAMP = 86400; // 60*60*24 = one da |
||
18 | |||
19 | /** |
||
20 | * Packages that can be upgraded |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $upgrades = array(); |
||
25 | |||
26 | /** |
||
27 | * Installables instance. |
||
28 | * |
||
29 | * @var Stencil_Installables |
||
30 | */ |
||
31 | protected $installables; |
||
32 | |||
33 | /** |
||
34 | * * Transient name to use for periodical upgrade checks. |
||
35 | */ |
||
36 | const TRANSIENT_NAME = 'stencil_upgrader_upgrader:last_check_timestamp'; |
||
37 | |||
38 | /** |
||
39 | * Stencil_Upgrader constructor. |
||
40 | */ |
||
41 | public function __construct() { |
||
61 | |||
62 | /** |
||
63 | * Get transient name to use. |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | protected function get_option_name() { |
||
70 | |||
71 | /** |
||
72 | * Get the periodically check timeout. |
||
73 | * |
||
74 | * @return int |
||
75 | */ |
||
76 | protected function get_upgrade_timeout() { |
||
81 | |||
82 | /** |
||
83 | * Get available upgrades. |
||
84 | * |
||
85 | * @return array |
||
86 | */ |
||
87 | public function get_upgrades() { |
||
90 | |||
91 | /** |
||
92 | * Check for all upgrades |
||
93 | * |
||
94 | * @return bool |
||
95 | */ |
||
96 | public function check_for_upgrades() { |
||
110 | |||
111 | /** |
||
112 | * Upgrade packages |
||
113 | */ |
||
114 | public function upgrade_all() { |
||
123 | |||
124 | /** |
||
125 | * Save upgrade information to the database. |
||
126 | */ |
||
127 | private function save_upgrade_information() { |
||
137 | } |
||
138 |
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.