Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
isDefaultValueConstant example
if
(
isset
(
$a
[
$prefix
.'typeHint'
]
)
)
{
$v
=
$a
[
$prefix
.'typeHint'
]
;
$a
[
$prefix
.'typeHint'
]
=
new
ClassStub
(
$v
,
[
class_exists
(
$v
, false
)
||
interface_exists
(
$v
, false
)
||
trait_exists
(
$v
, false
)
?
$v
: '', ''
]
)
;
}
else
{
unset
(
$a
[
$prefix
.'allowsNull'
]
)
;
}
if
(
$c
->
isOptional
(
)
)
{
try
{
$a
[
$prefix
.'default'
]
=
$v
=
$c
->
getDefaultValue
(
)
;
if
(
$c
->
isDefaultValueConstant
(
)
&& !\
is_object
(
$v
)
)
{
$a
[
$prefix
.'default'
]
=
new
ConstStub
(
$c
->
getDefaultValueConstantName
(
)
,
$v
)
;
}
if
(
null ===
$v
)
{
unset
(
$a
[
$prefix
.'allowsNull'
]
)
;
}
}
catch
(
\ReflectionException
)
{
}
}
return
$a
;
}
$r
->
getConstants
(
)
;
$r
->
getDefaultProperties
(
)
;
foreach
(
$r
->
getProperties
(
\ReflectionProperty::IS_PUBLIC
)
as
$p
)
{
self::
preloadType
(
$p
->
getType
(
)
,
$preloaded
)
;
}
foreach
(
$r
->
getMethods
(
\ReflectionMethod::IS_PUBLIC
)
as
$m
)
{
foreach
(
$m
->
getParameters
(
)
as
$p
)
{
if
(
$p
->
isDefaultValueAvailable
(
)
&&
$p
->
isDefaultValueConstant
(
)
)
{
$c
=
$p
->
getDefaultValueConstantName
(
)
;
if
(
$i
=
strpos
(
$c
, '::'
)
)
{
self::
doPreload
(
substr
(
$c
, 0,
$i
)
,
$preloaded
)
;
}
}
self::
preloadType
(
$p
->
getType
(
)
,
$preloaded
)
;
}
self::
preloadType
(
$m
->
getReturnType
(
)
,
$preloaded
)
;
}
$r
->
getConstants
(
)
;
$r
->
getDefaultProperties
(
)
;
foreach
(
$r
->
getProperties
(
\ReflectionProperty::IS_PUBLIC
)
as
$p
)
{
self::
preloadType
(
$p
->
getType
(
)
,
$preloaded
)
;
}
foreach
(
$r
->
getMethods
(
\ReflectionMethod::IS_PUBLIC
)
as
$m
)
{
foreach
(
$m
->
getParameters
(
)
as
$p
)
{
if
(
$p
->
isDefaultValueAvailable
(
)
&&
$p
->
isDefaultValueConstant
(
)
)
{
$c
=
$p
->
getDefaultValueConstantName
(
)
;
if
(
$i
=
strpos
(
$c
, '::'
)
)
{
self::
doPreload
(
substr
(
$c
, 0,
$i
)
,
$preloaded
)
;
}
}
self::
preloadType
(
$p
->
getType
(
)
,
$preloaded
)
;
}
self::
preloadType
(
$m
->
getReturnType
(
)
,
$preloaded
)
;
}
if
(
isset
(
$a
[
$prefix
.'typeHint'
]
)
)
{
$v
=
$a
[
$prefix
.'typeHint'
]
;
$a
[
$prefix
.'typeHint'
]
=
new
ClassStub
(
$v
,
[
class_exists
(
$v
, false
)
||
interface_exists
(
$v
, false
)
||
trait_exists
(
$v
, false
)
?
$v
: '', ''
]
)
;
}
else
{
unset
(
$a
[
$prefix
.'allowsNull'
]
)
;
}
if
(
$c
->
isOptional
(
)
)
{
try
{
$a
[
$prefix
.'default'
]
=
$v
=
$c
->
getDefaultValue
(
)
;
if
(
$c
->
isDefaultValueConstant
(
)
&& !\
is_object
(
$v
)
)
{
$a
[
$prefix
.'default'
]
=
new
ConstStub
(
$c
->
getDefaultValueConstantName
(
)
,
$v
)
;
}
if
(
null ===
$v
)
{
unset
(
$a
[
$prefix
.'allowsNull'
]
)
;
}
}
catch
(
\ReflectionException
)
{
}
}
return
$a
;
}