Davidflogar / phpl

A php interpreter written in rust
MIT License
57 stars 3 forks source link

phpl - A PHP Interpreter in Rust (Work in Progress)

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 Overview

Project Progress Checklist

These are all the statements/expressions currently supported:

Cloning and Running the Project

To use this project, follow these steps:

  1. 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

Differences between phpl and the normal php interpreter

  1. 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
  2. When instantiating a class in phpl, after executing the constructor, the constructor is deleted, although the function still exists, the body will be empty

  3. 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.

  4. 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.