1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of Ratchet. |
5
|
|
|
* |
6
|
|
|
** (c) 2016 Cees-Jan Kiewiet |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
namespace WyriHaximus\Ratchet\Event; |
12
|
|
|
|
13
|
|
|
use Cake\Event\Event; |
14
|
|
|
use Cake\Event\EventManager; |
15
|
|
|
use React\EventLoop\LoopInterface; |
16
|
|
|
use React\Promise\Deferred; |
17
|
|
|
use React\Promise\PromiseInterface; |
18
|
|
|
use Thruway\Message\ActionMessageInterface; |
19
|
|
|
use Thruway\Session; |
20
|
|
|
|
21
|
|
|
class AuthorizeEvent extends Event |
22
|
|
|
{ |
23
|
|
|
const EVENT = 'WyriHaximus.Ratchet.%s.authorize'; |
24
|
|
|
|
25
|
|
|
public static function realmEvent($realm) |
26
|
|
|
{ |
27
|
|
|
return sprintf(self::EVENT, $realm); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var Deferred |
32
|
|
|
*/ |
33
|
|
|
private $deferred; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param LoopInterface $loop |
|
|
|
|
37
|
|
|
* @return static |
38
|
|
|
*/ |
39
|
|
|
public static function create($realm, Session $session, ActionMessageInterface $actionMsg) |
40
|
|
|
{ |
41
|
|
|
return new static(self::realmEvent($realm), $actionMsg, [ |
42
|
|
|
'realm' => $realm, |
43
|
|
|
'session' => $session, |
44
|
|
|
'actionMessage' => $actionMsg, |
45
|
|
|
]); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function __construct($name, $subject = null, $data = null) |
49
|
|
|
{ |
50
|
|
|
parent::__construct($name, $subject, $data); |
51
|
|
|
$this->deferred = new Deferred(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return Session |
56
|
|
|
*/ |
57
|
|
|
public function getRealm() |
58
|
|
|
{ |
59
|
|
|
return $this->getData()['realm']; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return Session |
64
|
|
|
*/ |
65
|
|
|
public function getSession() |
66
|
|
|
{ |
67
|
|
|
return $this->getData()['session']; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return ActionMessageInterface |
72
|
|
|
*/ |
73
|
|
|
public function getActionMessage() |
74
|
|
|
{ |
75
|
|
|
return $this->getData()['actionMessage']; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return PromiseInterface |
80
|
|
|
*/ |
81
|
|
|
public function promise() |
82
|
|
|
{ |
83
|
|
|
return $this->deferred->promise(); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function reject() |
87
|
|
|
{ |
88
|
|
|
$this->deferred->reject(); |
89
|
|
|
} |
90
|
|
|
} |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.