laravel-ide-helper icon indicating copy to clipboard operation
laravel-ide-helper copied to clipboard

Can not generate `Carbon::macro` PHPDocs

Open Nationalcat opened this issue 3 years ago • 4 comments

Versions:

  • ide-helper Version: 2.9.0
  • Laravel Version: 8.29.0
  • PHP Version: 7.4

Description:

Can not generate Carbon::macro PHPDocs.

Steps To Reproduce:

  1. Set Carbon macro
use Illuminate\Support\Carbon;

// in AppServiceProvider.php
public function boot()
{
     Carbon::macro('sayHello', function () : string {
            return 'hello';
     });
}
  1. Regenerate PHPDocs run php artisan ide-helper:generate

  2. Not found Carbon::sayHello in _ide_helper.php

Nationalcat avatar Feb 26 '21 03:02 Nationalcat

Same here:

Versions

  • ide-helper Version: 2.8.1
  • Laravel Version: 6.18.40
  • PHP Version: 7.4
// app/Providers/CarbonServiceProvider.php
use Illuminate\Support\Carbon;
use Illuminate\Support\ServiceProvider;

class CarbonServiceProvider extends ServiceProvider
{
    ...

    public function boot()
    {
        Carbon::macro('startOfLatest15Min', static function () {
            $minutes = floor(self::this()->minute / 15) * 15;
            return self::this()->startOfHour()->minutes($minutes);
        });
    }
}
// config/app.php
return [
    'providers' => [
        App\Providers\CarbonServiceProvider::class,
        ...
    ],
];

Can't find Carbon::startOfLatest15Min in _ide_helper.php

stebogit avatar Mar 31 '21 21:03 stebogit

Any news on this?

pindab0ter avatar Nov 22 '21 13:11 pindab0ter

Just coming here to report the same thing.

What makes the Carbon Macros so different from other macros that DO get parsed by the ide-helper?

jonnywilliamson avatar Mar 09 '22 18:03 jonnywilliamson

@jonnywilliamson the ide helper checks that the macros are for classes that have the Illuminate\Support\Traits\Macroable trait.

https://github.com/barryvdh/laravel-ide-helper/blob/3ba1e2573b38f72107b8aacc4ee177fcab30a550/src/Generator.php#L298-L303

ordago avatar Mar 09 '22 19:03 ordago