GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 859d66...4f628a )
by やかみ
01:26
created

src/Http/Session/Memcached.php (1 issue)

Labels

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Kotori.php
4
 *
5
 * A Tiny Model-View-Controller PHP Framework
6
 *
7
 * This content is released under the Apache 2 License
8
 *
9
 * Copyright (c) 2015-2017 Kotori Technology. All rights reserved.
10
 *
11
 * Licensed under the Apache License, Version 2.0 (the "License");
12
 * you may not use this file except in compliance with the License.
13
 * You may obtain a copy of the License at
14
 *
15
 *     http://www.apache.org/licenses/LICENSE-2.0
16
 *
17
 * Unless required by applicable law or agreed to in writing, software
18
 * distributed under the License is distributed on an "AS IS" BASIS,
19
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
 * See the License for the specific language governing permissions and
21
 * limitations under the License.
22
 */
23
24
/**
25
 * Memcached Session Class
26
 *
27
 * @package     Kotori
28
 * @subpackage  Session
29
 * @author      Kokororin
30
 * @link        https://kotori.love
31
 */
32
namespace Kotori\Http\Session;
33
34
use Kotori\Core\Cache\Memcached as MemcachedDriver;
35
use SessionHandlerInterface;
36
37
class Memcached implements SessionHandlerInterface
38
{
39
    /**
40
     * Default configuration
41
     *
42
     * @var array
43
     */
44
    protected $config = [
45
        'host' => '127.0.0.1',
46
        'port' => 11211,
47
        'expire' => 3600,
48
        'prefix' => '',
49
    ];
50
51
    /**
52
     * Class constructor
53
     *
54
     * Setup Memcache(d)
55
     *
56
     * @param  array $config
57
     * @return void
58
     */
59
    public function __construct($config = [])
60
    {
61
        $this->config = array_merge($this->config, $config);
62
    }
63
64
    /**
65
     * Open session
66
     *
67
     * @param  string    $savePath
68
     * @param  mixed     $sessName
69
     * @return boolean
70
     */
71
    // @codingStandardsIgnoreStart
72
    public function open($savePath, $sessName)
73
    {
74
        $this->memcachedDriver = new MemcachedDriver($this->config);
0 ignored issues
show
The property memcachedDriver does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
75
        return true;
76
    }
77
    // @codingStandardsIgnoreEnd
78
79
    /**
80
     * Close session
81
     *
82
     * @return boolean
83
     */
84
    public function close()
85
    {
86
        $this->gc(ini_get('session.gc_maxlifetime'));
87
        $this->memcachedDriver = null;
88
        return true;
89
    }
90
91
    /**
92
     * Read session
93
     *
94
     * @param  string $sessID
95
     * @return string
96
     */
97
    public function read($sessID)
98
    {
99
        return (string) $this->memcachedDriver->get($this->config['prefix'] . $sessID);
100
    }
101
102
    /**
103
     * Write session
104
     *
105
     * @param string $sessID
106
     * @param String $sessData
107
     * @return boolean
108
     */
109
    public function write($sessID, $sessData)
110
    {
111
        return $this->memcachedDriver->set($this->config['prefix'] . $sessID, $sessData, $this->config['expire']);
112
    }
113
114
    /**
115
     * Delete session
116
     *
117
     * @param  string $sessID
118
     * @return boolean
119
     */
120
    public function destroy($sessID)
121
    {
122
        return $this->memcachedDriver->delete($this->config['prefix'] . $sessID);
123
    }
124
125
    /**
126
     * do garbage collection
127
     *
128
     * @param  string $sessMaxLifeTime
129
     * @return boolean
130
     */
131
    public function gc($sessMaxLifeTime)
132
    {
133
        return true;
134
    }
135
}
136