Skip to main content

PHPExpr

Enum PHPExpr 

Source
pub enum PHPExpr {
Show 22 variants Lit(String), Var(String), BinOp(Box<PHPExpr>, String, Box<PHPExpr>), UnaryOp(String, Box<PHPExpr>), FuncCall(String, Vec<PHPExpr>), ArrayLit(Vec<PHPExpr>), ArrayMap(Vec<(PHPExpr, PHPExpr)>), New(String, Vec<PHPExpr>), Arrow(Box<PHPExpr>, String), NullSafe(Box<PHPExpr>, String), StaticAccess(String, String), Index(Box<PHPExpr>, Box<PHPExpr>), Ternary(Box<PHPExpr>, Box<PHPExpr>, Box<PHPExpr>), NullCoalesce(Box<PHPExpr>, Box<PHPExpr>), Closure { params: Vec<PHPParam>, use_vars: Vec<String>, return_type: Option<PHPType>, body: Vec<String>, }, ArrowFn { params: Vec<PHPParam>, return_type: Option<PHPType>, body: Box<PHPExpr>, }, Match { subject: Box<PHPExpr>, arms: Vec<(PHPExpr, PHPExpr)>, default: Option<Box<PHPExpr>>, }, NamedArg(String, Box<PHPExpr>), Spread(Box<PHPExpr>), Cast(String, Box<PHPExpr>), Isset(Box<PHPExpr>), Empty(Box<PHPExpr>),
}
Expand description

PHP expression AST node.

Variants§

§

Lit(String)

Literal value (int, float, string, bool, null)

§

Var(String)

Variable reference: $name

§

BinOp(Box<PHPExpr>, String, Box<PHPExpr>)

Binary operation: lhs op rhs

§

UnaryOp(String, Box<PHPExpr>)

Unary operation: op operand

§

FuncCall(String, Vec<PHPExpr>)

Function/method call: name(args...)

§

ArrayLit(Vec<PHPExpr>)

Array literal: [expr, ...]

§

ArrayMap(Vec<(PHPExpr, PHPExpr)>)

Associative array literal: [key => val, ...]

§

New(String, Vec<PHPExpr>)

Object instantiation: new ClassName(args...)

§

Arrow(Box<PHPExpr>, String)

Property access: $obj->prop

§

NullSafe(Box<PHPExpr>, String)

Null-safe property access: $obj?->prop

§

StaticAccess(String, String)

Static property/method access: Class::member

§

Index(Box<PHPExpr>, Box<PHPExpr>)

Array index: $arr[idx]

§

Ternary(Box<PHPExpr>, Box<PHPExpr>, Box<PHPExpr>)

Ternary: $cond ? $then : $else

§

NullCoalesce(Box<PHPExpr>, Box<PHPExpr>)

Null coalescing: $a ?? $b

§

Closure

Closure / anonymous function

Fields

§params: Vec<PHPParam>
§use_vars: Vec<String>
§return_type: Option<PHPType>
§body: Vec<String>
§

ArrowFn

Arrow function (PHP 7.4+): fn($x) => expr

Fields

§params: Vec<PHPParam>
§return_type: Option<PHPType>
§body: Box<PHPExpr>
§

Match

Match expression (PHP 8.0+)

Fields

§subject: Box<PHPExpr>
§default: Option<Box<PHPExpr>>
§

NamedArg(String, Box<PHPExpr>)

Named argument: name: value

§

Spread(Box<PHPExpr>)

Spread operator: ...$arr

§

Cast(String, Box<PHPExpr>)

Cast: (type)$expr

§

Isset(Box<PHPExpr>)

isset($var)

§

Empty(Box<PHPExpr>)

empty($var)

Trait Implementations§

Source§

impl Clone for PHPExpr

Source§

fn clone(&self) -> PHPExpr

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PHPExpr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for PHPExpr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PHPExpr

Source§

fn eq(&self, other: &PHPExpr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for PHPExpr

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.