1.2.1028. Reflection Export() Is Deprecated

export() method in Reflection classes is now deprecated. It is obsolete since PHP 7.4 and will disappear in PHP 8.0.

The Reflector interface, which is implemented by all reflection classes, specifies two methods: __toString() and export().

<?php

ReflectionFunction::export('foo');
// same as
echo new ReflectionFunction('foo'), "\n";

$str = ReflectionFunction::export('foo', true);
// same as
$str = (string) new ReflectionFunction('foo');

?>

See also Reflection export() methods and Reflection.

1.2.1028.1. Suggestions

  • Cast the object to string

  • Remove the call to export()

1.2.1028.2. Specs

Short name

Php/ReflectionExportIsDeprecated

Rulesets

All, CE, Changed Behavior, CompatibilityPHP74

Exakat since

1.9.0

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Changed Behavior

PHP 7.4 - More

Precision

Very high

Features

reflection

Available in

Entreprise Edition, Community Edition, Exakat Cloud