_getClassProperties(get_class($object)), static fn($p) => $p->getName() === $property ); if (count($properties) !== 1) { return null; } return current($properties); } /** * @return ReflectionProperty[] * @throws ReflectionException */ private function _getClassProperties($class): array { return (new ReflectionClass($class))->getProperties(); } }