Phpstan: Property with heredoc default is always seen as not having a type

Created on 16 Dec 2019  路  3Comments  路  Source: phpstan/phpstan

Bug report

A property that has a default in the heredoc format will always be seen as not having a type, this isn't the case for a regular string or Nowdoc

PHPStan 0.12.3

Code snippet that reproduces the problem

<?php declare(strict_types = 1);

class BugReportMailrcConfigTests
{
    /** @var string */
    private $s1 = <<<STRING
I'm a string :(
STRING;
    /** @var string */
    private $s2 = <<<'STRING'
I'm a string :)
STRING;
    /** @var string */
    private $s3 = 'I\'m a string :)';
}

https://phpstan.org/r/e225ae46-945f-4327-bff5-77df51e1bf5b

Expected output

[OK] No errors

bug

All 3 comments

Looks like this is a PHP bug introduced in PHP 7.3.0: https://3v4l.org/4fRLA

Submitted a bug report: https://bugs.php.net/bug.php?id=79062

Fixed in PHP.

Was this page helpful?
0 / 5 - 0 ratings