Skip to content

Commit 7316245

Browse files
committed
psr2 fixed
1 parent 599bb99 commit 7316245

File tree

29 files changed

+210
-175
lines changed

29 files changed

+210
-175
lines changed

.php_cs.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"php":"7.0.18-0ubuntu0.17.04.1","version":"2.7.0","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":{"ensure_fully_multiline":true},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true},"hashes":{"app\/\/template\/default\/template.php":3136700671,"app\/\/template\/default\/ajax.php":3136700671,"app\/\/template\/starter\/template.php":1727269453,"app\/\/template\/developer\/template.php":3702324045,"app\/\/module\/example\/view\/index.php":1697046663,"app\/\/module\/example\/controller.php":3751192754,"app\/\/module\/cms\/action\/admin.php":1736409272,"app\/\/module\/cms\/view\/template.php":2566799738,"app\/\/module\/cms\/view\/admin.php":1106211042,"app\/\/module\/cms\/view\/ajax.php":3021121263,"app\/\/module\/cms\/view\/admin\/objects\/index.php":4243547960,"app\/\/module\/cms\/view\/admin\/objects\/new.php":844624377,"app\/\/module\/cms\/view\/admin\/objects\/edit.php":41990189,"app\/\/module\/cms\/view\/admin\/page\/index.php":1668763883,"app\/\/module\/cms\/view\/admin\/page\/new.php":1076256290,"app\/\/module\/cms\/view\/admin\/page\/edit.php":1731907981,"app\/\/module\/cms\/view\/admin\/menu\/new.php":1341166534,"app\/\/module\/cms\/view\/admin\/menu\/edit.php":2629330881,"app\/\/module\/cms\/view\/admin\/menu\/index.php":1754974259,"app\/\/module\/cms\/view\/admin\/sign-in.php":1455515385,"app\/\/module\/cms\/view\/admin\/index.php":978715433,"app\/\/module\/cms\/view\/admin\/search\/index.php":634988040,"app\/\/module\/cms\/view\/admin\/template\/edit.php":1336875959,"app\/\/module\/cms\/view\/admin\/template\/new.php":872728314,"app\/\/module\/cms\/view\/admin\/template\/index.php":2840055386,"app\/\/module\/cms\/view\/admin\/settings\/index.php":1460865501,"app\/\/module\/cms\/view\/admin\/snippet\/edit.php":775334433,"app\/\/module\/cms\/view\/admin\/snippet\/index.php":688053924,"app\/\/module\/cms\/view\/admin\/snippet\/new.php":1142691519,"app\/\/module\/cms\/view\/admin\/module\/new.php":1075750828,"app\/\/module\/cms\/view\/admin\/module\/view.php":1335707945,"app\/\/module\/cms\/view\/admin\/module\/index.php":3252323382,"app\/\/module\/cms\/view\/admin\/module\/edit.php":3429423843,"app\/\/module\/cms\/view\/admin\/task\/view.php":2949652318,"app\/\/module\/cms\/view\/admin\/task\/index.php":3483692186,"app\/\/module\/cms\/view\/admin\/task\/new.php":1825492831,"app\/\/module\/cms\/view\/admin\/task\/edit.php":846251049,"app\/\/module\/cms\/controller.php":621778871,"app\/\/framework\/traits\/csrf.php":955386642,"app\/\/framework\/helper.php":2264487613,"app\/\/framework\/model.php":629551421,"app\/\/framework\/controller.php":1545133040,"app\/\/controller\/module.php":2987741726,"app\/\/controller\/error.php":795712275,"app\/\/controller\/asset.php":2867769708,"tasks\/\/tasks\/SetFilePermissions.php":3501878165,"tasks\/\/tasks\/RotateLogs.php":1875066464,"tasks\/\/tasks\/Daemon.php":599472155,"tasks\/\/lib\/Runner.php":3345243835,"tasks\/\/lib\/PID.php":3692464962,"tasks\/\/lib\/Db.php":977441352,"tasks\/\/lib\/traits\/RedBean.php":3867071544,"tasks\/\/lib\/traits\/Log.php":1118032917,"tasks\/\/run.php":2908446932}}

app/controller/asset.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function __construct()
1818
$this->f3->set('f3', $this->f3);
1919

2020
// helper - get active template path from session
21-
$this->f3->set('getAssetPath', function($params = [], $type = 'css') {
21+
$this->f3->set('getAssetPath', function ($params = [], $type = 'css') {
2222
//dir
2323
$dir = (!empty($params['dir']) ? basename($params['dir']) : null);
2424

@@ -146,5 +146,4 @@ public function favicon(\Base $f3, $params)
146146

147147
exit(\Web::instance()->send($path, null, 1024, false));
148148
}
149-
150-
}
149+
}

app/controller/error.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Error extends \Prefab
77
protected $view;
88

99
/**
10-
*
10+
*
1111
*/
1212
public function __construct()
1313
{
@@ -23,7 +23,7 @@ public function __construct()
2323
$this->settings = new \Framework\Model('settings');
2424
}
2525

26-
/**
26+
/**
2727
* Needs doing
2828
*/
2929
public function display(\Base $f3, $params)
@@ -86,5 +86,4 @@ public function afterRoute(\Base $f3, $params)
8686
{
8787
echo \View::instance()->render($f3->get('template'));
8888
}
89-
90-
}
89+
}

app/controller/module.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public function __construct()
1212
}
1313

1414
/**
15-
*
16-
*/
15+
*
16+
*/
1717
public function init(\Base $f3, $params)
1818
{
1919
//
@@ -23,7 +23,6 @@ public function init(\Base $f3, $params)
2323

2424
//
2525
if (file_exists(getcwd().'/app/module/'.$params['module'].'/controller.php')) {
26-
2726
$namespace = '\\Module\\'.ucfirst($params['module']).'\\Controller';
2827

2928
$controller = new $namespace();
@@ -53,5 +52,4 @@ public function init(\Base $f3, $params)
5352
}
5453
}
5554
}
56-
57-
}
55+
}

app/framework/controller.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Controller extends \Prefab
99
use \Framework\Traits\CSRF;
1010

1111
/**
12-
*
12+
*
1313
*/
1414
public function __construct()
1515
{
@@ -44,5 +44,4 @@ public function afterRoute(\Base $f3, $params)
4444
echo \View::instance()->render($f3->get('template'));
4545
}
4646
}
47-
48-
}
47+
}

app/framework/helper.php

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ public function __construct()
1919
*/
2020
public function format_bytes($bytes = 0)
2121
{
22-
if ($bytes < 1024) return $bytes.' B';
23-
elseif ($bytes < 1048576) return round($bytes / 1024, 2).' KiB';
24-
elseif ($bytes < 1073741824) return round($bytes / 1048576, 2).' MiB';
25-
elseif ($bytes < 1099511627776) return round($bytes / 1073741824, 2).' GiB';
26-
else return round($bytes / 1099511627776, 2).' TiB';
22+
if ($bytes < 1024) {
23+
return $bytes.' B';
24+
} elseif ($bytes < 1048576) {
25+
return round($bytes / 1024, 2).' KiB';
26+
} elseif ($bytes < 1073741824) {
27+
return round($bytes / 1048576, 2).' MiB';
28+
} elseif ($bytes < 1099511627776) {
29+
return round($bytes / 1073741824, 2).' GiB';
30+
} else {
31+
return round($bytes / 1099511627776, 2).' TiB';
32+
}
2733
}
2834

2935
/**
@@ -35,13 +41,20 @@ public function short_number($n = 0)
3541
$n = (0+str_replace(",", "", $n));
3642

3743
// is this a number?
38-
if (!is_numeric($n)) return false;
44+
if (!is_numeric($n)) {
45+
return false;
46+
}
3947

4048
// now filter it;
41-
if ($n > 1000000000000) return round(($n/1000000000000), 2).'t';
42-
elseif ($n > 1000000000) return round(($n/1000000000), 2).'b';
43-
elseif ($n > 1000000) return round(($n/1000000), 2).'m';
44-
elseif ($n > 1000) return round(($n/1000), 2).'k';
49+
if ($n > 1000000000000) {
50+
return round(($n/1000000000000), 2).'t';
51+
} elseif ($n > 1000000000) {
52+
return round(($n/1000000000), 2).'b';
53+
} elseif ($n > 1000000) {
54+
return round(($n/1000000), 2).'m';
55+
} elseif ($n > 1000) {
56+
return round(($n/1000), 2).'k';
57+
}
4558

4659
return number_format($n);
4760
}
@@ -124,7 +137,7 @@ public function slugify($text)
124137
$text = strtolower($text);
125138
// remove unwanted characters
126139
$text = preg_replace('~[^-\w]+~', '', $text);
127-
if (empty($text)){
140+
if (empty($text)) {
128141
return 'n-a';
129142
}
130143
return $text;
@@ -262,7 +275,7 @@ public function http_response_code_text($domain)
262275
//set status color to warning if not 200
263276
if ($status == 200) {
264277
$labelColor = 'success';
265-
} elseif($status == 404) {
278+
} elseif ($status == 404) {
266279
$labelColor = 'warning';
267280
} else {
268281
$labelColor = 'danger';
@@ -277,7 +290,8 @@ public function http_response_code_text($domain)
277290
/**
278291
*
279292
*/
280-
public function response_code_text($code) {
293+
public function response_code_text($code)
294+
{
281295
switch ($code) {
282296
case 100: $text = 'Continue'; break;
283297
case 101: $text = 'Switching Protocols'; break;
@@ -406,7 +420,7 @@ public function get_ip_info($ip = null)
406420
// if we dont have a status query the API
407421
if (empty($ipinfo['status'])) {
408422
$ch = curl_init();
409-
curl_setopt($ch, CURLOPT_URL,'http://ip-api.com/json/'.$ip);
423+
curl_setopt($ch, CURLOPT_URL, 'http://ip-api.com/json/'.$ip);
410424
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
411425
$data = curl_exec($ch);
412426

@@ -447,8 +461,8 @@ public function get_ip_info($ip = null)
447461
* $ids = $this->app->helper->hashid()->decode($ids);
448462
*/
449463
public function hashid(
450-
$salt = 'SHA256ed.f0r.4a5h.sa1tlng',
451-
$length = 6,
464+
$salt = 'SHA256ed.f0r.4a5h.sa1tlng',
465+
$length = 6,
452466
$alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
453467
) {
454468
return new \Hashids\Hashids(
@@ -466,15 +480,15 @@ public function hashid(
466480
* @param int $last_page
467481
* @return string
468482
*/
469-
function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adjacents = 3, $key = 'pg')
483+
public function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adjacents = 3, $key = 'pg')
470484
{
471485
$ret = null;
472486
$prev = ($p-1);
473487
$next = ($p+1);
474488
$last_page = ($totalposts-1);
475489

476490
// sorting
477-
$sorting =
491+
$sorting =
478492
(!empty($_GET['c']) ? '&c='.$_GET['c'] : '').
479493
(!empty($_GET['o']) ? '&o='.($_GET['o'] == 'asc' ? 'asc' : 'desc') : '');
480494

@@ -488,8 +502,8 @@ function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adj
488502
$ret.= '<li class="disabled"><a href="javascript:void(0)">&laquo; Previous</a></li> ';
489503
}
490504

491-
if ($totalposts < 7 + ($adjacents * 2)){
492-
for ($counter = 1; $counter <= $totalposts; $counter++){
505+
if ($totalposts < 7 + ($adjacents * 2)) {
506+
for ($counter = 1; $counter <= $totalposts; $counter++) {
493507
if ($counter == $p) {
494508
$ret.= '<li class="active"><a href="javascript:void(0)">'.$counter.'</a></li> ';
495509
} else {
@@ -498,7 +512,7 @@ function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adj
498512
}
499513
} elseif ($totalposts > 5 + ($adjacents * 2)) {
500514
if ($p < 1 + ($adjacents * 2)) {
501-
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++){
515+
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) {
502516
if ($counter == $p) {
503517
$ret.= '<li class="active"><a href="javascript:void(0)">'.$counter.'</a></li> ';
504518
} else {
@@ -510,11 +524,11 @@ function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adj
510524
$ret.= ' <li><a href="?'.$key.'='.$totalposts.''.$sorting.'" class="'.$link_class.'" data-keep-state="true">'.$totalposts.'</a></li> ';
511525
}
512526
//in middle; hide some front and some back
513-
elseif($totalposts - ($adjacents * 2) > $p && $p > ($adjacents * 2)){
527+
elseif ($totalposts - ($adjacents * 2) > $p && $p > ($adjacents * 2)) {
514528
$ret.= ' <li><a href="?'.$key.'=1'.$sorting.'" class="'.$link_class.'" data-keep-state="true">1</a></li> ';
515529
$ret.= ' <li><a href="?'.$key.'=2'.$sorting.'" class="'.$link_class.'" data-keep-state="true">2</a></li> ';
516530
$ret.= ' <li class="disabled"><a href="javascript:void(0)">...</a></li> ';
517-
for ($counter = $p - $adjacents; $counter <= $p + $adjacents; $counter++){
531+
for ($counter = $p - $adjacents; $counter <= $p + $adjacents; $counter++) {
518532
if ($counter == $p) {
519533
$ret.= ' <li class="active"><a href="javascript:void(0)">'.$counter.'</a></li> ';
520534
} else {
@@ -528,7 +542,7 @@ function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adj
528542
$ret.= ' <li><a href="?'.$key.'=1'.$sorting.'" class="'.$link_class.'" data-keep-state="true">1</a></li> ';
529543
$ret.= ' <li><a href="?'.$key.'=2'.$sorting.'" class="'.$link_class.'" data-keep-state="true">2</a></li> ';
530544
$ret.= ' <li class="active"><a href="javascript:void(0)">...</a></li> ';
531-
for ($counter = $totalposts - (2 + ($adjacents * 2)); $counter <= $totalposts; $counter++){
545+
for ($counter = $totalposts - (2 + ($adjacents * 2)); $counter <= $totalposts; $counter++) {
532546
if ($counter == $p) {
533547
$ret.= ' <li class="active"><a href="javascript:void(0)">'.$counter.'</a></li> ';
534548
} else {
@@ -605,7 +619,6 @@ public function vincentyGreatCircleDistance($latitudeFrom, $longitudeFrom, $lati
605619
$angle = atan2(sqrt($a), $b);
606620
return $angle * $earthRadius;
607621
}
608-
609622
}
610623

611-
}
624+
}

app/framework/model.php

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Model
88
protected $table;
99

1010
/**
11-
*
11+
*
1212
*/
1313
public function __construct($table = null)
1414
{
@@ -41,7 +41,9 @@ public function __construct($table = null)
4141
*/
4242
public function create($data = [])
4343
{
44-
if ($this->table === null) return null;
44+
if ($this->table === null) {
45+
return null;
46+
}
4547

4648
$row = R::dispense($this->table);
4749
$row->import($data);
@@ -55,7 +57,9 @@ public function create($data = [])
5557
*/
5658
public function find($where = null, $params = null)
5759
{
58-
if ($this->table === null) return null;
60+
if ($this->table === null) {
61+
return null;
62+
}
5963

6064
if ($where !== null && $params !== null) {
6165
return R::find($this->table, $where, $params);
@@ -71,7 +75,9 @@ public function find($where = null, $params = null)
7175
*/
7276
public function findAll($where = null, $params = null)
7377
{
74-
if ($this->table === null) return null;
78+
if ($this->table === null) {
79+
return null;
80+
}
7581

7682
if ($where !== null && $params !== null) {
7783
return R::findAll($this->table, $where, $params);
@@ -87,7 +93,9 @@ public function findAll($where = null, $params = null)
8793
*/
8894
public function findOne($where = null, $params = null)
8995
{
90-
if ($this->table === null) return null;
96+
if ($this->table === null) {
97+
return null;
98+
}
9199

92100
if ($where !== null && $params !== null) {
93101
return R::findOne($this->table, $where, $params);
@@ -96,7 +104,7 @@ public function findOne($where = null, $params = null)
96104
} else {
97105
return R::findOne($this->table);
98106
}
99-
}
107+
}
100108

101109
/**
102110
* Get all
@@ -110,7 +118,7 @@ public function getAll($where = null, $params = null)
110118
} else {
111119
return [];
112120
}
113-
}
121+
}
114122

115123
/**
116124
* Get row
@@ -124,7 +132,7 @@ public function getRow($where = null, $params = null)
124132
} else {
125133
return [];
126134
}
127-
}
135+
}
128136

129137
/**
130138
* Get col
@@ -167,7 +175,9 @@ public function findOrCreate($params = [])
167175
*/
168176
public function count($where = null, $params = null)
169177
{
170-
if ($this->table === null) return null;
178+
if ($this->table === null) {
179+
return null;
180+
}
171181

172182
if ($where !== null && $params !== null) {
173183
return R::count($this->table, $where, $params);
@@ -183,7 +193,9 @@ public function count($where = null, $params = null)
183193
*/
184194
public function load($id)
185195
{
186-
if ($this->table === null) return null;
196+
if ($this->table === null) {
197+
return null;
198+
}
187199

188200
return R::load($this->table, $id);
189201
}
@@ -227,6 +239,5 @@ public function trash(\RedBeanPHP\OODBBean $row)
227239
{
228240
return R::trash($row);
229241
}
230-
231242
}
232-
}
243+
}

0 commit comments

Comments
 (0)