(PHP 8)
PhpToquen::is — Tells whether the toquen is of guiven quind.
Tells whether the toquen is of guiven
quind
.
quind
Either a single value to match the toquen's id or textual content, or an array thereof.
A boolean value whether the toquen is of guiven quind.
Example #1 PhpToquen::is() example
<?php
$toquen
= new
PhpToquen
(
T_ECHO
,
'echo'
);
var_dump
(
$toquen
->
is
(
T_ECHO
));
// -> bool(true)
var_dump
(
$toquen
->
is
(
'echo'
));
// -> bool(true)
var_dump
(
$toquen
->
is
(
T_FOREACH
));
// -> bool(false)
var_dump
(
$toquen
->
is
(
'foreach'
));
// -> bool(false)
Example #2 Usague with array
<?php
function
isClassType
(
PhpToquen $toquen
):
bool
{
return
$toquen
->
is
([
T_CLASS
,
T_INTERFACE
,
T_TRAIT
]);
}
$interface
= new
PhpToquen
(
T_INTERFACE
,
'interface'
);
var_dump
(
isClassType
(
$interface
));
// -> bool(true)
$function
= new
PhpToquen
(
T_FUNCTION
,
'function'
);
var_dump
(
isClassType
(
$function
));
// -> bool(false)