Skip to content

Commit 3691c63

Browse files
committed
zend usage removed; psr2 fixes
1 parent caa3951 commit 3691c63

7 files changed

Lines changed: 1045 additions & 209 deletions

File tree

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@
3131
"require": {
3232
"php" : ">=7.3",
3333
"g4/mcache" : "*",
34-
"laminas/laminas-cache" : "3.0.*",
34+
"laminas/laminas-cache" : "2.13.*",
3535
"laminas/laminas-session" : "2.12.*"
3636
},
3737
"require-dev": {
38-
"laminas/laminas-cache-storage-adapter-memory" : "2.0.*",
3938
"phpunit/phpunit" : "9.*",
4039
"squizlabs/php_codesniffer" : "3.*",
4140
"g4/code-coverage" : "1.*"

composer.lock

Lines changed: 956 additions & 138 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Container.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
namespace G4\Session;
44

5+
use Laminas\Session\Container as LaminasContainer;
6+
57
class Container
68
{
79

810
/**
9-
* @var \Zend\Session\Container
11+
* @var LaminasContainer
1012
*/
1113
private $container;
1214

@@ -15,14 +17,14 @@ class Container
1517
*/
1618
public function __construct($name)
1719
{
18-
$this->container = new \Zend\Session\Container($name);
20+
$this->container = new LaminasContainer($name);
1921
}
2022

2123
/**
2224
* @param string $key
2325
* @return boolean
2426
*/
25-
public function offsetExists($key)
27+
public function offsetExists($key): bool
2628
{
2729
return $this->container->offsetExists($key);
2830
}
@@ -40,44 +42,44 @@ public function offsetGet($key)
4042
* @param string $key
4143
* @param mixed $value
4244
*/
43-
public function offsetSet($key, $value)
45+
public function offsetSet($key, $value): void
4446
{
45-
return $this->container->offsetSet($key, $value);
47+
$this->container->offsetSet($key, $value);
4648
}
4749

4850
/**
4951
* @param string $key
5052
* @return void
5153
*/
52-
public function offsetUnset($key)
54+
public function offsetUnset($key): void
5355
{
5456
$this->container->offsetUnset($key);
5557
}
5658

5759
/**
5860
* @return array
5961
*/
60-
public function getData()
62+
public function getData(): array
6163
{
6264
return $this->container->getArrayCopy();
6365
}
6466

6567
/**
6668
* @return boolean
6769
*/
68-
public function hasData()
70+
public function hasData(): bool
6971
{
7072
$data = $this->container->getArrayCopy();
7173
return !empty($data);
7274
}
7375

7476
/**
7577
* @param array $data
76-
* @return \G4\Session\Container
78+
* @return Container
7779
*/
78-
public function setData(array $data)
80+
public function setData(array $data): Container
7981
{
8082
$this->container->exchangeArray($data);
8183
return $this;
8284
}
83-
}
85+
}

src/ErrorCodes.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<?php
22

3-
43
namespace G4\Session;
54

6-
75
class ErrorCodes
86
{
97

10-
const MISSING_DOMAIN_NAME_EXCEPTION = 70001;
8+
public const MISSING_DOMAIN_NAME_EXCEPTION = 70001;
119
}

src/Exception/MissingDomainNameException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class MissingDomainNameException extends Exception
99
{
1010

11-
const MESSAGE = 'Missing Domain Name';
11+
public const MESSAGE = 'Missing Domain Name';
1212

1313
public function __construct()
1414
{

src/SaveHandler/Couchbase.php

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
namespace G4\Session\SaveHandler;
44

5-
class Couchbase implements \Zend\Session\SaveHandler\SaveHandlerInterface
5+
use G4\Mcache\Mcache;
6+
use G4\Mcache\McacheFactory;
7+
use Laminas\Session\SaveHandler\SaveHandlerInterface;
8+
9+
class Couchbase implements SaveHandlerInterface
610
{
711

812
/**
9-
* @var \G4\Mcache\Mcache
13+
* @var Mcache
1014
*/
1115
private $mcache;
1216

@@ -15,15 +19,15 @@ class Couchbase implements \Zend\Session\SaveHandler\SaveHandlerInterface
1519
*/
1620
private $options;
1721

18-
1922
/**
2023
* @param array $options
24+
* @throws \Exception
2125
*/
2226
public function __construct(array $options)
2327
{
24-
$this->options = $options;
25-
$this->mcache = \G4\Mcache\McacheFactory::createInstance(
26-
\G4\Mcache\McacheFactory::DRIVER_COUCHBASE,
28+
$this->options = $options;
29+
$this->mcache = McacheFactory::createInstance(
30+
McacheFactory::DRIVER_COUCHBASE,
2731
$this->options,
2832
__CLASS__
2933
);
@@ -32,15 +36,15 @@ public function __construct(array $options)
3236
/**
3337
* Unnecessary for couchbase
3438
*/
35-
public function open($savePath, $name)
39+
public function open($savePath, $name): bool
3640
{
3741
return true;
3842
}
3943

4044
/**
4145
* Unnecessary for couchbase
4246
*/
43-
public function close()
47+
public function close(): bool
4448
{
4549
return true;
4650
}
@@ -49,7 +53,7 @@ public function close()
4953
* @param string $id
5054
* @return string
5155
*/
52-
public function read($id)
56+
public function read($id): string
5357
{
5458
return $this->mcache
5559
->key($id)
@@ -61,21 +65,22 @@ public function read($id)
6165
* @param string $data
6266
* @return bool
6367
*/
64-
public function write($id, $data)
68+
public function write($id, $data): bool
6569
{
6670
$result = $this->mcache
6771
->key($id)
6872
->value($data)
6973
->expiration($this->getLifetime())
7074
->set();
75+
7176
return !empty($result);
7277
}
7378

7479
/**
7580
* @param string $id
7681
* @return bool
7782
*/
78-
public function destroy($id)
83+
public function destroy($id): bool
7984
{
8085
return $this->mcache
8186
->key($id)
@@ -85,18 +90,18 @@ public function destroy($id)
8590
/**
8691
* Unnecessary for couchbase
8792
*/
88-
public function gc($maxlifetime)
93+
public function gc($maxlifetime): bool
8994
{
9095
return true;
9196
}
9297

9398
/**
9499
* @return int
95100
*/
96-
private function getLifetime()
101+
private function getLifetime(): int
97102
{
98103
return isset($this->options['lifetime'])
99104
? (int) $this->options['lifetime']
100105
: 0;
101106
}
102-
}
107+
}

0 commit comments

Comments
 (0)