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

Support of PHP 7.1 #143

Open
bartrail opened this issue Apr 20, 2018 · 3 comments
Open

Support of PHP 7.1 #143

bartrail opened this issue Apr 20, 2018 · 3 comments
Assignees

Comments

@bartrail
Copy link

bartrail commented Apr 20, 2018

I get a syntax error while testing on PHP 7.1 code:

Your project contains invalid code:
Syntax error, unexpected '?' in file /var/www/html/www/src/Acme/Bundle/MyClass.php

this file contains the optional return value operator public function getValue() ?int

a quick look into this composer.json reveals the support of php 7.0 - so I'd like to know are there any plans to upgrade to support php 7.1? I assume of course, pull requests are welcome ;)

@slde-robin
Copy link
Contributor

Did you may miss the : in your example ?
public function getValue() >:< ?int

I tested it with a simple function

class Run {
    public function test(): ?int
    {
        return null;
    }
}

$x = (new Run())->test();

The PHP-Parser 3.x should support PHP until PHP 7.2.

@pylebecq
Copy link

pylebecq commented May 31, 2018

There's definitely something going on here. I have a similar issue when grouping use declaration.

When using in a file:

use Symfony\Component\HttpFoundation\{
    Request,
    Response
};

I have an error displayed in the output:

Your project contains invalid code:                                                                                                                                                    
Syntax error, unexpected '{', expecting T_STRING in file /project/src/AppBundle/Controller/LayerController.php

When replacing the group use declaration by multiple use:

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

The error is gone.

I'm running deprecation detector using the following docker image: https://github.com/jakzal/phpqa , which runs PHP 7.2.
I didn't look deeper but there might be some weird issue lurking somewhere.

@zergu
Copy link

zergu commented Oct 9, 2020

Have similar issue.

Syntax error, unexpected '?', expecting T_VARIABLE in file /srv/http/www/src/DTO/ProductFeed/Product.php

    public function __construct(
        string $name,
        ?string $category,
        ?string $brand,
        ?string $productUrl,
        ?string $imageUrl,
        ?string $localId,
        ?string $gtin
    ) {
        $this->name = trim($name);
        $this->category = trim($category) ?: null;
        $this->brand = trim($brand) ?: null;
        $this->productUrl = trim($productUrl) ?: null;
        $this->imageUrl = trim($imageUrl) ?: null;
        $this->localId = trim($localId) ?: null;
        $this->gtin = trim($gtin) ?: null;
    }

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

No branches or pull requests

4 participants