| @@ -31,12 +31,14 @@ | ||
| 31 | 31 | |
| 32 | 32 | $fs = new Files(); | 
| 33 | 33 | |
| 34 | -        if ($fs->isDirectory(__DIR__ . '/../app/migrations')) { | |
| 34 | + if ($fs->isDirectory(__DIR__ . '/../app/migrations')) | |
| 35 | +        { | |
| 35 | 36 | $fs->deleteDirectory(__DIR__ . '/../app/migrations'); | 
| 36 | 37 | } | 
| 37 | 38 | |
| 38 | 39 |          $runtime = $this->app->get(DirectoriesInterface::class)->get('runtime'); | 
| 39 | -        if ($fs->isDirectory($runtime)) { | |
| 40 | + if ($fs->isDirectory($runtime)) | |
| 41 | +        { | |
| 40 | 42 | $fs->deleteDirectory($runtime); | 
| 41 | 43 | } | 
| 42 | 44 | } | 
| @@ -20,9 +20,12 @@ | ||
| 20 | 20 |      { | 
| 21 | 21 | $app = $this->makeApp(); | 
| 22 | 22 | |
| 23 | -        try { | |
| 23 | + try | |
| 24 | +        { | |
| 24 | 25 |              throw new \Error('test error'); | 
| 25 | -        } catch (\Error $e) { | |
| 26 | + } | |
| 27 | + catch (\Error $e) | |
| 28 | +        { | |
| 26 | 29 | /** @var SnapshotInterface $s */ | 
| 27 | 30 | $s = $app->get(SnapshotterInterface::class)->register($e); | 
| 28 | 31 | } | 
| @@ -20,7 +20,8 @@ | ||
| 20 | 20 | |
| 21 | 21 | public function tearDown(): void | 
| 22 | 22 |      { | 
| 23 | -        if (file_exists(self::TEST_FILE)) { | |
| 23 | + if (file_exists(self::TEST_FILE)) | |
| 24 | +        { | |
| 24 | 25 | unlink(self::TEST_FILE); | 
| 25 | 26 | } | 
| 26 | 27 | |
| @@ -18,7 +18,8 @@ discard block | ||
| 18 | 18 |  { | 
| 19 | 19 | public function testSetSid(): void | 
| 20 | 20 |      { | 
| 21 | -        $this->http->setHandler(function () { | |
| 21 | + $this->http->setHandler(function () | |
| 22 | +        { | |
| 22 | 23 |              return ++$this->session()->getSection('cli')->value; | 
| 23 | 24 | }); | 
| 24 | 25 | |
| @@ -32,7 +33,8 @@ discard block | ||
| 32 | 33 | |
| 33 | 34 | public function testSessionResume(): void | 
| 34 | 35 |      { | 
| 35 | -        $this->http->setHandler(function () { | |
| 36 | + $this->http->setHandler(function () | |
| 37 | +        { | |
| 36 | 38 |              return ++$this->session()->getSection('cli')->value; | 
| 37 | 39 | }); | 
| 38 | 40 | |
| @@ -56,7 +58,8 @@ discard block | ||
| 56 | 58 | |
| 57 | 59 | public function testSessionRegenerateId(): void | 
| 58 | 60 |      { | 
| 59 | -        $this->http->setHandler(function () { | |
| 61 | + $this->http->setHandler(function () | |
| 62 | +        { | |
| 60 | 63 |              return ++$this->session()->getSection('cli')->value; | 
| 61 | 64 | }); | 
| 62 | 65 | |
| @@ -73,7 +76,8 @@ discard block | ||
| 73 | 76 | $this->assertSame(200, $result->getStatusCode()); | 
| 74 | 77 |          $this->assertSame('2', $result->getBody()->__toString()); | 
| 75 | 78 | |
| 76 | -        $this->http->setHandler(function () { | |
| 79 | + $this->http->setHandler(function () | |
| 80 | +        { | |
| 77 | 81 | $this->session()->regenerateID(false); | 
| 78 | 82 | |
| 79 | 83 |              return ++$this->session()->getSection('cli')->value; | 
| @@ -92,7 +96,8 @@ discard block | ||
| 92 | 96 | |
| 93 | 97 | public function testDestroySession(): void | 
| 94 | 98 |      { | 
| 95 | -        $this->http->setHandler(function () { | |
| 99 | + $this->http->setHandler(function () | |
| 100 | +        { | |
| 96 | 101 |              return ++$this->session()->getSection('cli')->value; | 
| 97 | 102 | }); | 
| 98 | 103 | |
| @@ -105,7 +110,8 @@ discard block | ||
| 105 | 110 | ]); | 
| 106 | 111 | $this->assertSame(200, $result->getStatusCode()); | 
| 107 | 112 |          $this->assertSame('2', $result->getBody()->__toString()); | 
| 108 | -        $this->http->setHandler(function () { | |
| 113 | + $this->http->setHandler(function () | |
| 114 | +        { | |
| 109 | 115 | $this->session()->destroy(); | 
| 110 | 116 | $this->assertFalse($this->session()->isStarted()); | 
| 111 | 117 | |
| @@ -25,7 +25,8 @@ | ||
| 25 | 25 | |
| 26 | 26 | public function setUp(): void | 
| 27 | 27 |      { | 
| 28 | -        $this->bufferEmitter = new class() implements EmitterInterface { | |
| 28 | + $this->bufferEmitter = new class() implements EmitterInterface | |
| 29 | +        { | |
| 29 | 30 | public $response; | 
| 30 | 31 | |
| 31 | 32 | public function emit(ResponseInterface $response): bool | 
| @@ -26,10 +26,12 @@ discard block | ||
| 26 | 26 | $this->auth = $auth; | 
| 27 | 27 | } | 
| 28 | 28 | |
| 29 | - public function do(GuardInterface $guard) | |
| 29 | +    public function do{ | |
| 30 | + (GuardInterface $guard) | |
| 30 | 31 |      { | 
| 31 | 32 |          if (!$guard->allows('do')) { | 
| 32 | 33 |              throw new ControllerException("Unauthorized permission 'do'", ControllerException::FORBIDDEN); | 
| 34 | + } | |
| 33 | 35 | } | 
| 34 | 36 | |
| 35 | 37 | return 'ok'; | 
| @@ -37,7 +39,8 @@ discard block | ||
| 37 | 39 | |
| 38 | 40 | public function token(AuthContextInterface $authContext) | 
| 39 | 41 |      { | 
| 40 | -        if ($authContext->getToken() !== null) { | |
| 42 | + if ($authContext->getToken() !== null) | |
| 43 | +        { | |
| 41 | 44 | return $authContext->getToken()->getID(); | 
| 42 | 45 | } | 
| 43 | 46 | |
| @@ -55,7 +58,8 @@ discard block | ||
| 55 | 58 | |
| 56 | 59 | public function token2() | 
| 57 | 60 |      { | 
| 58 | -        if ($this->auth->getToken() !== null) { | |
| 61 | + if ($this->auth->getToken() !== null) | |
| 62 | +        { | |
| 59 | 63 | return $this->auth->getToken()->getID(); | 
| 60 | 64 | } | 
| 61 | 65 | |
| @@ -40,8 +40,10 @@ | ||
| 40 | 40 |       * @Guarded("do") | 
| 41 | 41 | * @return string | 
| 42 | 42 | */ | 
| 43 | - public function do() | |
| 43 | +    public function do{ | |
| 44 | + () | |
| 44 | 45 |      { | 
| 45 | 46 | return 'ok'; | 
| 46 | 47 | } | 
| 48 | + } | |
| 47 | 49 | } | 
| @@ -38,7 +38,8 @@ discard block | ||
| 38 | 38 | |
| 39 | 39 | public function testAllowServerAccess(): void | 
| 40 | 40 |      { | 
| 41 | -        $this->init(static function () { | |
| 41 | + $this->init(static function () | |
| 42 | +        { | |
| 42 | 43 | return true; | 
| 43 | 44 | }); | 
| 44 | 45 | |
| @@ -50,7 +51,8 @@ discard block | ||
| 50 | 51 | |
| 51 | 52 | public function testDenyServerAccess(): void | 
| 52 | 53 |      { | 
| 53 | -        $this->init(static function () { | |
| 54 | + $this->init(static function () | |
| 55 | +        { | |
| 54 | 56 | return false; | 
| 55 | 57 | }); | 
| 56 | 58 | |
| @@ -62,7 +64,8 @@ discard block | ||
| 62 | 64 | |
| 63 | 65 | public function testServerAccessWithDependency(): void | 
| 64 | 66 |      { | 
| 65 | -        $this->init(static function (ServerRequestInterface $request) { | |
| 67 | + $this->init(static function (ServerRequestInterface $request) | |
| 68 | +        { | |
| 66 | 69 | return $request instanceof ServerRequestInterface; | 
| 67 | 70 | }); | 
| 68 | 71 | |
| @@ -124,7 +127,8 @@ discard block | ||
| 124 | 127 | |
| 125 | 128 | public function testTopicAccessOK(): void | 
| 126 | 129 |      { | 
| 127 | -        $this->init(null, function () { | |
| 130 | + $this->init(null, function () | |
| 131 | +        { | |
| 128 | 132 | return true; | 
| 129 | 133 | }); | 
| 130 | 134 | |
| @@ -136,7 +140,8 @@ discard block | ||
| 136 | 140 | |
| 137 | 141 | public function testTopicWildcardAccessFail(): void | 
| 138 | 142 |      { | 
| 139 | -        $this->init(null, function () { | |
| 143 | + $this->init(null, function () | |
| 144 | +        { | |
| 140 | 145 | return true; | 
| 141 | 146 | }); | 
| 142 | 147 | |
| @@ -151,7 +156,8 @@ discard block | ||
| 151 | 156 | $this->init( | 
| 152 | 157 | null, | 
| 153 | 158 | null, | 
| 154 | -            function () { | |
| 159 | + function () | |
| 160 | +            { | |
| 155 | 161 | return true; | 
| 156 | 162 | } | 
| 157 | 163 | ); | 
| @@ -167,7 +173,8 @@ discard block | ||
| 167 | 173 | $this->init( | 
| 168 | 174 | null, | 
| 169 | 175 | null, | 
| 170 | -            function ($id) { | |
| 176 | + function ($id) | |
| 177 | +            { | |
| 171 | 178 | return $id === '1'; | 
| 172 | 179 | } | 
| 173 | 180 | ); | 
| @@ -183,7 +190,8 @@ discard block | ||
| 183 | 190 | $this->init( | 
| 184 | 191 | null, | 
| 185 | 192 | null, | 
| 186 | -            function ($id) { | |
| 193 | + function ($id) | |
| 194 | +            { | |
| 187 | 195 | return $id === '1'; | 
| 188 | 196 | } | 
| 189 | 197 | ); | 
| @@ -204,7 +212,8 @@ discard block | ||
| 204 | 212 | 'CYCLE_AUTH' => true, | 
| 205 | 213 | 'RR_BROADCAST_PATH' => '/ws/', | 
| 206 | 214 | 'WS_SERVER_CALLBACK' => null, | 
| 207 | -            'WS_TOPIC_CALLBACK'          => function (AuthContextInterface $authContext) { | |
| 215 | + 'WS_TOPIC_CALLBACK' => function (AuthContextInterface $authContext) | |
| 216 | +            { | |
| 208 | 217 | return $authContext->getToken() !== null; | 
| 209 | 218 | }, | 
| 210 | 219 | 'WS_TOPIC_WILDCARD_CALLBACK' => null, | 
| @@ -45,7 +45,8 @@ discard block | ||
| 45 | 45 | array $headers = [] | 
| 46 | 46 |      ): ResponseInterface { | 
| 47 | 47 | $r = $this->request($uri, 'GET', [], $headers, []); | 
| 48 | -        foreach ($attributes as $k => $v) { | |
| 48 | + foreach ($attributes as $k => $v) | |
| 49 | +        { | |
| 49 | 50 | $r = $r->withAttribute($k, $v); | 
| 50 | 51 | } | 
| 51 | 52 | |
| @@ -86,7 +87,8 @@ discard block | ||
| 86 | 87 | protected function fetchCookies(array $header) | 
| 87 | 88 |      { | 
| 88 | 89 | $result = []; | 
| 89 | -        foreach ($header as $line) { | |
| 90 | + foreach ($header as $line) | |
| 91 | +        { | |
| 90 | 92 |              $cookie = explode('=', $line); | 
| 91 | 93 | $result[$cookie[0]] = rawurldecode(substr($cookie[1], 0, strpos($cookie[1], ';'))); | 
| 92 | 94 | } |