PHP code example of lee-to / fast-attributes

1. Go to this page and download the library: Download lee-to/fast-attributes library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lee-to / fast-attributes example snippets


// All class attributes
$classAttributes = Attributes::for(ClassWithAttributes::class)->get();

// Only SomeAttribute class attributes
$someAttributes = Attributes::for(ClassWithAttributes::class)
    ->attribute(SomeAttribute::class)
    ->get();

// Only SomeAttribute instance
$someAttribute = Attributes::for(ClassWithAttributes::class)
    ->attribute(SomeAttribute::class)
    ->first();

// SomeAttribute variable property
$someAttribute = Attributes::for(ClassWithAttributes::class)
    ->attribute(SomeAttribute::class)
    ->first('variable');

// Method parameter attributes
$someAttribute = Attributes::for(ClassWithAttributes::class)
    ->method('someMethod')
    ->parameter('variable')
    ->get();

$someAttribute = Attributes::for(ClassWithAttributes::class)
    ->constant('VARIABLE')
    ->property('variable')
    ->method('someMethod')
    ->parameter('variable')
    ->get();