Issues (27)

src/NotCache.php (1 issue)

1
<?php
2
3
/*
4
 * This file is part of the Cache package.
5
 *
6
 * Copyright (c) Daniel González
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @author Daniel González <[email protected]>
12
 * @author Arnold Daniels <[email protected]>
13
 */
14
15
declare(strict_types=1);
16
17
namespace Desarrolla2\Cache;
18
19
use Desarrolla2\Cache\AbstractCache;
20
use Desarrolla2\Cache\Packer\PackerInterface;
21
use Desarrolla2\Cache\Packer\NopPacker;
22
23
/**
24
 * Dummy cache handler
25
 */
26
class NotCache extends AbstractCache
27
{
28
    /**
29
     * Create the default packer for this cache implementation.
30
     *
31
     * @return PackerInterface
32
     */
33
    protected static function createDefaultPacker(): PackerInterface
34
    {
35
        return new NopPacker();
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 1
    public function delete($key)
42
    {
43 1
        return true;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 1
    public function get($key, $default = null)
50
    {
51 1
        return false;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function getMultiple($keys, $default = null)
58
    {
59
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the return type mandated by Psr\SimpleCache\CacheInterface::getMultiple() of iterable.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65 1
    public function has($key)
66
    {
67 1
        return false;
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73 3
    public function set($key, $value, $ttl = null)
74
    {
75 3
        return false;
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81
    public function setMultiple($values, $ttl = null)
82
    {
83
        return false;
84
    }
85
86
    /**
87
     * {@inheritdoc}
88
     */
89
    public function clear()
90
    {
91
        return true;
92
    }
93
}
94