asmblah / uniter

🎉 PHP in the browser and Node.js => Docs: https://phptojs.com/
https://asmblah.github.io/uniter/
Other
446 stars 42 forks source link

include_once: Not resolved #29

Open IngwiePhoenix opened 8 years ago

IngwiePhoenix commented 8 years ago

include_once is resolved as a regular function.

Ingwie@Ingwies-Macbook-Pro.local /tmp $ nano test.php
Ingwie@Ingwies-Macbook-Pro.local /tmp $ cat test.php
<?php
include_once "foo.php";
Ingwie@Ingwies-Macbook-Pro.local /tmp $ uniter2ast test.php 

/Users/Ingwie/Work/uniter/uniter-tools/node_modules/phptoast/src/ErrorHandler.js:43
        throw error;
        ^
Error: PHP Parse error: syntax error, unexpected '"' in (program) on line 2
Ingwie@Ingwies-Macbook-Pro.local /tmp $ nano test.php
Ingwie@Ingwies-Macbook-Pro.local /tmp $ cat test.php
<?php
# Changed to "normal" function call:
include_once("foo.php");
Ingwie@Ingwies-Macbook-Pro.local /tmp $ uniter2ast test.php 
{
    "statements": [
        {
            "expression": {
                "func": {
                    "string": "include_once",
                    "name": "N_STRING"
                },
                "args": [
                    {
                        "string": "foo.php",
                        "name": "N_STRING_LITERAL"
                    }
                ],
                "name": "N_FUNCTION_CALL"
            },
            "name": "N_EXPRESSION_STATEMENT"
        }
    ],
    "name": "N_PROGRAM"
}

This should explain itself. :)