Issues (372)

src/Libc/Fuse/FuseDirFill.php (2 issues)

1
<?php
2
3
/**
4
 * This file is part of the sj-i/php-fuse package.
5
 *
6
 * (c) sji <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Fuse\Libc\Fuse;
15
16
use FFI\CData;
17
use TypedCData\TypedCDataInterface;
0 ignored issues
show
The type TypedCData\TypedCDataInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
19
/**
20
 * typedef int (*fuse_dirfil_t) (fuse_dirh_t h, const char *name, int type, ino_t ino);
21
 */
22
final class FuseDirFill implements TypedCDataInterface
23
{
24
    /** @var \Fuse\FuseDirFillCData */
25
    private CData $cdata;
26
27
    public function __invoke(FuseDirHandle $dirhandle, string $name, int $type, int $ino): int
28
    {
29
        /** @var int */
30
        return ($this->cdata)($dirhandle->toCData(null), $name, $type, $ino);
31
    }
32
33
    public static function getCTypeName(): string
34
    {
35
        return 'fuse_dirfil_t';
36
    }
37
38
    /** @param \Fuse\FuseDirFillCData $cdata */
39
    public function __construct(CData $cdata)
40
    {
41
        $this->cdata = $cdata;
0 ignored issues
show
Documentation Bug introduced by
$cdata is of type FFI\CData, but the property $cdata was declared to be of type Fuse\FuseDirFillCData. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
42
    }
43
44
    /** @return self */
45
    public static function fromCData(CData $cdata): self
46
    {
47
        /** @var \Fuse\FuseDirFillCData $cdata */
48
        return new self($cdata);
49
    }
50
51
    public function toCData(CData $cdata): CData
52
    {
53
        return $cdata;
54
    }
55
56
    public static function newCData(): CData
57
    {
58
        throw new \LogicException();
59
    }
60
}
61