These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the overtrue/wechat. |
||
5 | * |
||
6 | * (c) overtrue <[email protected]> |
||
7 | * |
||
8 | * This source file is subject to the MIT license that is bundled |
||
9 | * with this source code in the file LICENSE. |
||
10 | */ |
||
11 | |||
12 | namespace EasyWeChat\OpenPlatform\Auth; |
||
13 | |||
14 | use EasyWeChat\Kernel\Exceptions\RuntimeException; |
||
15 | use EasyWeChat\Kernel\Traits\InteractsWithCache; |
||
16 | use EasyWeChat\OpenPlatform\Application; |
||
17 | |||
18 | /** |
||
19 | * Class VerifyTicket. |
||
20 | * |
||
21 | * @author mingyoung <[email protected]> |
||
22 | */ |
||
23 | class VerifyTicket |
||
24 | { |
||
25 | use InteractsWithCache; |
||
26 | |||
27 | /** |
||
28 | * @var \EasyWeChat\OpenPlatform\Application |
||
29 | */ |
||
30 | protected $app; |
||
31 | |||
32 | /** |
||
33 | * Constructor. |
||
34 | * |
||
35 | * @param \EasyWeChat\OpenPlatform\Application $$app |
||
0 ignored issues
–
show
|
|||
36 | */ |
||
37 | public function __construct(Application $app) |
||
38 | { |
||
39 | $this->app = $app; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Put the credential `component_verify_ticket` in cache. |
||
44 | * |
||
45 | * @param string $ticket |
||
46 | * |
||
47 | * @return $this |
||
48 | */ |
||
49 | public function setTicket(string $ticket) |
||
50 | { |
||
51 | $this->getCache()->set($this->getCacheKey(), $ticket, 3600); |
||
52 | |||
53 | return $this; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Get the credential `component_verify_ticket` from cache. |
||
58 | * |
||
59 | * @return string |
||
60 | * |
||
61 | * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException |
||
62 | */ |
||
63 | public function getTicket(): string |
||
64 | { |
||
65 | if ($cached = $this->getCache()->get($this->getCacheKey())) { |
||
66 | return $cached; |
||
67 | } |
||
68 | |||
69 | throw new RuntimeException('Credential "component_verify_ticket" does not exist in cache.'); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Get cache key. |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | protected function getCacheKey(): string |
||
78 | { |
||
79 | return 'easywechat.open_platform.verify_ticket.'.$this->app['config']['app_id']; |
||
80 | } |
||
81 | } |
||
82 |
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.