| 1 | <?php |
||
| 13 | class CurlRemoteFilesystem extends Util\RemoteFilesystem |
||
| 14 | { |
||
| 15 | protected $io; |
||
| 16 | protected $config; |
||
| 17 | protected $options; |
||
| 18 | protected $disableTls; |
||
| 19 | |||
| 20 | private $req; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @inheritDoc |
||
| 24 | */ |
||
| 25 | 1 | public function __construct(IO\IOInterface $io, Config $config = null, array $options = array(), $disableTls = false) |
|
| 33 | |||
| 34 | /** |
||
| 35 | * @inheritDoc |
||
| 36 | */ |
||
| 37 | 1 | public function getContents($originUrl, $fileUrl, $progress = true, $options = array()) |
|
| 38 | { |
||
| 39 | 1 | $res = null; |
|
| 40 | try { |
||
| 41 | 1 | $this->req = new FetchRequest($fileUrl, $this->io, $this->config); |
|
|
|
|||
| 42 | 1 | $res = $this->req->fetch(); |
|
| 43 | } catch (\Exception $e) { |
||
| 44 | $this->io->writeError((string)$e); |
||
| 45 | } |
||
| 46 | 1 | if ($res) { |
|
| 47 | return $res; |
||
| 48 | } else { |
||
| 49 | 1 | return parent::getContents($originUrl, $fileUrl, $progress, $options); |
|
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | 1 | public function getLastHeaders() |
|
| 61 | |||
| 62 | 1 | public function __debugInfo() |
|
| 66 | } |
||
| 67 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: