1 | <?php |
||
11 | class Resolver |
||
12 | { |
||
13 | /** |
||
14 | * The request object. |
||
15 | * |
||
16 | * @var \Psr\Http\Message\ServerRequestInterface |
||
17 | */ |
||
18 | protected $request; |
||
19 | |||
20 | /** |
||
21 | * Configuration array. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $config; |
||
26 | |||
27 | /** |
||
28 | * The page api object. |
||
29 | * |
||
30 | * @var \Vssl\Render\PageApi |
||
31 | */ |
||
32 | protected $api; |
||
33 | |||
34 | /** |
||
35 | * Initialize a new Resolver |
||
36 | */ |
||
37 | 10 | public function __construct(ServerRequestInterface $request, $config = false) |
|
38 | { |
||
39 | 10 | $this->request = $request; |
|
40 | 10 | $this->config = is_array($config) ? static::config($config) : static::config(); |
|
|
|||
41 | 10 | if (!$this->config['cache'] instanceof CacheAdapterInterface) { |
|
42 | 1 | throw new ResolverException('Cache must implement \Journey\Cache\CacheAdapterInterface.'); |
|
43 | } |
||
44 | 10 | $this->api = new PageApi($request, $this->config); |
|
45 | 10 | } |
|
46 | |||
47 | /** |
||
48 | * Get a modified request message. |
||
49 | * |
||
50 | * @return \Psr\Http\Message\ServerRequestInterface |
||
51 | */ |
||
52 | 4 | public function getRequest() |
|
56 | |||
57 | /** |
||
58 | * Get an instance of the PageApi class. |
||
59 | * |
||
60 | * @return \Vssl\Render\PageApi |
||
61 | */ |
||
62 | 4 | public function getPageApi() |
|
66 | |||
67 | /** |
||
68 | * Resolve the current page from WebStories. Returns a render able page or |
||
69 | * false. |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | 4 | public function resolve() |
|
93 | |||
94 | /** |
||
95 | * Decode the body of a particular request. |
||
96 | * |
||
97 | * @return mixed |
||
98 | */ |
||
99 | 4 | public function decodePage(ResponseInterface $response) |
|
100 | { |
||
101 | 4 | $body = (string) $response->getBody(); |
|
102 | 4 | if ($response->getHeaderLine('Content-Type') == "application/json") { |
|
103 | 3 | $page = json_decode($body, true); |
|
104 | 3 | return !empty($page['exists']) ? $page['page'] : false; |
|
105 | } |
||
106 | 1 | return false; |
|
107 | } |
||
108 | |||
109 | /** |
||
110 | * Configure the resolver. |
||
111 | * |
||
112 | * @return void |
||
113 | */ |
||
114 | 23 | public static function config($assign = false) |
|
133 | } |
||
134 |
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: