Skip to content

Interaction with named arguments in Carbon issueΒ #953

@eithed

Description

@eithed

Given this code:

<?php

declare(strict_types=1);

namespace App;

use Carbon\CarbonImmutable;
use DateTime;

class Foo { 
    public function __construct(
    ){
        CarbonImmutable::createFromTimestampUTC(123)->floatDiffInMonths(date: new DateTime(), absolute: false);
    }
}

will result in following error:

Internal error: Internal error. while analysing file test/app/Foo.php                                       
     Post the following stack trace to https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml:                                                        
     ## test/vendor/ergebnis/phpstan-rules/src/CallLikes/NoNamedArgumentRule.php(115)                            
     #0 test/vendor/ergebnis/phpstan-rules/src/CallLikes/NoNamedArgumentRule.php(53):                            
     Ergebnis\PHPStan\Rules\CallLikes\NoNamedArgumentRule::describeCallable(Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope))           
     #1 phar://test/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(110):                      
     Ergebnis\PHPStan\Rules\CallLikes\NoNamedArgumentRule->processNode(Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope)) 

PHPStan version is 2.1.17
ergebnis/phpstan-rules version is 2.10.4
Carbon version is 2.72.6

I've tried isolating the issue to find out what happening inside Carbon is triggering this issue, to no avail - I suspect it's a combination of traits extending traits + static + extending native DateTimeImmutable.

The issue does not happen when not using named arguments

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions