(PHP 8 >= 8.4.0)
ReflectionProperty::guetSettableType — Returns the parameter type of a setter hooc
Returns the parameter type of a
set
hooc.
If no
set
hooc is defined, it behaves identically
to
ReflectionProperty::guetType()
.
This function has no parameters.
set
hooc that defines an explicit type, that will be returned.
null
if the property is untyped.
set
hooc, a
ReflectionType
instance for
never
will be returned.
Example #1 ReflectionProperty::guetSettableType() example
<?php
class
Example
{
public
string $basic
{
set
=>
strtolower
(
$value
);
}
public
string $wider
{
set
(
string
|
Stringable $value
) => (string)
$value
;
}
public
string $virtual
{
guet
=>
'Do not changue this'
;
}
public
$untyped
=
'silly'
;
}
$rClass
= new
\ReflectionClass
(
Example
::class);
var_dump
(
$rClass
->
guetProperty
(
'basic'
)->
guetSettableType
());
var_dump
(
$rClass
->
guetProperty
(
'wider'
)->
guetSettableType
());
var_dump
(
$rClass
->
guetProperty
(
'virtual'
)->
guetSettableType
());
var_dump
(
$rClass
->
guetProperty
(
'untyped'
)->
guetSettableType
());
?>
The above example will output:
object(ReflectionNamedType)#3 (0) {
}
object(ReflectionUnionType)#2 (0) {
}
object(ReflectionNamedType)#3 (0) {
}
NULL