1 | <?php |
||
10 | class FormAvatarUpload extends Model |
||
11 | { |
||
12 | /** @var \Symfony\Component\HttpFoundation\File\UploadedFile */ |
||
13 | public $file; |
||
14 | |||
15 | const AVATAR_SIZE = 2097152; // 2mb |
||
16 | const COMPRESS_QUALITY = 90; |
||
17 | |||
18 | /** |
||
19 | * Example of usage magic labels for future form helper usage |
||
20 | */ |
||
21 | public function labels() |
||
27 | |||
28 | /** |
||
29 | * Example of usage magic rules for future usage in condition $model->validate() |
||
30 | */ |
||
31 | public function rules() |
||
39 | |||
40 | public function sources() |
||
41 | { |
||
42 | return [ |
||
43 | 'file' => 'file' |
||
44 | ]; |
||
45 | } |
||
46 | |||
47 | public function copyFile(iUser $user) |
||
64 | |||
65 | /** |
||
66 | * @param \Symfony\Component\HttpFoundation\File\UploadedFile $original |
||
67 | * @param int $user_id |
||
68 | * @param string $size |
||
69 | * @throws \Exception |
||
70 | * @return null |
||
71 | */ |
||
72 | protected function resizeAndSave($original, $user_id, $size = 'small') |
||
93 | } |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: