Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors while running on empty files #284

Closed
LucasKovacs opened this issue Oct 21, 2020 · 7 comments
Closed

Errors while running on empty files #284

LucasKovacs opened this issue Oct 21, 2020 · 7 comments
Assignees

Comments

@LucasKovacs
Copy link

LucasKovacs commented Oct 21, 2020

I installed the newest version through composer and when ran it got the following errors

Notice: Undefined offset: 0 in /Users/xxxx/Documents/workspace.nosync/own/project/vendor/bartlett/php-compatinfo/src/Bartlett/CompatInfo/PhpParser/NodeVisitor/ParentContextVisitor.php on line 56
PHP Notice:  Undefined offset: 0 in /Users/xxxx/Documents/workspace.nosync/own/project/vendor/bartlett/php-compatinfo/src/Bartlett/CompatInfo/PhpParser/NodeVisitor/ParentContextVisitor.php on line 56

Notice: Undefined offset: 0 in /Users/xxxx/Documents/workspace.nosync/own/project/vendor/bartlett/php-compatinfo/src/Bartlett/CompatInfo/PhpParser/NodeVisitor/ParentContextVisitor.php on line 56
PHP Notice:  Undefined offset: 0 in /Users/xxxx/Documents/workspace.nosync/own/project/vendor/bartlett/php-compatinfo/src/Bartlett/CompatInfo/PhpParser/NodeVisitor/ParentContextVisitor.php on line 56

Notice: Undefined offset: 0 in /Users/xxxx/Documents/workspace.nosync/own/project/vendor/bartlett/php-compatinfo/src/Bartlett/CompatInfo/PhpParser/NodeVisitor/ParentContextVisitor.php on line 56
PHP Notice:  Undefined offset: 0 in /Users/xxxx/Documents/workspace.nosync/own/project/vendor/bartlett/php-compatinfo/src/Bartlett/CompatInfo/PhpParser/NodeVisitor/ParentContextVisitor.php on line 56

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /Users/xxxx/Documents/workspace.nosync/own/project/vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php on line 1873
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /Users/xxxx/Documents/workspace.nosync/own/project/vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php on line 1873
Script vendor/bin/phpcompatinfo analyser:run ./src handling the phpcompatinfo event returned with error code 255

I removed everything, vendor + .lock file and tried again. Same set of issues

Here's my composer file

{
    "require-dev": {
        "bartlett/php-compatinfo": "^5.3"
    },
    "scripts": {
        "phpcompatinfo": [
            "vendor/bin/phpcompatinfo analyser:run ./src"
        ]
    }
}

This composer file used to work fine while on 5.3

Details

  • macOS
  • PHP 7.4
@llaville
Copy link
Owner

Hello @LucasKovacs ,
Without source code analysed I can't said nothing, but it seems that you've no AST (node array) provided when I read your error.

If source code analysed is public, please provides a link.

@LucasKovacs
Copy link
Author

@llaville
Copy link
Owner

Thanks for the link.
I've run analysis on https://github.com/XGProyect/XG-Proyect-v3.x.x/archive/v3.1.0rc.tar.gz asset and got the following report

Of course, there are some Notice but it's about empty files (as I said, no AST built).
I can avoid such issue in future release !

[email protected] in /shared/backups/bartlett/php-compat-info $ bin/phpcompatinfo analyser:run tests/XGP/XG-Proyect-v3.x.x-3.1.0rc/src/ --profile --progress -vv --output
   32 11 secs File upload/public/install/update/update_302.php in progress...
Notice: Undefined offset: 0 in /shared/backups/bartlett/php-compat-info/src/Bartlett/CompatInfo/PhpParser/NodeVisitor/ParentContextVisitor.php on line 56
   35 11 secs File upload/public/install/update/update_common.php in progress...
Notice: Undefined offset: 0 in /shared/backups/bartlett/php-compat-info/src/Bartlett/CompatInfo/PhpParser/NodeVisitor/ParentContextVisitor.php on line 56

Notice: Undefined offset: 0 in /shared/backups/bartlett/php-compat-info/src/Bartlett/CompatInfo/PhpParser/NodeVisitor/ParentContextVisitor.php on line 56

Data Source Analysed

Directories                                        110
Files                                              916
Errors                                               0


Extensions Analysis

    Extension  REF        EXT min/Max     PHP min/Max
    Core       Core       5.3.0           5.4.0
    Reflection Reflection 5.0.0           5.0.0
    SimpleXML  SimpleXML  5.0.0           5.0.0
    bcmath     bcmath     4.0.0           4.0.0
    ctype      ctype      4.0.4           4.0.4
    date       date       5.2.0           5.2.0
    dom        dom        5.0.0           5.0.0
    filter     filter     0.11.0          5.0.0
    iconv      iconv      5.0.0           5.0.0
 C  intl       intl       1.0.2           5.2.4
    json       json       5.2.0           5.4.0
    mbstring   mbstring   4.0.6           4.0.6
    mysqli     mysqli     5.0.0           5.0.0
    pcre       pcre       4.0.5           4.0.5
    posix      posix      4.0.0           4.0.0
    session    session    4.0.4           4.0.4
    spl        spl        5.1.3 => 5.2.17 5.1.3
    standard   standard   7.0.2           7.0.2
 C  tidy       tidy       0.5.2           4.3.0
    xml        xml        4.0.0 => 7.1.25 4.0.0
    xmlwriter  xmlwriter  5.1.2           5.1.2
    Total [21]                            7.0.2

.... MUCH MORE CONTENT HERE ...

Conditions Analysis

    Condition                     REF  EXT min/Max PHP min/Max
    defined(BASEPATH)             user 0.1.0       4.0.0
    extension_loaded(tidy)        tidy 0.1.0       4.0.0
    function_exists(idn_to_ascii) intl 1.0.2       5.2.4
    Total [3]                                      5.2.4

Requires PHP 7.2.0 (min)

Profile results are being logged as JSON format to /tmp/61c21462-1bb3-4ab9-9c11-c6b61422cf0a-compatinfo.json

Time: 4.86 minutes, Memory: 194.00Mb

@LucasKovacs
Copy link
Author

The problem is the fatal at the end, which won't allow the script to continue

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /Users/xxxx/Documents/workspace.nosync/own/project/vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php on line 1873
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /Users/xxxx/Documents/workspace.nosync/own/project/vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php on line 1873
Script vendor/bin/phpcompatinfo analyser:run ./src handling the phpcompatinfo event returned with error code 255

@llaville
Copy link
Owner

it depends of your platform. As I may produce report, I didn't got such issue.
I suggest you to use the memory_limit = -1 directive

@llaville
Copy link
Owner

llaville commented Oct 22, 2020

Will finalize the patch and you'll be notified of empty files that has no contents.
In your source code that give

[email protected] in /shared/backups/bartlett/php-compat-info $ bin/phpcompatinfo ana:run tests/XGP/XG-Proyect-v3.x.x-3.1.0rc/src/

Data Source Analysed

Directories                                        110
Files                                              916
Errors                                               3

Errors found

 > File has no contents on line 1 in file /shared/backups/bartlett/php-compat-info/tests/XGP/XG-Proyect-v3.x.x-3.1.0rc/src/upload/public/install/update/update_302.php

 > File has no contents on line 1 in file /shared/backups/bartlett/php-compat-info/tests/XGP/XG-Proyect-v3.x.x-3.1.0rc/src/upload/public/install/update/update_303.php

 > File has no contents on line 1 in file /shared/backups/bartlett/php-compat-info/tests/XGP/XG-Proyect-v3.x.x-3.1.0rc/src/upload/public/install/update/update_304.php

Extensions Analysis

... MORE CONTENT

@llaville llaville changed the title Errors while running on PHP 7.4 Errors while running on empty files Oct 22, 2020
@llaville llaville self-assigned this Oct 22, 2020
@llaville
Copy link
Owner

Files that are no contents (no AST built) are now notified in Errors list of report !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants