1 | <?php |
||
27 | class SelfUpdateCommandHandler |
||
28 | { |
||
29 | /** |
||
30 | * Handles the "self-update" command. |
||
31 | * |
||
32 | * @param Args $args The console arguments. |
||
33 | * @param IO $io The I/O. |
||
34 | * |
||
35 | * @return int The status code. |
||
36 | */ |
||
37 | public function handle(Args $args, IO $io) |
||
38 | { |
||
39 | $updateStrategy = new PuliStrategy(); |
||
40 | $updateStrategy->setStability($this->getStability($args)); |
||
41 | |||
42 | // false: disable signed releases, otherwise the updater will look for |
||
43 | // a *.pubkey file for the PHAR |
||
44 | $updater = new Updater(null, false); |
||
45 | $updater->setStrategyObject($updateStrategy); |
||
46 | |||
47 | if ($updater->update()) { |
||
48 | $io->writeLine(sprintf( |
||
49 | 'Updated from version %s to version %s.', |
||
50 | $updater->getOldVersion(), |
||
51 | $updater->getNewVersion() |
||
52 | )); |
||
53 | |||
54 | return 0; |
||
55 | } |
||
56 | |||
57 | $io->writeLine(sprintf( |
||
58 | 'Version %s is the latest version. No update required.', |
||
59 | $updater->getOldVersion() |
||
60 | )); |
||
61 | |||
62 | return 0; |
||
63 | } |
||
64 | |||
65 | private function getStability(Args $args) |
||
79 | } |
||
80 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.