Skip to content

Latest commit

 

History

History
28 lines (18 loc) · 803 Bytes

RequireExtends.md

File metadata and controls

28 lines (18 loc) · 803 Bytes

RequireExtends Attribute

This attribute is the equivalent of the @require-extends annotation. It can be applied to a trait to specify that the class using it must extend a specific class.

Arguments

The attribute accepts one string that defines the class that needs to be extended. The attribute itself does not have a knowledge of which classes are valid and which are not and this will depend on the implementation for each particular tool.

We aim to accept all the classes accepted by static analysis tools for the @require-extends annotation.

Example usage

<?php

use PhpStaticAnalysis\Attributes\RequireExtends;

abstract class Parent {
}

#[RequireExtends(Parent::class)] // needs to extend this class
trait myTrait {
}

class Child extends Parent {
  use myTrait;
}