Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 20543 программиста и 1132 робота. Сейчас ищут 639 программистов ...
Приступая к работе

ReflectionFunctionAbstract::getReturnType - Gets the specified return type of a function

Вернуться к: ReflectionFunctionAbstract

ReflectionFunctionAbstract::getReturnType

(PHP 7)

ReflectionFunctionAbstract::getReturnTypeGets the specified return type of a function

Описание

public ReflectionType ReflectionFunctionAbstract::getReturnType ( void )

Gets the specified return type of a reflected function.

Список параметров

У этой функции нет параметров.

Возвращаемые значения

Returns a ReflectionType object if a return type is specified, NULL otherwise.

Примеры

Пример #1 ReflectionFunctionAbstract::getReturnType() example

<?php

function to_int($param) : int {
    return (int) 
$param;
}

$reflection1 = new ReflectionFunction('to_int');
echo 
$reflection1->getReturnType();

Результат выполнения данного примера:

int

Пример #2 Usage on built-in functions

<?php

$reflection2 
= new ReflectionFunction('array_merge');

var_dump($reflection2->getReturnType());

Результат выполнения данного примера:

null

This is because many internal functions do not have types specified for their parameters or return values. It is therefore best to avoid using this method on built-in functions.

Смотрите также



Вернуться к: ReflectionFunctionAbstract

© 2024 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware