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:----VuDVR5rWQR/AjkwpnBF+KotAwU/6nvnZHwLGLKx7mgqCGCSpYQ6GzQ7ZrxHLt2UvvL6EJxkB679Dq4NoBMUUCTsGC6Nnrwa7Pz64uFrmG5rN9TVkEIGyfzRGErKyDXlVt9wgnnkiosfcLsKJWvJbRflmBsxrZk0mhbd9hof5QDRz9Djz5D2qLWBm2Ukqc1hu6VY7RkVzmg5eSUXSvTi4vRcvktg3vN27cnk/hDvedsKhnfYEtrLmwInZUFTOssvDvV1y+Ge/29vNoxPqX8cb7WpY/T9igDwfjQpzgVI+ONqwmFars+vh7Oxp/vqQsP3+HRcDTp0XTMa3KNNYEfKIdKxTEkzLtILDjixiQ7+18zfUiatcA5ifpYmj0XBoY/hfE3bMEtFHlo/H2g3eu6KXGvAyzfDULkh9b0jpznRXSotV9Kd4D+c092PZQB90LLWrlK6vPmGcveR2hF0SsyQNVFyK58VBxwL/RAU1KbOiBzEXax1ouVZPkKhrHTZolpnYHluZvx+RX32ppAQ87G3i46G2dWxH71W9UnCrwKBMyMYVyEB3f8Sg+xa0rRbYp8qnOCQQvxwxLtM64eke2J1tmL5KThzFrtxtY2jBDpQd6V4y1f++aoBWMJTJm2TwvTrt2Fci92boUxgQIh8ySK1xdaHtDfhBW0JnR1wtcsm/aMY=----ATTACHMENT:----NzM5NTQ5NDk2Nzg1NzI5NCAyMTkwMzgwNDA1OTEzMjA2IDUyNTA5OTU4MTYyOTg2MTU=