1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @copyright Bluz PHP Team |
||
5 | * @link https://github.com/bluzphp/skeleton |
||
6 | */ |
||
7 | |||
8 | declare(strict_types=1); |
||
9 | |||
10 | namespace Application\UsersActions; |
||
11 | |||
12 | use Bluz\Proxy\Db; |
||
0 ignored issues
–
show
|
|||
13 | |||
14 | /** |
||
15 | * Table of User Actions |
||
16 | * |
||
17 | * @package Application\Users |
||
18 | * |
||
19 | * @method static Row|null findRow($primaryKey) |
||
20 | * @see \Bluz\Db\Table::findRow() |
||
21 | * @method static Row|null findRowWhere($whereList) |
||
22 | * @see \Bluz\Db\Table::findRowWhere() |
||
23 | */ |
||
24 | class Table extends \Bluz\Db\Table |
||
0 ignored issues
–
show
The type
Bluz\Db\Table was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
25 | { |
||
26 | public const ACTION_ACTIVATION = 'activation'; |
||
27 | public const ACTION_CHANGE_EMAIL = 'email'; |
||
28 | public const ACTION_RECOVERY = 'recovery'; |
||
29 | public const ACTION_REMOVE = 'remove'; |
||
30 | |||
31 | /** |
||
32 | * Table |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $name = 'users_actions'; |
||
37 | |||
38 | /** |
||
39 | * Primary key(s) |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $primary = ['userId', 'code']; |
||
44 | |||
45 | /** |
||
46 | * generate action with token |
||
47 | * |
||
48 | * @param int $userId |
||
49 | * @param string $action |
||
50 | * @param int $expired in days |
||
51 | * @param array $params |
||
52 | * |
||
53 | * @return Row |
||
54 | * @throws \Bluz\Db\Exception\DbException |
||
55 | * @throws \Bluz\Db\Exception\InvalidPrimaryKeyException |
||
56 | * @throws \Bluz\Db\Exception\TableNotFoundException |
||
57 | */ |
||
58 | public function generate($userId, $action, $expired = 5, $params = []): Row |
||
59 | { |
||
60 | // remove previously generated tokens |
||
61 | Db::delete($this->name) |
||
62 | ->where('userId = ?', $userId) |
||
63 | ->andWhere('action = ?', $action) |
||
64 | ->execute(); |
||
65 | |||
66 | // create new row |
||
67 | $actionRow = new Row(); |
||
68 | $actionRow->userId = $userId; |
||
69 | $actionRow->action = $action; |
||
70 | $actionRow->code = bin2hex(random_bytes(32)); |
||
71 | $actionRow->expired = gmdate('Y-m-d H:i:s', strtotime("+$expired day")); |
||
72 | $actionRow->params = $params; |
||
0 ignored issues
–
show
It seems like
$params of type array is incompatible with the declared type string of property $params .
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.. ![]() |
|||
73 | $actionRow->save(); |
||
74 | |||
75 | return $actionRow; |
||
76 | } |
||
77 | } |
||
78 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths