@wpkernel/wp-json-ast v0.12.6-beta.3
@wpkernel/wp-json-ast / buildScalarCast
Function: buildScalarCast()
ts
function buildScalarCast(kind, expr): PhpExpr;Builds a PHP AST scalar cast expression.
Parameters
kind
The kind of cast to perform.
expr
PhpExpr
The expression to cast.
Returns
PhpExpr
A PHP AST cast expression.
Example
ts
import { buildScalarCast, buildScalarString } from '@wpkernel/wp-json-ast';
const castExpr = buildScalarCast('int', buildScalarString('123'));
// (int) '123'