|
1 | 1 | <?php |
2 | 2 |
|
3 | | -use OCP\IRequest; |
| 3 | +declare(strict_types=1); |
4 | 4 |
|
5 | 5 | /** |
6 | 6 | * @copyright Copyright (c) 2016, ownCloud, Inc. |
|
29 | 29 | * along with this program. If not, see <http://www.gnu.org/licenses/> |
30 | 30 | * |
31 | 31 | */ |
32 | | -class OC_EventSource implements \OCP\IEventSource { |
33 | | - /** |
34 | | - * @var bool |
35 | | - */ |
36 | | - private $fallback; |
37 | 32 |
|
38 | | - /** |
39 | | - * @var int |
40 | | - */ |
41 | | - private $fallBackId = 0; |
| 33 | +namespace OC; |
42 | 34 |
|
43 | | - /** |
44 | | - * @var bool |
45 | | - */ |
46 | | - private $started = false; |
| 35 | +use OCP\IEventSource; |
| 36 | +use OCP\IRequest; |
47 | 37 |
|
48 | | - private IRequest $request; |
| 38 | +class EventSource implements IEventSource { |
| 39 | + private bool $fallback = false; |
| 40 | + private int $fallBackId = 0; |
| 41 | + private bool $started = false; |
49 | 42 |
|
50 | | - public function __construct(IRequest $request) { |
51 | | - $this->request = $request; |
| 43 | + public function __construct( |
| 44 | + private IRequest $request, |
| 45 | + ) { |
52 | 46 | } |
53 | 47 |
|
54 | | - protected function init() { |
| 48 | + protected function init(): void { |
55 | 49 | if ($this->started) { |
56 | 50 | return; |
57 | 51 | } |
58 | 52 | $this->started = true; |
59 | 53 |
|
60 | 54 | // prevent php output buffering, caching and nginx buffering |
61 | | - OC_Util::obEnd(); |
| 55 | + \OC_Util::obEnd(); |
62 | 56 | header('Cache-Control: no-cache'); |
63 | 57 | header('X-Accel-Buffering: no'); |
64 | 58 | $this->fallback = isset($_GET['fallback']) and $_GET['fallback'] == 'true'; |
@@ -104,7 +98,7 @@ protected function init() { |
104 | 98 | */ |
105 | 99 | public function send($type, $data = null) { |
106 | 100 | if ($data and !preg_match('/^[A-Za-z0-9_]+$/', $type)) { |
107 | | - throw new BadMethodCallException('Type needs to be alphanumeric ('. $type .')'); |
| 101 | + throw new \BadMethodCallException('Type needs to be alphanumeric ('. $type .')'); |
108 | 102 | } |
109 | 103 | $this->init(); |
110 | 104 | if (is_null($data)) { |
|
0 commit comments