CakeFest 2025 Madrid: The Official CakePHP Conference

ReflectionMethod::isAbstract

(PHP 5, PHP 7, PHP 8)

ReflectionMethod::isAbstractChecks if method is abstract

Description

public ReflectionMethod::isAbstract(): bool

Checks if the method is abstract.

Parameters

This function has no parameters.

Return Values

true if the method is abstract, otherwise false

See Also

add a note

User Contributed Notes 1 note

up
0
bobray99 at gmail dot com
4 days ago
This is an example using ReflectionMethod() to check if the parent class method is abstract or not. Calling an abstract method of a parent class will crash PHP.

<?php
abstract class modProcessor {
abstract public function
process();
}

class
ConcreteClass extends modProcessor {

public function
process() {
$reflectionMethod = new ReflectionMethod('modProcessor', 'process');
if (!
$reflectionMethod->isAbstract()) {
parent::process();
} else {
echo
"Cannot call abstract parent method";
}
}
}

$c = new ConcreteClass($modx);

$c->process();
To Top

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant