1 | <?php |
||
21 | class ZendSentry |
||
22 | { |
||
23 | /** |
||
24 | * @var string $nonce |
||
25 | */ |
||
26 | private static $nonce; |
||
27 | /** |
||
28 | * @var RavenClient $ravenClient |
||
29 | */ |
||
30 | private $ravenClient; |
||
31 | /** |
||
32 | * @var RavenErrorHandler $ravenErrorHandler |
||
33 | */ |
||
34 | private $ravenErrorHandler; |
||
35 | |||
36 | /** |
||
37 | * @param RavenClient $ravenClient |
||
38 | * @param RavenErrorHandler $ravenErrorHandler |
||
39 | */ |
||
40 | public function __construct(RavenClient $ravenClient, RavenErrorHandler $ravenErrorHandler = null) |
||
41 | { |
||
42 | $this->ravenClient = $ravenClient; |
||
43 | $this->setOrLoadRavenErrorHandler($ravenErrorHandler); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param null|RavenErrorHandler $ravenErrorHandler |
||
48 | */ |
||
49 | private function setOrLoadRavenErrorHandler($ravenErrorHandler) |
||
50 | { |
||
51 | if ($ravenErrorHandler !== null) { |
||
52 | $this->ravenErrorHandler = $ravenErrorHandler; |
||
53 | } else { |
||
54 | $this->ravenErrorHandler = new RavenErrorHandler($this->ravenClient); |
||
55 | } |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @param string $nonce |
||
60 | */ |
||
61 | public static function setCSPNonce(string $nonce) |
||
62 | { |
||
63 | self::$nonce = $nonce; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @param bool $callExistingHandler |
||
68 | * @param int $errorReporting |
||
69 | * |
||
70 | * @return ZendSentry |
||
71 | */ |
||
72 | public function registerErrorHandler($callExistingHandler = true, $errorReporting = E_ALL): ZendSentry |
||
73 | { |
||
74 | $this->ravenErrorHandler->registerErrorHandler($callExistingHandler, $errorReporting); |
||
|
|||
75 | return $this; |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @param bool $callExistingHandler |
||
80 | * |
||
81 | * @return ZendSentry |
||
82 | */ |
||
83 | public function registerExceptionHandler($callExistingHandler = true): ZendSentry |
||
84 | { |
||
85 | $this->ravenErrorHandler->registerExceptionHandler($callExistingHandler); |
||
86 | return $this; |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @param int $reservedMemorySize |
||
91 | * |
||
92 | * @return ZendSentry |
||
93 | */ |
||
94 | public function registerShutdownFunction($reservedMemorySize = 10): ZendSentry |
||
95 | { |
||
96 | $this->ravenErrorHandler->registerShutdownFunction($reservedMemorySize); |
||
97 | return $this; |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * @return null|string |
||
102 | */ |
||
103 | public function getCSPNonce(): ?string |
||
107 | } |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: