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 Spatie\MediaLibrary; |
||
4 | |||
5 | use Spatie\MediaLibrary\Models\Media; |
||
6 | use Illuminate\Database\Eloquent\SoftDeletes; |
||
7 | use Spatie\MediaLibrary\Filesystem\Filesystem; |
||
8 | |||
9 | class MediaObserver |
||
10 | { |
||
11 | public function creating(Media $media) |
||
12 | { |
||
13 | $media->setHighestOrderNumber(); |
||
14 | } |
||
15 | |||
16 | public function updating(Media $media) |
||
17 | { |
||
18 | if ($media->file_name !== $media->getOriginal('file_name')) { |
||
19 | app(Filesystem::class)->syncFileNames($media); |
||
20 | } |
||
21 | } |
||
22 | |||
23 | public function updated(Media $media) |
||
24 | { |
||
25 | if (is_null($media->getOriginal('model_id'))) { |
||
26 | return; |
||
27 | } |
||
28 | |||
29 | if ($media->manipulations !== json_decode($media->getOriginal('manipulations'), true)) { |
||
0 ignored issues
–
show
|
|||
30 | $eventDispatcher = Media::getEventDispatcher(); |
||
31 | Media::unsetEventDispatcher(); |
||
32 | |||
33 | app(FileManipulator::class)->createDerivedFiles($media); |
||
34 | |||
35 | Media::setEventDispatcher($eventDispatcher); |
||
36 | } |
||
37 | } |
||
38 | |||
39 | public function deleted(Media $media) |
||
40 | { |
||
41 | if (in_array(SoftDeletes::class, class_uses_recursive($media))) { |
||
42 | if (! $media->isForceDeleting()) { |
||
43 | return; |
||
44 | } |
||
45 | } |
||
46 | |||
47 | app(Filesystem::class)->removeAllFiles($media); |
||
48 | } |
||
49 | } |
||
50 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.