Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<ReflectionParameter::getTypeReflectionParameter::isArray>
^ReflectionParameterLast updated: Mon, 26 Oct 2026

ReflectionParameter::hasType

(PHP 7, PHP 8)

ReflectionParameter::hasType — Checks if parameter has a type

Description

public function ReflectionParameter::hasType(): bool

Checks if the parameter has a type associated with it.

Parameters

This function has no parameters.

Return Values

true if a type is specified, false otherwise.

Examples

Example #1 ReflectionParameter::hasType() example

<?php
function someFunction(string $param, $param2 = null) {}

$reflectionFunc = new ReflectionFunction('someFunction');
$reflectionParams = $reflectionFunc->getParameters();

var_dump($reflectionParams[0]->hasType());
var_dump($reflectionParams[1]->hasType());

The above example will output something similar to:

bool(true)
bool(false)

See Also


<ReflectionParameter::getTypeReflectionParameter::isArray>
^ReflectionParameterLast updated: Mon, 26 Oct 2026