Skip to content

Commit c6b5218

Browse files
authored
Merge pull request #58 from thomas-netlor/master
Old commit & php8 changes
2 parents 2b47b40 + ee8509f commit c6b5218

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

Pragma/ORM/Model.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ public function attrs_allowed($attrs, $force = false)
860860
return $this;
861861
}
862862

863-
public function jsonSerialize():array
863+
public function jsonSerialize():mixed
864864
{
865865
return $this->as_array();
866866
}

Pragma/Router/Request.php

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Pragma\Router;
34

45
class Request
@@ -11,14 +12,14 @@ class Request
1112
protected $options = [];
1213
protected $mask = 'pig';
1314

14-
private static $request = null;//singleton
15+
private static $request = null; //singleton
1516

1617
public function __construct()
1718
{
1819
if (php_sapi_name() == "cli") {
1920
$this->isCli = true;
2021
global $argv;
21-
$path = empty($argv)?[]:$argv;
22+
$path = empty($argv) ? [] : $argv;
2223
unset($path[0]); // public/index.php
2324
$this->path = [];
2425
foreach ($path as $p) {
@@ -60,7 +61,7 @@ public function __construct()
6061

6162
$this->method = strtolower($_SERVER['REQUEST_METHOD']);
6263

63-
if (!empty($this->method) && $this->method == 'post') {//we need to check _METHOD
64+
if (!empty($this->method) && $this->method == 'post') { //we need to check _METHOD
6465
if (!empty($_POST['_METHOD'])) {
6566
$verb = strtolower($_POST['_METHOD']);
6667
switch ($verb) {
@@ -75,9 +76,9 @@ public function __construct()
7576

7677
//isXhr ?
7778
$this->isXhr =
78-
(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest')
79-
|| isset($_SERVER['CONTENT_TYPE']) && strpos(strtolower($_SERVER['CONTENT_TYPE']), 'application/json') !== false
80-
|| isset($_SERVER['CONTENT_TYPE']) && strpos(strtolower($_SERVER['CONTENT_TYPE']), 'application/javascript') !== false;//jsonp
79+
(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest')
80+
|| isset($_SERVER['CONTENT_TYPE']) && strpos(strtolower($_SERVER['CONTENT_TYPE']), 'application/json') !== false
81+
|| isset($_SERVER['CONTENT_TYPE']) && strpos(strtolower($_SERVER['CONTENT_TYPE']), 'application/javascript') !== false; //jsonp
8182

8283
//isSameOrigin ? HTTP_REFERER is not always given by the browser agent, HTTP_HOST too
8384
if (isset($_SERVER['HTTP_PRAGMA_REFERER']) || isset($_SERVER['HTTP_REFERER']) && isset($_SERVER['HTTP_HOST'])) {
@@ -152,10 +153,10 @@ public function parse_params($sanitize = true)
152153
}
153154

154155
if ($sanitize) {
155-
$params = array_map(self::class . '::recursive_filter', $params);
156-
array_walk_recursive($_GET, self::class . '::filter_string_polyfill');
157-
array_walk_recursive($_POST, self::class . '::filter_string_polyfill');
158-
array_walk_recursive($this->options, self::class . '::filter_string_polyfill');
156+
$params = array_map([self::class, 'filter_string_polyfill'], $params);
157+
array_walk_recursive($_GET, [self::class, 'filter_string_polyfill']);
158+
array_walk_recursive($_POST, [self::class, 'filter_string_polyfill']);
159+
array_walk_recursive($this->options, [self::class, 'filter_string_polyfill']);
159160
}
160161

161162
if (is_null($_POST)) {
@@ -179,16 +180,16 @@ private function buildParams($p, $i, $g)
179180
$mask = str_split($this->mask);
180181
foreach ($mask as $k) {
181182
switch ($k) {
182-
case 'p':
183-
$ret = array_merge($ret, $p);
184-
break;
185-
case 'i':
186-
$ret = array_merge($ret, $i);
187-
break;
188-
case 'g':
189-
$ret = array_merge($ret, $g);
190-
break;
191-
}
183+
case 'p':
184+
$ret = array_merge($ret, $p);
185+
break;
186+
case 'i':
187+
$ret = array_merge($ret, $i);
188+
break;
189+
case 'g':
190+
$ret = array_merge($ret, $g);
191+
break;
192+
}
192193
}
193194
return $ret;
194195
}
@@ -198,7 +199,7 @@ public static function recursive_filter($val)
198199
if ($val === null) {
199200
return null;
200201
} elseif (is_array($val)) {
201-
return array_map(self::class . '::recursive_filter', $val);
202+
return array_map([self::class, 'recursive_filter'], $val);
202203
} else {
203204
return self::filter_string_polyfill($val);
204205
}

0 commit comments

Comments
 (0)