Skip to content

Commit bb349c0

Browse files
committed
refactor: replace function null checks with strict comparisons
1 parent 1ab0628 commit bb349c0

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

EventHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function addEvent(callable|object|string $event, ?string $bind = null): v
6262
}
6363
}
6464

65-
if (is_null($bind)) {
65+
if ($bind === null) {
6666
$this->event[] = $event;
6767
} else {
6868
$this->event[] = [$bind => $event];
@@ -95,7 +95,7 @@ public function __call(string $method, array $args): mixed
9595
throw new BadMethodCallException("The method \"".$method."\" does not exist in the class (" . $handler[0]::class . ")", 1);
9696
}
9797
*/
98-
if (is_null($handler[1][0]) || in_array($method, $handler[1])) {
98+
if ($handler[1][0] === null || in_array($method, $handler[1])) {
9999
$this->bindable[$method] = $method;
100100
}
101101
$data = call_user_func_array([$handler[0], $method], $args);

Reflection.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function dependencyInjector(?object $class = null, ?string $method = null
7777
{
7878
$args = [];
7979
$constructor = $this->setDependMethod($method, $this->reflect);
80-
if (!is_null($constructor)) {
80+
if ($constructor !== null) {
8181
$params = $constructor->getParameters();
8282
$this->injectRecursion($params, $this->reflect->getName());
8383
foreach ($params as $param) {
@@ -93,7 +93,7 @@ public function dependencyInjector(?object $class = null, ?string $method = null
9393
}
9494
}
9595
}
96-
if (!is_null($this->dependMethod)) {
96+
if ($this->dependMethod !== null) {
9797
$this->dependMethod = null;
9898
return $constructor->invokeArgs($class, $args);
9999
}
@@ -111,7 +111,7 @@ public function setDependMethod(?string $method, ReflectionClass $inst): ?Reflec
111111
{
112112
$method = ($method === "constructor") ? null : $method;
113113
$this->dependMethod = $method;
114-
if (is_null($this->dependMethod)) {
114+
if ($this->dependMethod === null) {
115115
return $inst->getConstructor();
116116
}
117117
return $inst->getMethod($this->dependMethod);
@@ -239,7 +239,7 @@ private function getClassNameFromParam(ReflectionParameter $param): ?string
239239
private function insertInterfaceClasses(ReflectionClass $inst, string $classNameA): void
240240
{
241241
if ($this->allowInterfaces) {
242-
if (!is_null(self::$interfaceFactory)) {
242+
if (self::$interfaceFactory !== null) {
243243
foreach (self::$interfaceFactory as $call) {
244244
self::$class[$classNameA] = $call($inst->getShortName(), $classNameA, $inst);
245245
}
@@ -323,7 +323,7 @@ public function getReflect(): ReflectionClass
323323
*/
324324
public function get(): mixed
325325
{
326-
if (!is_null($this->method)) {
326+
if ($this->method !== null) {
327327
$method = $this->reflect->getMethod($this->method);
328328
if ($method->isConstructor()) {
329329
return $this->getClass();
@@ -333,7 +333,7 @@ public function get(): mixed
333333
}
334334
$inst = $this->reflect->newInstanceWithoutConstructor();
335335

336-
if (!is_null($this->args)) {
336+
if ($this->args !== null) {
337337
return $method->invokeArgs($inst, $this->args);
338338
} else {
339339
return $method->invoke($inst);
@@ -354,7 +354,7 @@ public static function getClassList(): array
354354
*/
355355
private function getClass(): object
356356
{
357-
if (!is_null($this->args)) {
357+
if ($this->args !== null) {
358358
$inst = $this->reflect->newInstanceArgs($this->args);
359359
} else {
360360
$inst = $this->dependencyInjector();

0 commit comments

Comments
 (0)