TYPO3 v15 dev-main snapshot ()

This commit is contained in:
2026-08-10 22:31:09 +02:00
commit af8cc155b5
6818 changed files with 642608 additions and 0 deletions
@@ -0,0 +1,99 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\Compatibility;
/**
* Trait to support the logging of deprecation of public INSTANCE methods.
*
* This is useful due to the long list of PHP4 methods that have been set to
* public previously, which should be removed or moved to "protected" / "private".
*
* Usage:
*
* 1. Use this trait for the class with the method to change the visibility status or to be removed.
* 2. Add the class methods with deprecated public visibility to $deprecatedPublicMethods.
* 3. Set these methods to protected or private.
* 4. Add the phpDoc tag "@private" to the method so IDEs understand that.
*
* With the next major release remove the "@private" tag and remove the methods from
* $deprecatedPublicMethods. Remove the trait use after removing the last deprecation.
*
* Note:
*
* - Only use this trait in classes only that do not define their own magic __call() method.
* - Do not use this trait for static methods.
*
* Example usage:
*
*
* class MyControllerClass {
* use PublicMethodDeprecationTrait;
*
* /**
* * List previously publicly accessible variables
* * @var array
* *...
* private $deprecatedPublicMethods = [
* 'myMethod' => '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);
}
}
@@ -0,0 +1,140 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\Compatibility;
/**
* Trait to support the logging of deprecation of public properties.
*
* This is useful due to the long list of PHP4 properties have been set to
* public previously, which should be removed or moved to "protected" / "private".
*
* Usage:
*
* - Use this trait for the class with the properties to change the visibility status or to be removed.
* - Set internal class properties to protected.
* - Add the phpDoc tag "private" to the property (so IDEs understand that).
* - Remove this tag with the next major version.
* - Remove trait after last deprecation.
*
* Note:
*
* Use this trait for classes only that do not make use of magic accessors otherwise.
*
* Example usage:
*
*
* class MyControllerClass {
* use PublicPropertyDeprecationTrait;
*
* /**
* * List previously publicly accessible variables
* *...
* private array $deprecatedPublicProperties = [
* 'myProperty' => 'Using myProperty is deprecated and will not be possible anymore in TYPO3 v10.0. Use getMyProperty() instead.'
* ];
*
* /**
* * This is my property.
* *
* * @var bool
* * @deprecated (if deprecated)
* * @internal (if switched to private)
* /
* protected $myProperty = true;
* }
*/
/**
* This trait has no public properties by default, ensure to add a $deprecatedPublicProperties to your class
* when using this trait.
*/
trait PublicPropertyDeprecationTrait
{
/**
* Checks if the property of the given name is set.
*
* Unmarked protected properties must return false as usual.
* Marked properties are evaluated by isset().
*
* This method is not called for public properties.
*
* @property array $deprecatedPublicProperties List of deprecated public properties
* @param string $propertyName
* @return bool
*/
public function __isset(string $propertyName)
{
if (isset($this->deprecatedPublicProperties[$propertyName])) {
trigger_error($this->deprecatedPublicProperties[$propertyName], E_USER_DEPRECATED);
return isset($this->$propertyName);
}
return false;
}
/**
* Gets the value of the property of the given name if tagged.
*
* The evaluation is done in the assumption that this method is never
* reached for a public property.
*
* @property array $deprecatedPublicProperties List of deprecated public properties
* @param string $propertyName
* @return mixed
*/
public function __get(string $propertyName)
{
if (isset($this->deprecatedPublicProperties[$propertyName])) {
trigger_error($this->deprecatedPublicProperties[$propertyName], E_USER_DEPRECATED);
}
return property_exists($this, $propertyName) ? $this->$propertyName : null;
}
/**
* Sets the property of the given name if tagged.
*
* Additionally it's allowed to set unknown properties.
*
* The evaluation is done in the assumption that this method is never
* reached for a public property.
*
* @property array $deprecatedPublicProperties List of deprecated public properties
* @param string $propertyName
* @param mixed $propertyValue
*/
public function __set(string $propertyName, $propertyValue)
{
// It's allowed to set an unknown property as public, the check is thus necessary
if (property_exists($this, $propertyName) && isset($this->deprecatedPublicProperties[$propertyName])) {
trigger_error($this->deprecatedPublicProperties[$propertyName], E_USER_DEPRECATED);
}
$this->$propertyName = $propertyValue;
}
/**
* Unsets the property of the given name if tagged.
*
* @property array $deprecatedPublicProperties List of deprecated public properties
*/
public function __unset(string $propertyName)
{
if (isset($this->deprecatedPublicProperties[$propertyName])) {
trigger_error($this->deprecatedPublicProperties[$propertyName], E_USER_DEPRECATED);
}
unset($this->$propertyName);
}
}