silverleague / silverstripe-ideannotator

Generate docblocks for DataObjects, Page, PageControllers and (Data)Extensions
BSD 3-Clause "New" or "Revised" License
46 stars 25 forks source link

property has invalid value (\Page dataRecord) #144

Closed andersbjorkland closed 1 year ago

andersbjorkland commented 1 year ago

Setup

PHP 8.0 Silverstripe CMS v4.11.0 SilverLeague IDEAnnotator v3.2 PHPStan v1.8

Bug

When running dev/build the IDEAnnotator will add the following PHPDoc to the default PageController in SilverStripe:

<?php

namespace {

/**
 * Class \PageController
 *
 * @property \Page dataRecord
 * @method \Page data()
 * @mixin \Page
 */
class PageController extends \SilverStripe\CMS\Controllers\ContentController
// ...

Running PHPStan to analyze, it will react to the annotations with the following message:

  Line   PageController.php                                                                                                        
 ------ -------------------------------------------------------------------------------------------------------------------------- 
  12     PHPDoc tag @property has invalid value (\Page dataRecord): Unexpected token "dataRecord", expected variable at offset 51  
 ------ -------------------------------------------------------------------------------------------------------------------------- 

The property dataRecord is not correctly defined as a variable as it is missing the $-sign.

Solution

Fix generation for this property in ControllerTagGenerator

Firesphere commented 1 year ago

Interesting. This is specific to dataRecord that it's not getting the prefixed $, that's an oversight somewhere a few weeks/months back!

Thanks!

Did you check if any tests needed updating too?

andersbjorkland commented 1 year ago

Sorry, no. Did a quick fix straight on github.dev.

wernerkrauss commented 1 year ago

Hi @Firesphere, would you mind releasing a tag release with this fix? PHPStan is complaining about that property thingie...

Firesphere commented 1 year ago

Tagged