mostafaznv /
larupload
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace Mostafaznv\Larupload\Concerns\Standalone; |
||||||
| 4 | |||||||
| 5 | use Illuminate\Http\UploadedFile; |
||||||
| 6 | |||||||
| 7 | trait StandaloneLaruploadCover |
||||||
| 8 | { |
||||||
| 9 | /** |
||||||
| 10 | * @internal |
||||||
| 11 | */ |
||||||
| 12 | public function updateCover(UploadedFile $file): bool |
||||||
| 13 | { |
||||||
| 14 | if ($this->internalFunctionIsCallable) { |
||||||
| 15 | return parent::updateCover($file); |
||||||
| 16 | } |
||||||
| 17 | |||||||
| 18 | $this->internalException(); |
||||||
|
0 ignored issues
–
show
It seems like
internalException() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 19 | } |
||||||
| 20 | |||||||
| 21 | public function changeCover(UploadedFile $file): ?object |
||||||
| 22 | { |
||||||
| 23 | if ($this->metaExists()) { |
||||||
|
0 ignored issues
–
show
It seems like
metaExists() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 24 | $this->internalFunctionIsCallable = true; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 25 | $res = $this->updateCover($file); |
||||||
| 26 | |||||||
| 27 | if ($res) { |
||||||
| 28 | $this->setCover($this->id); |
||||||
|
0 ignored issues
–
show
It seems like
setCover() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 29 | $this->updateMeta(); |
||||||
|
0 ignored issues
–
show
It seems like
updateMeta() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 30 | |||||||
| 31 | return $this->urls(); |
||||||
|
0 ignored issues
–
show
It seems like
urls() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 32 | } |
||||||
| 33 | } |
||||||
| 34 | |||||||
| 35 | return null; |
||||||
| 36 | } |
||||||
| 37 | |||||||
| 38 | public function deleteCover(): ?object |
||||||
| 39 | { |
||||||
| 40 | if ($this->metaExists()) { |
||||||
| 41 | $this->internalFunctionIsCallable = true; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 42 | $res = $this->detachCover(); |
||||||
| 43 | |||||||
| 44 | if ($res) { |
||||||
| 45 | $this->setCover($this->id); |
||||||
| 46 | $this->updateMeta(); |
||||||
| 47 | |||||||
| 48 | return $this->urls(); |
||||||
| 49 | } |
||||||
| 50 | } |
||||||
| 51 | |||||||
| 52 | return null; |
||||||
| 53 | } |
||||||
| 54 | |||||||
| 55 | /** |
||||||
| 56 | * @internal |
||||||
| 57 | */ |
||||||
| 58 | public function detachCover(): bool |
||||||
| 59 | { |
||||||
| 60 | if ($this->internalFunctionIsCallable) { |
||||||
| 61 | return parent::detachCover(); |
||||||
| 62 | } |
||||||
| 63 | |||||||
| 64 | $this->internalException(); |
||||||
|
0 ignored issues
–
show
In this branch, the function will implicitly return
null which is incompatible with the type-hinted return boolean. Consider adding a return statement or allowing null as return value.
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: interface ReturnsInt {
public function returnsIntHinted(): int;
}
class MyClass implements ReturnsInt {
public function returnsIntHinted(): int
{
if (foo()) {
return 123;
}
// here: null is implicitly returned
}
}
Loading history...
|
|||||||
| 65 | } |
||||||
| 66 | } |
||||||
| 67 |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: