Skip to content

Commit 8c98cdc

Browse files
committed
Import global classes but fully qualify functions and constants
1 parent df41929 commit 8c98cdc

File tree

224 files changed

+1105
-1081
lines changed

Some content is hidden

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

224 files changed

+1105
-1081
lines changed

app/Config/Database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Database extends Config
1515
*
1616
* @var string
1717
*/
18-
public $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR;
18+
public $filesPath = APPPATH . 'Database' . \DIRECTORY_SEPARATOR;
1919

2020
/**
2121
* Lets you choose which connection group to

app/Config/Mimes.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,11 @@ public static function guessTypeFromExtension(string $extension)
491491
{
492492
$extension = trim(strtolower($extension), '. ');
493493

494-
if (! array_key_exists($extension, static::$mimes)) {
494+
if (! \array_key_exists($extension, static::$mimes)) {
495495
return null;
496496
}
497497

498-
return is_array(static::$mimes[$extension]) ? static::$mimes[$extension][0] : static::$mimes[$extension];
498+
return \is_array(static::$mimes[$extension]) ? static::$mimes[$extension][0] : static::$mimes[$extension];
499499
}
500500

501501
/**
@@ -512,7 +512,7 @@ public static function guessExtensionFromType(string $type, ?string $proposedExt
512512
$proposedExtension = trim(strtolower($proposedExtension));
513513

514514
if ($proposedExtension !== '') {
515-
if (array_key_exists($proposedExtension, static::$mimes) && in_array($type, is_string(static::$mimes[$proposedExtension]) ? [static::$mimes[$proposedExtension]] : static::$mimes[$proposedExtension], true)) {
515+
if (\array_key_exists($proposedExtension, static::$mimes) && \in_array($type, \is_string(static::$mimes[$proposedExtension]) ? [static::$mimes[$proposedExtension]] : static::$mimes[$proposedExtension], true)) {
516516
// The detected mime type matches with the proposed extension.
517517
return $proposedExtension;
518518
}
@@ -524,7 +524,7 @@ public static function guessExtensionFromType(string $type, ?string $proposedExt
524524
// Reverse check the mime type list if no extension was proposed.
525525
// This search is order sensitive!
526526
foreach (static::$mimes as $ext => $types) {
527-
if ((is_string($types) && $types === $type) || (is_array($types) && in_array($type, $types, true))) {
527+
if ((\is_string($types) && $types === $type) || (\is_array($types) && \in_array($type, $types, true))) {
528528
return $ext;
529529
}
530530
}

system/API/ResponseTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function respond($data = null, ?int $status = null, string $message = '')
131131
*/
132132
public function fail($messages, int $status = 400, ?string $code = null, string $customMessage = '')
133133
{
134-
if (! is_array($messages)) {
134+
if (! \is_array($messages)) {
135135
$messages = ['error' => $messages];
136136
}
137137

@@ -332,7 +332,7 @@ public function failServerError(string $description = 'Internal Server Error', ?
332332
protected function format($data = null)
333333
{
334334
// If the data is a string, there's not much we can do to it...
335-
if (is_string($data)) {
335+
if (\is_string($data)) {
336336
// The content type should be text/... and not application/...
337337
$contentType = $this->response->getHeaderLine('Content-Type');
338338
$contentType = str_replace('application/json', 'text/html', $contentType);
@@ -347,7 +347,7 @@ protected function format($data = null)
347347
$mime = "application/{$this->format}";
348348

349349
// Determine correct response type through content negotiation if not explicitly declared
350-
if (empty($this->format) || ! in_array($this->format, ['json', 'xml'], true)) {
350+
if (empty($this->format) || ! \in_array($this->format, ['json', 'xml'], true)) {
351351
$mime = $this->request->negotiate('media', $format->getConfig()->supportedResponseFormats, false);
352352
}
353353

system/Autoloader/Autoloader.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function register()
123123

124124
// Load our non-class files
125125
foreach ($this->files as $file) {
126-
if (is_string($file)) {
126+
if (\is_string($file)) {
127127
$this->includeFile($file);
128128
}
129129
}
@@ -138,22 +138,22 @@ public function register()
138138
*/
139139
public function addNamespace($namespace, ?string $path = null)
140140
{
141-
if (is_array($namespace)) {
141+
if (\is_array($namespace)) {
142142
foreach ($namespace as $prefix => $namespacedPath) {
143143
$prefix = trim($prefix, '\\');
144144

145-
if (is_array($namespacedPath)) {
145+
if (\is_array($namespacedPath)) {
146146
foreach ($namespacedPath as $dir) {
147-
$this->prefixes[$prefix][] = rtrim($dir, '\\/') . DIRECTORY_SEPARATOR;
147+
$this->prefixes[$prefix][] = rtrim($dir, '\\/') . \DIRECTORY_SEPARATOR;
148148
}
149149

150150
continue;
151151
}
152152

153-
$this->prefixes[$prefix][] = rtrim($namespacedPath, '\\/') . DIRECTORY_SEPARATOR;
153+
$this->prefixes[$prefix][] = rtrim($namespacedPath, '\\/') . \DIRECTORY_SEPARATOR;
154154
}
155155
} else {
156-
$this->prefixes[trim($namespace, '\\')][] = rtrim($path, '\\/') . DIRECTORY_SEPARATOR;
156+
$this->prefixes[trim($namespace, '\\')][] = rtrim($path, '\\/') . \DIRECTORY_SEPARATOR;
157157
}
158158

159159
return $this;
@@ -198,7 +198,7 @@ public function loadClassmap(string $class)
198198
{
199199
$file = $this->classmap[$class] ?? '';
200200

201-
if (is_string($file) && $file !== '') {
201+
if (\is_string($file) && $file !== '') {
202202
return $this->includeFile($file);
203203
}
204204

@@ -239,7 +239,7 @@ protected function loadInNamespace(string $class)
239239
$directory = rtrim($directory, '\\/');
240240

241241
if (strpos($class, $namespace) === 0) {
242-
$filePath = $directory . str_replace('\\', DIRECTORY_SEPARATOR, substr($class, strlen($namespace))) . '.php';
242+
$filePath = $directory . str_replace('\\', \DIRECTORY_SEPARATOR, substr($class, \strlen($namespace))) . '.php';
243243
$filename = $this->includeFile($filePath);
244244

245245
if ($filename) {

system/Autoloader/FileLocator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function locateFile(string $file, ?string $folder = null, string $ext = '
5050

5151
// Clears the folder name if it is at the beginning of the filename
5252
if (! empty($folder) && strpos($file, $folder) === 0) {
53-
$file = substr($file, strlen($folder . '/'));
53+
$file = substr($file, \strlen($folder . '/'));
5454
}
5555

5656
// Is not namespaced? Try the application folder.
@@ -208,7 +208,7 @@ protected function ensureExt(string $path, string $ext): string
208208
if ($ext) {
209209
$ext = '.' . $ext;
210210

211-
if (substr($path, -strlen($ext)) !== $ext) {
211+
if (substr($path, -\strlen($ext)) !== $ext) {
212212
$path .= $ext;
213213
}
214214
}
@@ -233,15 +233,15 @@ protected function getNamespaces()
233233
if ($prefix === 'CodeIgniter') {
234234
$system = [
235235
'prefix' => $prefix,
236-
'path' => rtrim($path, '\\/') . DIRECTORY_SEPARATOR,
236+
'path' => rtrim($path, '\\/') . \DIRECTORY_SEPARATOR,
237237
];
238238

239239
continue;
240240
}
241241

242242
$namespaces[] = [
243243
'prefix' => $prefix,
244-
'path' => rtrim($path, '\\/') . DIRECTORY_SEPARATOR,
244+
'path' => rtrim($path, '\\/') . \DIRECTORY_SEPARATOR,
245245
];
246246
}
247247
}

system/BaseModel.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ abstract public function chunk(int $size, Closure $userFunc);
514514
*/
515515
public function find($id = null)
516516
{
517-
$singleton = is_numeric($id) || is_string($id);
517+
$singleton = is_numeric($id) || \is_string($id);
518518

519519
if ($this->tempAllowCallbacks) {
520520
// Call the before event and check for a return
@@ -732,11 +732,11 @@ public function insert($data = null, bool $returnID = true)
732732
// Set created_at and updated_at with same time
733733
$date = $this->setDate();
734734

735-
if ($this->useTimestamps && $this->createdField && ! array_key_exists($this->createdField, $data)) {
735+
if ($this->useTimestamps && $this->createdField && ! \array_key_exists($this->createdField, $data)) {
736736
$data[$this->createdField] = $date;
737737
}
738738

739-
if ($this->useTimestamps && $this->updatedField && ! array_key_exists($this->updatedField, $data)) {
739+
if ($this->useTimestamps && $this->updatedField && ! \array_key_exists($this->updatedField, $data)) {
740740
$data[$this->updatedField] = $date;
741741
}
742742

@@ -784,19 +784,19 @@ public function insert($data = null, bool $returnID = true)
784784
*/
785785
public function insertBatch(?array $set = null, ?bool $escape = null, int $batchSize = 100, bool $testing = false)
786786
{
787-
if (is_array($set)) {
787+
if (\is_array($set)) {
788788
foreach ($set as &$row) {
789789
// If $data is using a custom class with public or protected
790790
// properties representing the collection elements, we need to grab
791791
// them as an array.
792-
if (is_object($row) && ! $row instanceof stdClass) {
792+
if (\is_object($row) && ! $row instanceof stdClass) {
793793
$row = $this->objectToArray($row, false, true);
794794
}
795795

796796
// If it's still a stdClass, go ahead and convert to
797797
// an array so doProtectFields and other model methods
798798
// don't have to do special checks.
799-
if (is_object($row)) {
799+
if (\is_object($row)) {
800800
$row = (array) $row;
801801
}
802802

@@ -812,11 +812,11 @@ public function insertBatch(?array $set = null, ?bool $escape = null, int $batch
812812
// Set created_at and updated_at with same time
813813
$date = $this->setDate();
814814

815-
if ($this->useTimestamps && $this->createdField && ! array_key_exists($this->createdField, $row)) {
815+
if ($this->useTimestamps && $this->createdField && ! \array_key_exists($this->createdField, $row)) {
816816
$row[$this->createdField] = $date;
817817
}
818818

819-
if ($this->useTimestamps && $this->updatedField && ! array_key_exists($this->updatedField, $row)) {
819+
if ($this->useTimestamps && $this->updatedField && ! \array_key_exists($this->updatedField, $row)) {
820820
$row[$this->updatedField] = $date;
821821
}
822822
}
@@ -836,7 +836,7 @@ public function insertBatch(?array $set = null, ?bool $escape = null, int $batch
836836
*/
837837
public function update($id = null, $data = null): bool
838838
{
839-
if (is_numeric($id) || is_string($id)) {
839+
if (is_numeric($id) || \is_string($id)) {
840840
$id = [$id];
841841
}
842842

@@ -857,7 +857,7 @@ public function update($id = null, $data = null): bool
857857
throw DataException::forEmptyDataset('update');
858858
}
859859

860-
if ($this->useTimestamps && $this->updatedField && ! array_key_exists($this->updatedField, $data)) {
860+
if ($this->useTimestamps && $this->updatedField && ! \array_key_exists($this->updatedField, $data)) {
861861
$data[$this->updatedField] = $this->setDate();
862862
}
863863

@@ -900,19 +900,19 @@ public function update($id = null, $data = null): bool
900900
*/
901901
public function updateBatch(?array $set = null, ?string $index = null, int $batchSize = 100, bool $returnSQL = false)
902902
{
903-
if (is_array($set)) {
903+
if (\is_array($set)) {
904904
foreach ($set as &$row) {
905905
// If $data is using a custom class with public or protected
906906
// properties representing the collection elements, we need to grab
907907
// them as an array.
908-
if (is_object($row) && ! $row instanceof stdClass) {
908+
if (\is_object($row) && ! $row instanceof stdClass) {
909909
$row = $this->objectToArray($row, true, true);
910910
}
911911

912912
// If it's still a stdClass, go ahead and convert to
913913
// an array so doProtectFields and other model methods
914914
// don't have to do special checks.
915-
if (is_object($row)) {
915+
if (\is_object($row)) {
916916
$row = (array) $row;
917917
}
918918

@@ -933,7 +933,7 @@ public function updateBatch(?array $set = null, ?string $index = null, int $batc
933933
$row[$index] = $updateIndex;
934934
}
935935

936-
if ($this->useTimestamps && $this->updatedField && ! array_key_exists($this->updatedField, $row)) {
936+
if ($this->useTimestamps && $this->updatedField && ! \array_key_exists($this->updatedField, $row)) {
937937
$row[$this->updatedField] = $this->setDate();
938938
}
939939
}
@@ -954,7 +954,7 @@ public function updateBatch(?array $set = null, ?string $index = null, int $batc
954954
*/
955955
public function delete($id = null, bool $purge = false)
956956
{
957-
if ($id && (is_numeric($id) || is_string($id))) {
957+
if ($id && (is_numeric($id) || \is_string($id))) {
958958
$id = [$id];
959959
}
960960

@@ -1146,7 +1146,7 @@ protected function doProtectFields(array $data): array
11461146
}
11471147

11481148
foreach (array_keys($data) as $key) {
1149-
if (! in_array($key, $this->allowedFields, true)) {
1149+
if (! \in_array($key, $this->allowedFields, true)) {
11501150
unset($data[$key]);
11511151
}
11521152
}
@@ -1339,7 +1339,7 @@ public function validate($data): bool
13391339
}
13401340

13411341
//Validation requires array, so cast away.
1342-
if (is_object($data)) {
1342+
if (\is_object($data)) {
13431343
$data = (array) $data;
13441344
}
13451345

@@ -1366,7 +1366,7 @@ public function getValidationRules(array $options = []): array
13661366

13671367
// ValidationRules can be either a string, which is the group name,
13681368
// or an array of rules.
1369-
if (is_string($rules)) {
1369+
if (\is_string($rules)) {
13701370
$rules = $this->validation->loadRuleGroup($rules);
13711371
}
13721372

@@ -1403,7 +1403,7 @@ protected function cleanValidationRules(array $rules, ?array $data = null): arra
14031403
}
14041404

14051405
foreach (array_keys($rules) as $field) {
1406-
if (! array_key_exists($field, $data)) {
1406+
if (! \array_key_exists($field, $data)) {
14071407
unset($rules[$field]);
14081408
}
14091409
}
@@ -1573,7 +1573,7 @@ protected function objectToRawArray($data, bool $onlyChanged = true, bool $recur
15731573
*/
15741574
protected function transformDataToArray($data, string $type): array
15751575
{
1576-
if (! in_array($type, ['insert', 'update'], true)) {
1576+
if (! \in_array($type, ['insert', 'update'], true)) {
15771577
throw new InvalidArgumentException(sprintf('Invalid type "%s" used upon transforming data to array.', $type));
15781578
}
15791579

@@ -1584,14 +1584,14 @@ protected function transformDataToArray($data, string $type): array
15841584
// If $data is using a custom class with public or protected
15851585
// properties representing the collection elements, we need to grab
15861586
// them as an array.
1587-
if (is_object($data) && ! $data instanceof stdClass) {
1587+
if (\is_object($data) && ! $data instanceof stdClass) {
15881588
$data = $this->objectToArray($data, true, true);
15891589
}
15901590

15911591
// If it's still a stdClass, go ahead and convert to
15921592
// an array so doProtectFields and other model methods
15931593
// don't have to do special checks.
1594-
if (is_object($data)) {
1594+
if (\is_object($data)) {
15951595
$data = (array) $data;
15961596
}
15971597

@@ -1682,11 +1682,11 @@ protected function fillPlaceholders(array $rules, array $data): array
16821682

16831683
if (! empty($replacements)) {
16841684
foreach ($rules as &$rule) {
1685-
if (is_array($rule)) {
1685+
if (\is_array($rule)) {
16861686
foreach ($rule as &$row) {
16871687
// Should only be an `errors` array
16881688
// which doesn't take placeholders.
1689-
if (is_array($row)) {
1689+
if (\is_array($row)) {
16901690
continue;
16911691
}
16921692

system/CLI/BaseCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function getPad(array $array, int $pad): int
195195
$max = 0;
196196

197197
foreach (array_keys($array) as $key) {
198-
$max = max($max, strlen($key));
198+
$max = max($max, \strlen($key));
199199
}
200200

201201
return $max + $pad;

0 commit comments

Comments
 (0)