Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpstan error because #17

Open
hassifmohd opened this issue May 22, 2020 · 0 comments
Open

phpstan error because #17

hassifmohd opened this issue May 22, 2020 · 0 comments

Comments

@hassifmohd
Copy link

Problem

when i do my code like below

$token = $this->Examples->Tokens->find()->first()
return $token->foreign_data['vendor_email']

then i got errors during phpstan

> phpstan analyse --memory-limit=512M
Note: Using configuration file /var/www/html/phpstan.neon.
 145/145 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ -------------------------------------------
  Line   src/Controller/ExamplesController.php
 ------ -------------------------------------------
  11     Cannot assign offset 'string' to string.
 ------ -------------------------------------------

 [ERROR] Found 1 error

Script phpstan analyse --memory-limit=512M handling the stan event returned with error code 1
Script @stan was called via check

Investigation

foreign_data currently is a string
https://github.com/UseMuffin/Tokenize/blob/master/src/Model/Entity/Token.php#L16

foreign_data should be an array because setColumnType=json
https://github.com/UseMuffin/Tokenize/blob/master/src/Model/Table/TokensTable.php#L118

Proposal

to put the correct properties
also to put other properties such as expired, created and modified

 * @property array $foreign_data
 * @property \Cake\I18n\FrozenTime $expired
 * @property \Cake\I18n\FrozenTime $created
 * @property \Cake\I18n\FrozenTime $modified

some example i would like to use for the expired property is

$token = $this->Examples->Tokens->find()->first()
return $token->expired->isPast()

Others

composer.json

...
"muffin/tokenize": "dev-cake-4.x",
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant