These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Halapi\Representation; |
||
4 | |||
5 | /** |
||
6 | * A paginated collection representation. |
||
7 | * |
||
8 | * Class PaginatedRepresentation |
||
9 | */ |
||
10 | class PaginatedRepresentation |
||
11 | { |
||
12 | /** |
||
13 | * Filters const used to provide easy documentation integration. |
||
14 | */ |
||
15 | const FILTERS = [ |
||
16 | ['name' => 'page', 'dataType' => 'integer', 'default' => 1], |
||
17 | ['name' => 'limit', 'dataType' => 'integer', 'default' => 20], |
||
18 | // We'll need some more work to re-implement that as OpenApi has currently no support for |
||
19 | // query params of this kind. ( ?param[key]=value ) |
||
20 | //['name' => 'sorting', 'dataType' => 'array'], |
||
21 | //['name' => 'filtervalue', 'dataType' => 'array', 'pattern' => '[field]=(asc|desc)'], |
||
22 | //['name' => 'filteroperator', 'dataType' => 'array', 'pattern' => '[field]=(<|>|<=|>=|=|!=)'], |
||
23 | ]; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | public $page; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | public $limit; |
||
34 | |||
35 | /** |
||
36 | * @var object |
||
37 | */ |
||
38 | public $_links; |
||
39 | |||
40 | /** |
||
41 | * @var array |
||
42 | */ |
||
43 | public $_embedded; |
||
44 | |||
45 | /** |
||
46 | * PaginatedRepresentation constructor. |
||
47 | * |
||
48 | * @param int $page |
||
49 | * @param int $limit |
||
50 | * @param array $links |
||
51 | * @param array $embedded |
||
52 | */ |
||
53 | public function __construct($page, $limit, $links, $embedded) |
||
54 | { |
||
55 | $this->page = $page; |
||
0 ignored issues
–
show
|
|||
56 | $this->limit = $limit; |
||
0 ignored issues
–
show
The property
$limit was declared of type string , but $limit is of type integer . Maybe add a type cast?
This check looks for assignments to scalar types that may be of the wrong type. To ensure the code behaves as expected, it may be a good idea to add an explicit type cast. $answer = 42;
$correct = false;
$correct = (bool) $answer;
Loading history...
|
|||
57 | $this->_links = $links; |
||
0 ignored issues
–
show
It seems like
$links of type array is incompatible with the declared type object of property $_links .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
Loading history...
|
|||
58 | $this->_embedded = $embedded; |
||
59 | } |
||
60 | } |
||
61 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.