Skip to content

Commit 3fee1ce

Browse files
authored
Use fully qualified for php functions (#212)
1 parent 3a70abe commit 3fee1ce

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

src/App.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(array $userSettings = [])
4343

4444
if (!empty($this->config('scripts'))) {
4545
foreach ($this->config('scripts') as $script) {
46-
call_user_func($script, $this, Config::get());
46+
\call_user_func($script, $this, Config::get());
4747
}
4848

4949
$this->loadConfig();
@@ -170,7 +170,7 @@ public function __unset($name)
170170
*/
171171
public function config($name, $value = null)
172172
{
173-
if ($value === null && is_string($name)) {
173+
if ($value === null && \is_string($name)) {
174174
return Config::get($name);
175175
}
176176

@@ -185,7 +185,7 @@ public function config($name, $value = null)
185185
*/
186186
public function attach(callable $code)
187187
{
188-
call_user_func($code, $this, Config::get());
188+
\call_user_func($code, $this, Config::get());
189189
$this->loadConfig();
190190
$this->setupErrorHandler();
191191
}
@@ -223,10 +223,10 @@ public function setResponseClass($class)
223223
*/
224224
public function cors($options = [])
225225
{
226-
if (class_exists('Leaf\Http\Cors')) {
226+
if (\class_exists('Leaf\Http\Cors')) {
227227
Http\Cors::config($options);
228228
} else {
229-
trigger_error('Cors module not found! Run `leaf install cors` or `composer require leafs/cors` to install the CORS module. This is required to configure CORS.');
229+
\trigger_error('Cors module not found! Run `leaf install cors` or `composer require leafs/cors` to install the CORS module. This is required to configure CORS.');
230230
}
231231
}
232232

@@ -240,7 +240,7 @@ public function cors($options = [])
240240
*/
241241
public function ws(string $name, callable $callback)
242242
{
243-
Config::set('eien.events', array_merge(
243+
Config::set('eien.events', \array_merge(
244244
Config::get('eien.events') ?? [],
245245
[$name => $callback]
246246
));
@@ -258,7 +258,7 @@ public function ws(string $name, callable $callback)
258258
public function logger()
259259
{
260260
if (!$this->log) {
261-
trigger_error('You need to enable logging to use this feature! Set log.enabled to true and install the logger module');
261+
\trigger_error('You need to enable logging to use this feature! Set log.enabled to true and install the logger module');
262262
}
263263

264264
return $this->log;
@@ -308,7 +308,7 @@ public function response(): Http\Response
308308
*/
309309
public function root()
310310
{
311-
return rtrim($_SERVER['DOCUMENT_ROOT'], '/') . rtrim($this->request->getScriptName(), '/') . '/';
311+
return \rtrim($_SERVER['DOCUMENT_ROOT'], '/') . \rtrim($this->request->getScriptName(), '/') . '/';
312312
}
313313

314314
/**
@@ -323,8 +323,8 @@ public function root()
323323
*/
324324
public static function halt($status, $message = '')
325325
{
326-
if (ob_get_level() !== 0) {
327-
ob_clean();
326+
if (\ob_get_level() !== 0) {
327+
\ob_clean();
328328
}
329329

330330
Http\Headers::resetStatus($status);
@@ -372,7 +372,7 @@ public static function environment($mode, $callback)
372372
*/
373373
public static function run(?callable $callback = null)
374374
{
375-
if (class_exists('Leaf\Eien\Server') && Config::get('eien.enabled')) {
375+
if (\class_exists('Leaf\Eien\Server') && Config::get('eien.enabled')) {
376376
server()
377377
->wrap(function () use ($callback) {
378378
parent::run($callback);

src/Config.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ class Config
3737
*/
3838
public static function set($item, $value = null)
3939
{
40-
if (is_string($item)) {
41-
if (!strpos($item, '.')) {
40+
if (\is_string($item)) {
41+
if (!\strpos($item, '.')) {
4242
static::$settings[$item] = $value;
4343
} else {
44-
static::$settings = array_merge(
44+
static::$settings = \array_merge(
4545
static::$settings,
4646
static::mapConfig($item, $value)
4747
);
@@ -58,13 +58,13 @@ public static function set($item, $value = null)
5858
*/
5959
protected static function mapConfig(string $item, $value = null)
6060
{
61-
$config = explode('.', $item);
61+
$config = \explode('.', $item);
6262

63-
if (count($config) > 2) {
64-
trigger_error('Nested config can\'t be more than 1 level deep');
63+
if (\count($config) > 2) {
64+
\trigger_error('Nested config can\'t be more than 1 level deep');
6565
}
6666

67-
return [$config[0] => array_merge(
67+
return [$config[0] => \array_merge(
6868
static::$settings[$config[0]] ?? [],
6969
[$config[1] => $value]
7070
)];
@@ -78,9 +78,9 @@ protected static function mapConfig(string $item, $value = null)
7878
public static function get($item = null)
7979
{
8080
if ($item) {
81-
$items = explode('.', $item);
81+
$items = \explode('.', $item);
8282

83-
if (count($items) > 1) {
83+
if (\count($items) > 1) {
8484
return static::$settings[$items[0]][$items[1]] ?? null;
8585
}
8686

src/View.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public static function attach($className, $name = null)
3131

3232
private static function getDiIndex($class)
3333
{
34-
$fullName = explode("\\", strtolower(get_class($class)));
35-
$className = $fullName[count($fullName) - 1];
34+
$fullName = \explode("\\", \strtolower(\get_class($class)));
35+
$className = $fullName[\count($fullName) - 1];
3636

3737
return $className;
3838
}

0 commit comments

Comments
 (0)