Skip to content

Commit c233fb5

Browse files
authored
Merge pull request #11 from inceptphp/main
php9 prep
2 parents 1a90993 + 04025c7 commit c233fb5

19 files changed

Lines changed: 71 additions & 70 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
composer.phar
22
/vendor/
3+
composer.lock
34

45
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
56
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file

admin/AdminPackage.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ public function error(
122122
$path = $request->getPath('string');
123123
//if not an admin path
124124
if ($path !== static::ROOT_PATH
125-
&& strpos($path, static::ROOT_PATH . '/') !== 0
125+
&& strpos((string) $path, static::ROOT_PATH . '/') !== 0
126126
) {
127127
return;
128128
}
129129

130-
$debug = strpos($path, static::ROOT_SPA . '/') === false ? 'page': 'spa';
130+
$debug = strpos((string) $path, static::ROOT_SPA . '/') === false ? 'page': 'spa';
131131

132132
//if it was a call for an actual file
133133
if (preg_match('/\.[a-zA-Z0-9]{1,4}$/', $path)) {
@@ -136,7 +136,7 @@ public function error(
136136

137137
//if this is not an html page
138138
$type = $response->getHeaders('Content-Type');
139-
if (strpos($type, 'html') === false) {
139+
if (strpos((string) $type, 'html') === false) {
140140
//don't make it pretty
141141
return $this->errorDebug($request, $response, $error, $debug);
142142
}
@@ -346,7 +346,7 @@ protected function errorDebug(
346346

347347
//shorten file
348348
$data['short_file'] = basename($data['file']);
349-
if (strpos($data['file'], INCEPT_CWD) === 0) {
349+
if (strpos((string) $data['file'], INCEPT_CWD) === 0) {
350350
$data['short_file'] = substr($data['file'], strlen(INCEPT_CWD));
351351
}
352352

@@ -373,7 +373,7 @@ protected function errorDebug(
373373

374374
//shorten file
375375
$trace['short_file'] = basename($trace['file']);
376-
if (strpos($data['file'], INCEPT_CWD) === 0) {
376+
if (strpos((string) $data['file'], INCEPT_CWD) === 0) {
377377
$trace['short_file'] = substr($trace['file'], strlen(INCEPT_CWD) + 1);
378378
}
379379

admin/controller/fieldset.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
$data = $request->getPost();
181181

182182
//if detail has no value make it null
183-
if (isset($data['detail']) && !trim($data['detail'])) {
183+
if (isset($data['detail']) && !trim((string) $data['detail'])) {
184184
$data['detail'] = null;
185185
}
186186

@@ -496,7 +496,7 @@
496496
//get the content
497497
$fieldset = $request->getStage('fieldset');
498498
//get the type
499-
$type = substr($fieldset, 5, strpos($fieldset, ';base64') - 5);
499+
$type = substr($fieldset, 5, strpos((string) $fieldset, ';base64') - 5);
500500

501501
//invalid file?
502502
if ($type !== 'application/json' && $type !== 'application/zip') {
@@ -505,7 +505,7 @@
505505

506506
//decode the content
507507
$content = base64_decode(
508-
substr($fieldset, strpos($fieldset, ';base64,') + 8)
508+
substr($fieldset, strpos((string) $fieldset, ';base64,') + 8)
509509
);
510510

511511
//json file?
@@ -587,7 +587,7 @@
587587

588588
//root or not under fieldset?
589589
if ($filename === 'fieldset/'
590-
|| strpos($filename, 'fieldset/') === false
590+
|| strpos((string) $filename, 'fieldset/') === false
591591
) {
592592
continue;
593593
}
@@ -868,7 +868,7 @@
868868
$data = $request->getPost();
869869

870870
//if detail has no value make it null
871-
if (isset($data['detail']) && !trim($data['detail'])) {
871+
if (isset($data['detail']) && !trim((string) $data['detail'])) {
872872
$data['detail'] = null;
873873
}
874874

admin/controller/language.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
//loop through the keys found
111111
foreach ($keys as $key) {
112112
//if blank key
113-
if (!trim($key)) {
113+
if (!trim((string) $key)) {
114114
//skip
115115
continue;
116116
}
@@ -172,7 +172,7 @@
172172

173173
//----------------------------//
174174
// 2. Validate Data
175-
if (!isset($data['filename']) || !trim($data['filename'])) {
175+
if (!isset($data['filename']) || !trim((string) $data['filename'])) {
176176
return $response->setError(true, 'Language code is required');
177177
}
178178

@@ -322,7 +322,7 @@
322322

323323
//----------------------------//
324324
// 2. Validate Data
325-
if (!isset($data['filename']) || !trim($data['filename'])) {
325+
if (!isset($data['filename']) || !trim((string) $data['filename'])) {
326326
return $response->setError(true, 'Language code is required');
327327
}
328328

admin/controller/package.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
$rows = $this('config')->get('packages');
3434

3535
foreach ($rows as $name => $row) {
36-
if (($data['filter'] === 'default' && strpos($name, 'inceptphp/') !== 0)
37-
|| ($data['filter'] === 'custom' && strpos($name, 'inceptphp/') === 0)
36+
if (($data['filter'] === 'default' && strpos((string) $name, 'inceptphp/') !== 0)
37+
|| ($data['filter'] === 'custom' && strpos((string) $name, 'inceptphp/') === 0)
3838
) {
3939
continue;
4040
}
@@ -45,11 +45,11 @@
4545
} else {
4646
$path = null;
4747
//if it starts with / like /foo/bar
48-
if (strpos($name, '/') === 0) {
48+
if (strpos((string) $name, '/') === 0) {
4949
//it's a root package
5050
$path = INCEPT_CWD . $name;
5151
//if theres a slash like foo/bar
52-
} else if (strpos($name, '/') !== false) {
52+
} else if (strpos((string) $name, '/') !== false) {
5353
//it's vendor package
5454
$path = sprintf('%s/vendor/%s', INCEPT_CWD, $name);
5555
}
@@ -74,7 +74,7 @@
7474

7575
if (isset($rows[$name]['info']['settings'])) {
7676
$rows[$name]['info']['open'] = strpos(
77-
$rows[$name]['info']['settings'],
77+
(string) $rows[$name]['info']['settings'],
7878
'/admin/spa/'
7979
) === 0;
8080
}
@@ -152,11 +152,11 @@
152152
} else {
153153
$path = null;
154154
//if it starts with / like /foo/bar
155-
if (strpos($name, '/') === 0) {
155+
if (strpos((string) $name, '/') === 0) {
156156
//it's a root package
157157
$path = INCEPT_CWD . $name;
158158
//if theres a slash like foo/bar
159-
} else if (strpos($name, '/') !== false) {
159+
} else if (strpos((string) $name, '/') !== false) {
160160
//it's vendor package
161161
$path = sprintf('%s/vendor/%s', INCEPT_CWD, $name);
162162
}
@@ -273,11 +273,11 @@
273273
} else {
274274
$path = null;
275275
//if it starts with / like /foo/bar
276-
if (strpos($name, '/') === 0) {
276+
if (strpos((string) $name, '/') === 0) {
277277
//it's a root package
278278
$path = INCEPT_CWD . $name;
279279
//if theres a slash like foo/bar
280-
} else if (strpos($name, '/') !== false) {
280+
} else if (strpos((string) $name, '/') !== false) {
281281
//it's vendor package
282282
$path = sprintf('%s/vendor/%s', INCEPT_CWD, $name);
283283
}
@@ -394,11 +394,11 @@
394394
} else {
395395
$path = null;
396396
//if it starts with / like /foo/bar
397-
if (strpos($name, '/') === 0) {
397+
if (strpos((string) $name, '/') === 0) {
398398
//it's a root package
399399
$path = INCEPT_CWD . $name;
400400
//if theres a slash like foo/bar
401-
} else if (strpos($name, '/') !== false) {
401+
} else if (strpos((string) $name, '/') !== false) {
402402
//it's vendor package
403403
$path = sprintf('%s/vendor/%s', INCEPT_CWD, $name);
404404
}

admin/controller/schema.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
if (isset($data['rows']) && is_array($data['rows'])) {
5656
foreach ($data['rows'] as $row) {
5757
$group = 'Custom';
58-
if (isset($row['group']) && trim($row['group'])) {
58+
if (isset($row['group']) && trim((string) $row['group'])) {
5959
$group = $row['group'];
6060
}
6161

@@ -201,7 +201,7 @@
201201
$data = $request->getPost();
202202

203203
//if detail has no value make it null
204-
if (isset($data['detail']) && !trim($data['detail'])) {
204+
if (isset($data['detail']) && !trim((string) $data['detail'])) {
205205
$data['detail'] = null;
206206
}
207207

@@ -890,7 +890,7 @@
890890
$data = $request->getPost();
891891

892892
//if detail has no value make it null
893-
if (isset($data['detail']) && !trim($data['detail'])) {
893+
if (isset($data['detail']) && !trim((string) $data['detail'])) {
894894
$data['detail'] = null;
895895
}
896896

api/boot/body.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @param ResponseInterface $response
2222
*/
2323
return function(RequestInterface $request, ResponseInterface $response) {
24-
if (!trim($request->get('body'))) {
24+
if (!trim((string) $request->get('body'))) {
2525
return;
2626
}
2727

auth/AuthPackage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function slugger(string $string, string $suffix = null): string
136136
$slug = preg_replace('~[^-\w\+]+~', '', $slug);
137137

138138
// trim
139-
$slug = trim($slug, '-');
139+
$slug = trim((string) $slug, '-');
140140

141141
// remove duplicate -
142142
$slug = preg_replace('~-+~', '-', $slug);

auth/controller/admin.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,31 +120,31 @@
120120
//----------------------------//
121121
// 3. Validate Data
122122
foreach ($data['services'] as $i => $service) {
123-
if (!isset($service['name']) || !trim($service['name'])) {
123+
if (!isset($service['name']) || !trim((string) $service['name'])) {
124124
$response->invalidate('service', $i, 'name', 'Name is required');
125125
}
126126

127127
if (!isset($service['active'])) {
128128
$response->invalidate('service', $i, 'active', 'Active is required');
129129
}
130130

131-
if (!isset($service['client_id']) || !trim($service['client_id'])) {
131+
if (!isset($service['client_id']) || !trim((string) $service['client_id'])) {
132132
$response->invalidate('service', $i, 'client_id', 'Client ID is required');
133133
}
134134

135-
if (!isset($service['client_secret']) || !trim($service['client_secret'])) {
135+
if (!isset($service['client_secret']) || !trim((string) $service['client_secret'])) {
136136
$response->invalidate('service', $i, 'client_secret', 'Client Secret is required');
137137
}
138138

139-
if (!isset($service['url_authorize']) || !trim($service['url_authorize'])) {
139+
if (!isset($service['url_authorize']) || !trim((string) $service['url_authorize'])) {
140140
$response->invalidate('service', $i, 'url_authorize', 'Authorize URL is required');
141141
}
142142

143-
if (!isset($service['url_access_token']) || !trim($service['url_access_token'])) {
143+
if (!isset($service['url_access_token']) || !trim((string) $service['url_access_token'])) {
144144
$response->invalidate('service', $i, 'url_access_token', 'Access Token URL is required');
145145
}
146146

147-
if (!isset($service['url_resource']) || !trim($service['url_resource'])) {
147+
if (!isset($service['url_resource']) || !trim((string) $service['url_resource'])) {
148148
$response->invalidate('service', $i, 'url_resource', 'Resource URL is required');
149149
}
150150
}
@@ -212,7 +212,7 @@
212212
) {
213213
//if profile id, or profile name
214214
if (is_numeric($request->getStage('profile_id'))
215-
|| !trim($request->getStage('__profile'))
215+
|| !trim((string) $request->getStage('__profile'))
216216
) {
217217
return;
218218
}

auth/events.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595

9696
//----------------------------//
9797
// 2. Validate Data
98-
if (!isset($data['auth_slug']) || !trim($data['auth_slug'])) {
98+
if (!isset($data['auth_slug']) || !trim((string) $data['auth_slug'])) {
9999
$response->invalidate('auth_slug', 'Cannot be empty');
100100
}
101101

0 commit comments

Comments
 (0)