Skip to content

Commit 3aaaf2c

Browse files
author
Anton
authored
Merge pull request #474 from bluzphp/develop
Migrate to Symfony/Cache
2 parents e47c194 + ddb31d2 commit 3aaaf2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+363
-358
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"ext-json": "*",
1010
"ext-ctype": "*",
1111
"bluzphp/collection": "~1.0",
12-
"cache/cache": "~1.0",
1312
"psr/log": "~1.1",
1413
"laminas/laminas-diactoros": "~2.6",
15-
"laminas/laminas-httphandlerrunner": "~1.4"
14+
"laminas/laminas-httphandlerrunner": "~1.4",
15+
"symfony/cache": "^5.3"
1616
},
1717
"require-dev": {
1818
"codeception/codeception": "~4.1",
@@ -27,7 +27,7 @@
2727
"ext-redis": "required by Redis adapter for Bluz\\Cache (https://github.com/bluzphp/framework/wiki/Cache)",
2828
"ext-memcached": "required by Memcached adapter for Bluz\\Cache (https://github.com/bluzphp/framework/wiki/Cache)",
2929
"phpmailer/phpmailer": "required by Bluz\\Mailer (https://github.com/bluzphp/framework/wiki/Mailer)",
30-
"predis/predis": "required by Cache\\Adapter\\Predis (https://github.com/bluzphp/framework/wiki/Cache)"
30+
"predis/predis": "required by Redis adapter for Bluz\\Cache (https://github.com/bluzphp/framework/wiki/Cache)"
3131
},
3232
"autoload": {
3333
"psr-4": {

src/Application/Application.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ public function getEnvironment(): string
8989
* Get path to Application
9090
*
9191
* @return string
92-
* @throws ReflectionException
9392
*/
9493
public function getPath(): string
9594
{
@@ -180,7 +179,6 @@ public function init(string $environment = 'production'): void
180179
*
181180
* @return void
182181
* @throws ConfigException
183-
* @throws ReflectionException
184182
*/
185183
protected function initConfig(): void
186184
{

src/Common/Options.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ trait Options
4747
/**
4848
* @var array options store
4949
*/
50-
protected $options;
50+
protected $options = [];
5151

5252
/**
5353
* Get option by key
@@ -105,7 +105,7 @@ public function getOptions(): array
105105
*
106106
* @return void
107107
*/
108-
public function setOptions(array $options = null): void
108+
public function setOptions(?array $options = null): void
109109
{
110110
// store options by default
111111
$this->options = (array)$options;

src/Db/Table.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,10 @@ public static function findWhere(...$where): array
293293
$whereAndTerms[] = $self->name . '.' . $keyName . ' IN (' . $keyValue . ')';
294294
} elseif (null === $keyValue) {
295295
$whereAndTerms[] = $self->name . '.' . $keyName . ' IS NULL';
296-
} elseif (is_string($keyValue) && ('%' === $keyValue{0} || '%' === $keyValue{-1})) {
296+
} elseif (
297+
is_string($keyValue)
298+
&& ('%' === substr($keyValue, 0, 1) || '%' === substr($keyValue, -1, 1))
299+
) {
297300
$whereAndTerms[] = $self->name . '.' . $keyName . ' LIKE ?';
298301
$whereParams[] = $keyValue;
299302
} else {

src/EventManager/Event.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,13 @@ public function getParam($name, $default = null)
135135
/**
136136
* Set the event name
137137
*
138-
* @param string $name
138+
* @param string $name
139139
*
140140
* @return void
141141
*/
142-
public function setName($name): void
142+
public function setName(string $name): void
143143
{
144-
$this->name = (string)$name;
144+
$this->name = $name;
145145
}
146146

147147
/**

src/Http/CacheControl.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class CacheControl
4646
*
4747
* @param Response $response
4848
*/
49-
public function __construct($response)
49+
public function __construct(Response $response)
5050
{
5151
$this->response = $response;
5252
}
@@ -135,11 +135,11 @@ public function getMaxAge(): ?int
135135
*
136136
* This methods sets the Cache-Control max-age directive.
137137
*
138-
* @param integer $value Number of seconds
138+
* @param integer $value Number of seconds
139139
*
140140
* @return void
141141
*/
142-
public function setMaxAge($value): void
142+
public function setMaxAge(int $value): void
143143
{
144144
$this->doSetContainer('max-age', $value);
145145
$this->updateCacheControlHeader();
@@ -150,11 +150,11 @@ public function setMaxAge($value): void
150150
*
151151
* This methods sets the Cache-Control s-maxage directive.
152152
*
153-
* @param integer $value Number of seconds
153+
* @param integer $value Number of seconds
154154
*
155155
* @return void
156156
*/
157-
public function setSharedMaxAge($value): void
157+
public function setSharedMaxAge(int $value): void
158158
{
159159
$this->setPublic();
160160
$this->doSetContainer('s-maxage', $value);
@@ -183,11 +183,11 @@ public function getTtl(): ?int
183183
*
184184
* This method adjusts the Cache-Control/s-maxage directive.
185185
*
186-
* @param integer $seconds Number of seconds
186+
* @param integer $seconds Number of seconds
187187
*
188188
* @return void
189189
*/
190-
public function setTtl($seconds): void
190+
public function setTtl(int $seconds): void
191191
{
192192
$this->setSharedMaxAge($this->getAge() + $seconds);
193193
}
@@ -197,11 +197,11 @@ public function setTtl($seconds): void
197197
*
198198
* This method adjusts the Cache-Control/max-age directive.
199199
*
200-
* @param integer $seconds Number of seconds
200+
* @param integer $seconds Number of seconds
201201
*
202202
* @return void
203203
*/
204-
public function setClientTtl($seconds): void
204+
public function setClientTtl(int $seconds): void
205205
{
206206
$this->setMaxAge($this->getAge() + $seconds);
207207
}
@@ -219,12 +219,12 @@ public function getEtag(): string
219219
/**
220220
* Sets the ETag value
221221
*
222-
* @param string $etag The ETag unique identifier
223-
* @param bool $weak Whether you want a weak ETag or not
222+
* @param string $etag The ETag unique identifier
223+
* @param bool $weak Whether you want a weak ETag or not
224224
*
225225
* @return void
226226
*/
227-
public function setEtag($etag, $weak = false): void
227+
public function setEtag(string $etag, bool $weak = false): void
228228
{
229229
$etag = trim($etag, '"');
230230
$this->response->setHeader('ETag', (true === $weak ? 'W/' : '') . '"' . $etag . '"');
@@ -246,11 +246,11 @@ public function getAge(): int
246246
/**
247247
* Set the age of the response
248248
*
249-
* @param integer $age
249+
* @param integer $age
250250
*
251251
* @return void
252252
*/
253-
public function setAge($age): void
253+
public function setAge(int $age): void
254254
{
255255
$this->response->setHeader('Age', $age);
256256
}

src/Layout/Helper/HeadScript.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
/**
1818
* Set or generate <script> code for <head>
1919
*
20-
* @param string $src
21-
* @param array $attributes
20+
* @param string|null $src
21+
* @param array $attributes
2222
*
2323
* @return null|string
2424
*/
2525
return
26-
function ($src = null, array $attributes = []) {
26+
function (?string $src = null, array $attributes = []) {
2727
/**
2828
* @var Layout $this
2929
*/

src/Layout/Helper/HeadStyle.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
/**
1818
* Set or generate <style> code for <head>
1919
*
20-
* @param string $href
21-
* @param string $media
20+
* @param string|null $href
21+
* @param string $media
2222
*
2323
* @return string|null
2424
*/
2525
return
26-
function ($href = null, $media = 'all') {
26+
function (?string $href = null, string $media = 'all') {
2727
/**
2828
* @var Layout $this
2929
*/

src/Layout/Helper/Link.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
/**
1818
* Set or generate <link> code for <head>
1919
*
20-
* @param array $link
20+
* @param array|null $link
2121
*
2222
* @return string|null
2323
*/
2424
return
25-
function (array $link = null) {
25+
function (?array $link = null) {
2626
/**
2727
* @var Layout $this
2828
*/

src/Layout/Helper/Meta.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
/**
1717
* Set or generate <meta> code for <head>
1818
*
19-
* @param string|array|null $name
20-
* @param string|null $content
19+
* @param string|array|null $name
20+
* @param string|null $content
2121
*
2222
* @return string|null
2323
*/
2424
return
25-
function ($name = null, $content = null) {
25+
function ($name = null, ?string $content = null) {
2626
// it's stack for <head>
2727
$meta = Registry::get('layout:meta') ?: [];
2828

0 commit comments

Comments
 (0)