deprecation-detector icon indicating copy to clipboard operation
deprecation-detector copied to clipboard

Support of PHP 7.1

Open bartrail opened this issue 6 years ago • 3 comments

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 ;)

bartrail avatar Apr 20 '18 12:04 bartrail

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.

slde-robin avatar May 18 '18 12:05 slde-robin

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.

pylebecq avatar May 31 '18 14:05 pylebecq

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;
    }

zergu avatar Oct 09 '20 10:10 zergu