{"action":"closed","issue":{"url":"https://api.github.com/repos/yiisoft/yii2-redis/issues/73","repository_url":"https://api.github.com/repos/yiisoft/yii2-redis","labels_url":"https://api.github.com/repos/yiisoft/yii2-redis/issues/73/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2-redis/issues/73/comments","events_url":"https://api.github.com/repos/yiisoft/yii2-redis/issues/73/events","html_url":"https://github.com/yiisoft/yii2-redis/issues/73","id":161874610,"number":73,"title":"Strict attribute types","user":{"login":"yii-bot","id":13490354,"avatar_url":"https://avatars.githubusercontent.com/u/13490354?v=3","gravatar_id":"","url":"https://api.github.com/users/yii-bot","html_url":"https://github.com/yii-bot","followers_url":"https://api.github.com/users/yii-bot/followers","following_url":"https://api.github.com/users/yii-bot/following{/other_user}","gists_url":"https://api.github.com/users/yii-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/yii-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yii-bot/subscriptions","organizations_url":"https://api.github.com/users/yii-bot/orgs","repos_url":"https://api.github.com/users/yii-bot/repos","events_url":"https://api.github.com/users/yii-bot/events{/privacy}","received_events_url":"https://api.github.com/users/yii-bot/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/yiisoft/yii2-redis/milestones/4","html_url":"https://github.com/yiisoft/yii2-redis/milestones/2.0.6","labels_url":"https://api.github.com/repos/yiisoft/yii2-redis/milestones/4/labels","id":1649466,"number":4,"title":"2.0.6","description":"","creator":{"login":"cebe","id":189796,"avatar_url":"https://avatars.githubusercontent.com/u/189796?v=3","gravatar_id":"","url":"https://api.github.com/users/cebe","html_url":"https://github.com/cebe","followers_url":"https://api.github.com/users/cebe/followers","following_url":"https://api.github.com/users/cebe/following{/other_user}","gists_url":"https://api.github.com/users/cebe/gists{/gist_id}","starred_url":"https://api.github.com/users/cebe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cebe/subscriptions","organizations_url":"https://api.github.com/users/cebe/orgs","repos_url":"https://api.github.com/users/cebe/repos","events_url":"https://api.github.com/users/cebe/events{/privacy}","received_events_url":"https://api.github.com/users/cebe/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":5,"state":"open","created_at":"2016-03-17T04:03:17Z","updated_at":"2016-08-05T10:27:06Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-06-23T09:10:27Z","updated_at":"2016-08-05T10:27:06Z","closed_at":"2016-08-05T10:27:06Z","body":"This issue has originally been reported by @NaLLiFFuNT at https://github.com/yiisoft/yii2/issues/11804.\nMoved here by @cebe.\n\n-----\n\n### The problem\r\nI work on api. I use RedisActiveRecord.\r\nI do create request \r\n{\r\n stringValue : '123'\r\n intValue : 20,\r\n boolValue : true\r\n}\r\n\r\nI load AR model & save it.\r\nSo, model have integer validator for intValue & bool Validator for boolValue \r\n\r\nwhen i do get request\r\nI find model by Id from RedisDB & return $model->toArray().\r\nthe ploblem that after loading from DB intValue & boolValue become string '20' & '1'.  \r\n\r\n### Suggestion\r\nMaybe that is not a problem for PHP7. But at this momen i don't have ability to upgrade a php version. I guess, you can face the challenge with other DB & AR.\r\nI'd suggest following solution.\r\nAdd method attributeTypes to BaseActiveRecord which return array in following format\r\n[\r\n 'attributeName1'=> 'int'\r\n 'attributeName2'=> 'bool'\r\n 'attributeName3'=> 'string'\r\n]\r\n\r\nin __set method we have to verify type of value for attribute & bring it, if it's required.\r\n\r\n### Additional info\r\nI saw similar solution at Laravel and i find it very usefull.\r\n\r\n| Q                | A\r\n| ---------------- | ---\r\n| Yii version      | 2.0.5\r\n| PHP version      | 5.6\r\n| Operating system | Ubuntu mate \r\n"}}
{"actor":{"display_login":"klimov-paul"}}