phpl is an ongoing project aimed at developing a PHP interpreter in Rust. Please note that this project is in its early stages and cannot currently execute complete PHP files.
- Project Status: Work in Progress
- Current Capabilities: Can parse and evaluate simple PHP expressions and statements.
- Language Compatibility: Supports a subset of PHP features.
These are all the statements/expressions currently supported:
- FullOpeningTag
- ShortOpeningTag
- EchoOpeningTag
- ClosingTag
- InlineHtml
- Label
- Goto
- HaltCompiler
- Static
- DoWhile
- While
- For
- Foreach
- Break
- Continue
- Constant
- Function
- Class
- Trait
- Interface
- If
- Switch
- Echo
- Expression
- Eval
- Empty
- Die
- Exit
- Isset
- Unset
- Literal
- ArithmeticOperation
- AssignmentOperation
- BitwiseOperation
- ComparisonOperation
- LogicalOperation
- Concat
- Instanceof
- Reference
- Parenthesized
- ErrorSuppress
- Identifier
- Variable
- Include
- IncludeOnce
- Require
- RequireOnce
- FunctionCall
- FunctionClosureCreation
- MethodCall
- MethodClosureCreation
- NullsafeMethodCall
- StaticMethodCall
- StaticVariableMethodCall
- StaticMethodClosureCreation
- StaticVariableMethodClosureCreation
- PropertyFetch
- NullsafePropertyFetch
- StaticPropertyFetch
- ConstantFetch
- Static
- Self_
- Parent
- ShortArray
- Array
- List
- Closure
- ArrowFunction
- New
- InterpolatedString
- Heredoc
- Nowdoc
- ShellExec
- AnonymousClass
- Bool
- ArrayIndex
- Null
- MagicConstant
- ShortTernary
- Ternary
- Coalesce
- Clone
- Match
- Throw
- Yield
- YieldFrom
- Cast
- Noop
- Return
- Namespace
- Use
- GroupUse
- Comment
- Try
- UnitEnum
- BackedEnum
- Block
- Global
- Declare
- Noop
To use this project, follow these steps:
-
Clone the Repository: Begin by cloning the repository from the Git repository using the following command:
git clone https://github.com/Davidflogar/phpl cd phpl cargo r file.php # or you can build the project
-
Declaring variables does not return any value. Example in normal php:
$b = $a = 1; // $b is 1
Example in phpl:
$b = $a = 1; // $b is null
-
When instantiating a class in phpl, after executing the constructor, the constructor is deleted, although the function still exists, the body will be empty
-
PHPL will not attempt to convert a parameter to the correct data type when passed to a function. For example: if a function receives an integer, the data type of the passed parameter must be an integer and no attempt will be made to convert the parameter to an integer. That's how it is with all data types.
-
When using promoted properties, the variable will be a reference to the property of that same object:
class A { public function __construct(public mixed $a) { // here $a is the same as $this->a, so any change to one of the two variables will be reflected in the other } }
There are still some undocumented differences, so this list will expand over time.