php-generics-standard icon indicating copy to clipboard operation
php-generics-standard copied to clipboard

Drop the Attributes version

Open DaveLiddament opened this issue 4 years ago • 0 comments

Reasons for dropping the proposed Attributes version of annotating code (see example below):

  • Not supported and a perfectly acceptable alternative exists (docblocks)
  • Would require static analysis tool authors to do extra work to support it.
  • Is it actually better than docblocks?
use StaticAnalysis\Generics\v1\Template;
use StaticAnalysis\Generics\v1\Type;

#[Template("T")] 
#[Type("array<int,T>")]    // This is documenting the return type
function asArray(
    #[Type("T")] $value,
) { 
    return [$value]; 
}

..

DaveLiddament avatar Jan 08 '21 19:01 DaveLiddament