Issues (177)

Standalone/StandaloneLaruploadNotCallables.php (8 issues)

1
<?php
2
3
namespace Mostafaznv\Larupload\Concerns\Standalone;
4
5
use Exception;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Http\RedirectResponse;
8
use Mostafaznv\Larupload\Enums\LaruploadMode;
9
use Mostafaznv\Larupload\Enums\LaruploadSecureIdsMethod;
10
use Mostafaznv\Larupload\UploadEntities;
11
use Symfony\Component\HttpFoundation\StreamedResponse;
12
13
trait StandaloneLaruploadNotCallables
14
{
15
    /**
16
     * @throws Exception
17
     * @internal
18
     */
19
    public static function make(string $name, LaruploadMode $mode = LaruploadMode::HEAVY): UploadEntities
20
    {
21
        $self = new self($name, $mode);
0 ignored issues
show
The call to Mostafaznv\Larupload\Con...allables::__construct() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
        $self = /** @scrutinizer ignore-call */ new self($name, $mode);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
22
        $self->internalException();
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Mostafaznv\Larupload\UploadEntities. 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...
23
    }
24
25
    /**
26
     * @internal
27
     */
28
    public function saved(Model $model): Model
0 ignored issues
show
The parameter $model is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

28
    public function saved(/** @scrutinizer ignore-unused */ Model $model): Model

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
    {
30
        $this->internalException();
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Illuminate\Database\Eloquent\Model. 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...
31
    }
32
33
    /**
34
     * @internal
35
     */
36
    public function deleted(): void
37
    {
38
        $this->internalException();
39
    }
40
41
    /**
42
     * @internal
43
     */
44
    public function download(string $style = 'original'): StreamedResponse|RedirectResponse|null
0 ignored issues
show
The parameter $style is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

44
    public function download(/** @scrutinizer ignore-unused */ string $style = 'original'): StreamedResponse|RedirectResponse|null

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
45
    {
46
        $this->internalException();
47
    }
48
49
    /**
50
     * @internal
51
     */
52
    public function setOutput(Model $model): void
0 ignored issues
show
The parameter $model is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

52
    public function setOutput(/** @scrutinizer ignore-unused */ Model $model): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
53
    {
54
        $this->internalException();
55
    }
56
57
    public function secureIdsMethod(LaruploadSecureIdsMethod $method): self
0 ignored issues
show
The parameter $method is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

57
    public function secureIdsMethod(/** @scrutinizer ignore-unused */ LaruploadSecureIdsMethod $method): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
58
    {
59
        $this->internalException();
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Mostafaznv\Larupload\Con...neLaruploadNotCallables. 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...
60
    }
61
62
    private function internalException()
63
    {
64
        throw new Exception(
65
            'This function is flagged as @internal and is not available on the standalone uploader.'
66
        );
67
    }
68
}
69