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

PHPDoc tag @var for constant with type string|null is not subtype of native type string #10911

Open
gabrielrbarbosa opened this issue Apr 19, 2024 · 2 comments

Comments

@gabrielrbarbosa
Copy link

gabrielrbarbosa commented Apr 19, 2024

Bug report

  • Larastan Version: 11.x

larastan/larastan#1928 (comment)

Description

Errors detected in CI

16     PHPDoc tag @var for constant                                
         App\Models\Produto\TestModel::CREATED_AT with type  
         string|null is not subtype of native type string.
           
17     PHPDoc tag @var for constant                                
         App\Models\Produto\TestModel::UPDATED_AT with type  
         string|null is not subtype of native type string. 

Laravel code where the issue was found

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class TestModel extends Model
{
    use HasFactory;

    protected $table = 'test';

    public $timestamps = true;
    const string CREATED_AT = 'data_criacao';
    const string UPDATED_AT = 'data_alteracao';
    
    ...
}

Code snippet that reproduces the problem

https://phpstan.org/r/20335f79-4d10-4cd7-b8a3-8d12b5c1a072

No response

Expected output

I think the expected behavior is that a const string should be valid for "string|null" right?

Did PHPStan help you today? Did it make you happy in any way?

No response

Copy link

mergeable bot commented Apr 19, 2024

This bug report is missing a link to reproduction at phpstan.org/try.

It will most likely be closed after manual review.

@gabrielrbarbosa
Copy link
Author

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

1 participant