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

PHP 7.1 Nullable types not being detected #273

Closed
LucasKovacs opened this issue Aug 5, 2020 · 6 comments
Closed

PHP 7.1 Nullable types not being detected #273

LucasKovacs opened this issue Aug 5, 2020 · 6 comments
Assignees
Milestone

Comments

@LucasKovacs
Copy link

LucasKovacs commented Aug 5, 2020

PHP 7.1 nullable types are not being detected.

For example, the following block of code won't be identified as a PHP 7.1 block

<?php

function testReturn(): ?string
{
    return 'elePHPant';
}

var_dump(testReturn());

function testReturn(): ?string
{
    return null;
}

var_dump(testReturn());

function test(?string $name)
{
    var_dump($name);
}

test('elePHPant');
test(null);
test();

Currently using:
version 5.3.0
DB version 2.16.0
Installed via Composer

Reference:
https://www.php.net/manual/en/migration71.new-features.php

@llaville
Copy link
Owner

llaville commented Aug 5, 2020

Thanks for reporting (with details: I appreciate a lot), but the situation is already known !

To resume, all versions until 5.3.0 are not yet ready to detect all PHP 7 features.
This is the main goal of future 5.4.0 that will come soon now.

Branch 5.4 is currently under huge refactoring to avoid monolithic architecture (legacy) code, enhance maintainibility, and allow to add easily fix about detection/feature missing.

I may be available to push to repository in few hours a running v5.4 that you can test !

@llaville llaville self-assigned this Aug 5, 2020
llaville added a commit that referenced this issue Aug 5, 2020
llaville added a commit that referenced this issue Aug 5, 2020
@llaville
Copy link
Owner

llaville commented Aug 5, 2020

With test script added by commit e89de39, future 5.4 will give such result :

 bin/phpcompatinfo analyser:run tests/fixtures/gh273.php

Data Source Analysed

Directories                                          1
Files                                                1
Errors                                               0


Extensions Analysis

    Extension Matches REF      EXT min/Max PHP min/Max PHP all
    Core              Core     4.0.0       4.0.0
    standard          standard 4.0.0       4.0.0
    Total [2]                              4.0.0

Namespaces Analysis

    Namespace Matches REF  EXT min/Max PHP min/Max PHP all
                      user             7.1.0
    Total [1]                          7.1.0

No interface found

No trait found

No class found

Functions Analysis

    Function    Matches REF      EXT min/Max PHP min/Max
    test                user                 7.1.0
    testReturn1         user                 7.1.0
    testReturn2         user                 7.1.0
    var_dump            standard 4.0.0       4.0.0
    Total [4]                                7.1.0

Constants Analysis

    Constant  Matches REF  EXT min/Max PHP min/Max
    null              Core 4.0.0       4.0.0
    Total [1]                          4.0.0

No condition found

Requires PHP 7.1.0 (min), PHP 7.1.0 (all)

@llaville
Copy link
Owner

llaville commented Aug 5, 2020

@LucasKovacs : beta code is up and running in repo (branch 5.4), if you want to test the preview

@LucasKovacs
Copy link
Author

@llaville I will give it a try! thanks :)

I was not aware that 5.3 did not have full support

@llaville
Copy link
Owner

llaville commented Aug 6, 2020

See also commit 58660ad that handle parameters type hinting

@llaville llaville added this to the 5.4 milestone Aug 25, 2020
@llaville
Copy link
Owner

Will be release in two weeks with official release 5.4.0

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