1.2.1039. Reserved Methods

PHP has reserved all the methods names, starting with two underscores characters __.

While this is not explicitely enforced, using such names may create future conflict if PHP acquire features that rely on them.

<?php

class x {
     // One of the reserved and used PHP method
     function __toString() {}

     // One potential PHP reserved method
     function __toArray() {}
}

?>

See also Magic methods.

1.2.1039.1. Suggestions

  • Change the name of the method and avoid prefixing it with __

1.2.1039.2. Specs

Short name

Php/ReservedMethods

Rulesets

All, Changed Behavior, PHP recommendations

Exakat since

2.6.2

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

naming, magic-method

Available in

Entreprise Edition, Exakat Cloud