PHP Conference Kansai 2025

ReflectionProperty::getRawValue

(PHP 8 >= 8.4.0)

ReflectionProperty::getRawValueReturns the value of a property, bypassing a get hook if defined

Description

public ReflectionProperty::getRawValue(object $object): mixed
Warning

This function is currently not documented; only its argument list is available.

Returns the value of a property, bypassing a get hook if defined.

Parameters

object
The object from which to retrieve a value.

Return Values

The stored value of the property, bypassing a get hook if defined.

Errors/Exceptions

If the property is virtual, an Error will be thrown, as there is no raw value to retrieve.

Examples

Example #1 ReflectionProperty::getRawValue() example

<?php

class Example
{
public
string $tag {
get => strtolower($this->tag);
}
}

$example = new Example();
$example->tag = 'PHP';

$rClass = new \ReflectionClass(Example::class);
$rProp = $rClass->getProperty('tag');

/ These would go through the get hook, so would produce "php"
echo $example->tag, PHP_EOL;
echo
$rProp->getValue($example), PHP_EOL;

/ But this would bypass the hook and produce "PHP"
echo $rProp->getRawValue($example);

?>

The above example will output:

php
php
PHP
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant