'Using MyControllerClass::myMethod() is deprecated and will not be possible anymore in TYPO3 v10.0. Use MyControllerClass:myOtherMethod() instead.' * ]; * * /** * * This is my method. * * * * @deprecated (if deprecated) * * @internal (if switched to private) * / * protected function myMethod($arg1, $arg2); * } */ /** * This trait has no public methods by default, ensure to add a $deprecatedPublicMethods property * to your class when using this trait. */ trait PublicMethodDeprecationTrait { /** * Checks if the method of the given name is available, calls it but throws a deprecation. * If the method does not exist, a fatal error is thrown. * * Unavailable protected methods must return in a fatal error as usual. * Marked methods are called and a deprecation entry is thrown. * * __call() is not called for public methods. * * @property array $deprecatedPublicMethods List of deprecated public methods * @param string $methodName * @param array $arguments * @return mixed */ public function __call(string $methodName, array $arguments) { if (method_exists($this, $methodName) && isset($this->deprecatedPublicMethods[$methodName])) { trigger_error($this->deprecatedPublicMethods[$methodName], E_USER_DEPRECATED); return $this->$methodName(...$arguments); } // Do the same behaviour as calling $myObject->method(); if (method_exists($this, $methodName)) { throw new \Error('Call to protected/private method ' . self::class . '::' . $methodName . '()', 1720252929); } throw new \Error('Call to undefined method ' . self::class . '::' . $methodName . '()', 1720252942); } }