phpday 2027 - Call for Papers

get_declared_traits

(PHP 5 >= 5.4.0, PHP 7, PHP 8)

get_declared_traits — Bildirilmiş tüm nitelikleri dizi olarak döndürür

Açıklama

function get_declared_traits(): array

Bildirilmiş tüm niteliklerin değer olduğu bir dizi döndürür.

Bağımsız Değişkenler

Bu işlevin bağımsız değişkeni yoktur.

Dönen Değerler

Bildirilmiş tüm niteliklerin değer olduğu bir dizi döndürür.

Ayrıca Bakınız

User Contributed Notes 1 note

up
1
@everaldofilho
7 years ago
Example of use:

<?php

namespace Example;

// Declare Trait
trait FooTrait
{
}

// Declare Abstract class
abstract class FooAbstract
{
}

// Declare class
class Bar extends FooAbstract
{
    use FooTrait;
}

// Get all traits declareds
$array = get_declared_traits();

var_dump($array);
/**
 * Result:

 * array(1) {
 *  [0] =>
 *  string(23) "Example\FooTrait"
 * }
 */
Adding new notes is disabled. Please see the links in the Found A Problem? section.
To Top