Skip to content

Commit

Permalink
Tini-tiny fix of "__isset" sub-supplying to the external framework wh…
Browse files Browse the repository at this point in the history
…en is not available in local functionality.

Basically normalizing in the same row with "__set" and "__get" methods.
  • Loading branch information
PandaHugMonster committed Feb 14, 2022
1 parent b9a317f commit 8f76bef
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/traits/PropertiesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use spaf\simputils\exceptions\PropertyAccessError;
use spaf\simputils\exceptions\PropertyDoesNotExist;
use spaf\simputils\special\PropertiesCacheIndex;
use function get_parent_class;
use function in_array;

/**
Expand Down Expand Up @@ -97,15 +98,26 @@ public function __set($name, $value): void {
}

public function __isset($name) {
return $this->____checkSimpUtilsPropertyAvailability($name);
}

private function ____checkSimpUtilsPropertyAvailability($name, $type = Property::TYPE_GET) {
$type = Property::TYPE_GET;
$ref = static::class.'#'.$name.'#'.$type;
if ($method_name = PropertiesCacheIndex::$index[$ref] ?? false) {
return $this->$method_name(null, $type, $name);
}
return $this->____prepareProperty($name, $type, check_and_do_not_call: true);
$res = $this->____prepareProperty($name, $type, check_and_do_not_call: true);

if (!$res) {
try {
/** @noinspection PhpUndefinedMethodInspection */
if (get_parent_class()) {
$res = parent::__isset($name);
}
} catch (Error $e) {
/** @noinspection PhpUnhandledExceptionInspection */
throw $e;
}
}

return $res;
}

private function ____propertyBatchMethodGet($value, $type, $name): mixed {
Expand Down

0 comments on commit 8f76bef

Please sign in to comment.