CDataArray   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 53
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetUnset() 0 2 1
A offsetExists() 0 2 1
A offsetSet() 0 2 1
A offsetGet() 0 2 1
1
<?php
2
3
/**
4
 * This file is part of the sj-i/typed-cdata 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 FFI;
15
16
class CData
17
{
18
19
}
20
21
/**
22
 * @implements \ArrayAccess<int, CData>
23
 */
24
class CDataArray extends CData implements \ArrayAccess
25
{
26
27
    /**
28
     * Whether a offset exists
29
     * @link https://php.net/manual/en/arrayaccess.offsetexists.php
30
     * @param mixed $offset <p>
31
     * An offset to check for.
32
     * </p>
33
     * @return bool true on success or false on failure.
34
     * </p>
35
     * <p>
36
     * The return value will be casted to boolean if non-boolean was returned.
37
     */
38
    public function offsetExists($offset)
39
    {
40
        // TODO: Implement offsetExists() method.
41
    }
42
43
    /**
44
     * @param int $offset
45
     */
46
    public function offsetGet($offset): CData
47
    {
48
        // TODO: Implement offsetGet() method.
49
    }
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 FFI\CData. 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...
50
51
    /**
52
     * Offset to set
53
     * @link https://php.net/manual/en/arrayaccess.offsetset.php
54
     * @param mixed $offset <p>
55
     * The offset to assign the value to.
56
     * </p>
57
     * @param mixed $value <p>
58
     * The value to set.
59
     * </p>
60
     * @return void
61
     */
62
    public function offsetSet($offset, $value)
63
    {
64
        // TODO: Implement offsetSet() method.
65
    }
66
67
    /**
68
     * Offset to unset
69
     * @link https://php.net/manual/en/arrayaccess.offsetunset.php
70
     * @param mixed $offset <p>
71
     * The offset to unset.
72
     * </p>
73
     * @return void
74
     */
75
    public function offsetUnset($offset)
76
    {
77
        // TODO: Implement offsetUnset() method.
78
    }
79
}