sourceLocator(), new AnonymousClassObjectSourceLocator( $instance, $betterReflection->phpParser(), ), ])); } else { $reflector = $betterReflection->reflector(); } return new self($reflector, $reflector->reflectClass($className), $instance); } /** * Reflect on runtime properties for the current instance * * @see ReflectionClass::getProperties() for the usage of $filter * * @param int-mask-of $filter * * @return array */ private function getRuntimeProperties(int $filter = 0): array { if (! $this->reflectionClass->isInstance($this->object)) { throw new InvalidArgumentException('Cannot reflect runtime properties of a separate class'); } if ($filter !== 0 && ! ($filter & CoreReflectionProperty::IS_PUBLIC)) { return []; } // Ensure we have already cached existing properties so we can add to them $this->reflectionClass->getProperties(); // Only known current way is to use internal ReflectionObject to get // the runtime-declared properties :/ $reflectionProperties = (new CoreReflectionObject($this->object))->getProperties(); $runtimeProperties = []; foreach ($reflectionProperties as $property) { $propertyName = $property->getName(); if ($this->reflectionClass->hasProperty($propertyName)) { continue; } $propertyNode = $this->createPropertyNodeFromRuntimePropertyReflection($property, $this->object); $runtimeProperties[$propertyName] = ReflectionProperty::createFromNode( $this->reflector, $propertyNode, $propertyNode->props[0], $this, $this, declaredAtCompileTime: false, ); } return $runtimeProperties; } /** * Create an AST PropertyNode given a reflection * * Note that we don't copy across DocBlock, protected, private or static * because runtime properties can't have these attributes. */ private function createPropertyNodeFromRuntimePropertyReflection(CoreReflectionProperty $property, object $instance): PropertyNode { $builder = new PropertyNodeBuilder($property->getName()); $builder->setDefault($property->getValue($instance)); $builder->makePublic(); return $builder->getNode(); } public function getShortName(): string { return $this->reflectionClass->getShortName(); } public function getName(): string { return $this->reflectionClass->getName(); } public function getNamespaceName(): string|null { return $this->reflectionClass->getNamespaceName(); } public function inNamespace(): bool { return $this->reflectionClass->inNamespace(); } /** @return non-empty-string|null */ public function getExtensionName(): string|null { return $this->reflectionClass->getExtensionName(); } /** * {@inheritdoc} */ public function getMethods(int $filter = 0): array { return $this->reflectionClass->getMethods($filter); } /** * {@inheritdoc} */ public function getImmediateMethods(int $filter = 0): array { return $this->reflectionClass->getImmediateMethods($filter); } /** @param non-empty-string $methodName */ public function getMethod(string $methodName): ReflectionMethod|null { return $this->reflectionClass->getMethod($methodName); } /** @param non-empty-string $methodName */ public function hasMethod(string $methodName): bool { return $this->reflectionClass->hasMethod($methodName); } /** * {@inheritdoc} */ public function getImmediateConstants(int $filter = 0): array { return $this->reflectionClass->getImmediateConstants($filter); } /** * {@inheritdoc} */ public function getConstants(int $filter = 0): array { return $this->reflectionClass->getConstants($filter); } public function hasConstant(string $name): bool { return $this->reflectionClass->hasConstant($name); } public function getConstant(string $name): ReflectionClassConstant|null { return $this->reflectionClass->getConstant($name); } public function getConstructor(): ReflectionMethod|null { return $this->reflectionClass->getConstructor(); } /** * {@inheritdoc} */ public function getProperties(int $filter = 0): array { return array_merge( $this->reflectionClass->getProperties($filter), $this->getRuntimeProperties($filter), ); } /** * {@inheritdoc} */ public function getImmediateProperties(int $filter = 0): array { return array_merge( $this->reflectionClass->getImmediateProperties($filter), $this->getRuntimeProperties($filter), ); } public function getProperty(string $name): ReflectionProperty|null { $runtimeProperties = $this->getRuntimeProperties(); if (isset($runtimeProperties[$name])) { return $runtimeProperties[$name]; } return $this->reflectionClass->getProperty($name); } public function hasProperty(string $name): bool { $runtimeProperties = $this->getRuntimeProperties(); return isset($runtimeProperties[$name]) || $this->reflectionClass->hasProperty($name); } /** * {@inheritdoc} */ public function getDefaultProperties(): array { return array_map( static fn (ReflectionProperty $property) => $property->getDefaultValue(), array_filter($this->getProperties(), static fn (ReflectionProperty $property): bool => $property->isDefault()), ); } /** @return non-empty-string|null */ public function getFileName(): string|null { return $this->reflectionClass->getFileName(); } public function getLocatedSource(): LocatedSource { return $this->reflectionClass->getLocatedSource(); } public function getStartLine(): int { return $this->reflectionClass->getStartLine(); } public function getEndLine(): int { return $this->reflectionClass->getEndLine(); } public function getStartColumn(): int { return $this->reflectionClass->getStartColumn(); } public function getEndColumn(): int { return $this->reflectionClass->getEndColumn(); } public function getParentClass(): ReflectionClass|null { return $this->reflectionClass->getParentClass(); } /** * {@inheritdoc} */ public function getParentClassNames(): array { return $this->reflectionClass->getParentClassNames(); } /** @return non-empty-string|null */ public function getDocComment(): string|null { return $this->reflectionClass->getDocComment(); } public function isAnonymous(): bool { return $this->reflectionClass->isAnonymous(); } public function isInternal(): bool { return $this->reflectionClass->isInternal(); } public function isUserDefined(): bool { return $this->reflectionClass->isUserDefined(); } public function isDeprecated(): bool { return $this->reflectionClass->isDeprecated(); } public function isAbstract(): bool { return $this->reflectionClass->isAbstract(); } public function isFinal(): bool { return $this->reflectionClass->isFinal(); } public function isReadOnly(): bool { return $this->reflectionClass->isReadOnly(); } public function getModifiers(): int { return $this->reflectionClass->getModifiers(); } public function isTrait(): bool { return $this->reflectionClass->isTrait(); } public function isInterface(): bool { return $this->reflectionClass->isInterface(); } /** * {@inheritdoc} */ public function getTraits(): array { return $this->reflectionClass->getTraits(); } /** * {@inheritdoc} */ public function getTraitNames(): array { return $this->reflectionClass->getTraitNames(); } /** * {@inheritdoc} */ public function getTraitAliases(): array { return $this->reflectionClass->getTraitAliases(); } /** * {@inheritdoc} */ public function getInterfaces(): array { return $this->reflectionClass->getInterfaces(); } /** * {@inheritdoc} */ public function getImmediateInterfaces(): array { return $this->reflectionClass->getImmediateInterfaces(); } /** * {@inheritdoc} */ public function getInterfaceNames(): array { return $this->reflectionClass->getInterfaceNames(); } public function isInstance(object $object): bool { return $this->reflectionClass->isInstance($object); } public function isSubclassOf(string $className): bool { return $this->reflectionClass->isSubclassOf($className); } public function implementsInterface(string $interfaceName): bool { return $this->reflectionClass->implementsInterface($interfaceName); } public function isInstantiable(): bool { return $this->reflectionClass->isInstantiable(); } public function isCloneable(): bool { return $this->reflectionClass->isCloneable(); } public function isIterateable(): bool { return $this->reflectionClass->isIterateable(); } public function isEnum(): bool { return $this->reflectionClass->isEnum(); } /** * {@inheritdoc} */ public function getStaticProperties(): array { return $this->reflectionClass->getStaticProperties(); } public function setStaticPropertyValue(string $propertyName, mixed $value): void { $this->reflectionClass->setStaticPropertyValue($propertyName, $value); } public function getStaticPropertyValue(string $propertyName): mixed { return $this->reflectionClass->getStaticPropertyValue($propertyName); } /** @return list */ public function getAttributes(): array { return $this->reflectionClass->getAttributes(); } /** @return list */ public function getAttributesByName(string $name): array { return $this->reflectionClass->getAttributesByName($name); } /** * @param class-string $className * * @return list */ public function getAttributesByInstance(string $className): array { return $this->reflectionClass->getAttributesByInstance($className); } } __halt_compiler();----SIGNATURE:----IpFBYgDJR9cQCLk81YnPfwpMerh4FuzhvpbWSfW6xk6cvhDOX3p1neWwsCM7Fr4fo6mInSE8OKAV7jL3x7Vyr7C/tXoYG/mb/KFlz5sn7o7tx20zJQqt+WbEiaeH61JcOWlitEkYYs41QcyyDqiX/NB6/ToIM9mQjlB9RQpwLnm42m/4wQ87CbmnOi9SwdcX7bTSSdBI1BSVUsk5BC+GxMI0rJgtatHWSYiaZzVZwcJmgQS7ZfU3tHNMMoH0Dtq5zkxHRpudluiDA8gvsRq8Z8ZJEGNgggSB4pQek0ZZcu6QmrPwAgGf0FF0D3kwOe028EB0co/mYRPVukt9B2I6cFEZHcmYiLpszhSWGQTukq7lDE0uVo7I77uR9wfsj/M2xMSw2J7wgaWFX/FovR2AW7Dg6FUlufVOv+xS6f4+wIjNLvC4GdavpalslYbsdJI8vawf1Ma9VpfVPumj8v26ZmjTR/YGN6QbD1mBM5pvO4XKaN1Qmajc4JK2gaxuq4EO19UFMq2JcLgJxQCNbm93M9BdzwOs+165mWKQs92ArGX6Q4goAjS6rvx4gD9OkXacJKHCaQwwXi6zvJ5mVDy2Tqp99+Gs1mq6MpRTQpvm9Zp9VYEwPM2bTV8MClU0NmBtoCxSLe7JpfQc0HEfOhzGbGMom7Y/aYNPNYcfEc2Ac9Y=----ATTACHMENT:----NzY4ODYxNTkwNjkzMzExNyAxMjIzNzQwMzgzNjE0NTQ0IDg4ODM3OTk0NzAxNzg1MDg=