Commit bf03cdd9 authored by Benni Mack's avatar Benni Mack Committed by Susanne Moog
Browse files

[TASK] Include all classes via use statements in ext:core

This patch has been created with rector and php-cs-fixer

    bin/rector process --set=php53 typo3/sysext/core/Classes
    bin/rector process --set=php53 typo3/sysext/core/Tests

Resolves: #91054
Releases: master
Change-Id: Ie27503980812581103a5d12581a80a7e8fe474f1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64192


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarAlexander Schnitzler <git@alexanderschnitzler.de>
Tested-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Reviewed-by: default avatarAlexander Schnitzler <git@alexanderschnitzler.de>
Reviewed-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
parent 23ff5c03
......@@ -14,6 +14,9 @@ parameters:
- 'typo3/sysext/install/Tests/Unit/ExtensionScanner/Php/Matcher/Fixtures/'
- 'ClassAliasMap.php'
- 'class.ext_update.php'
- 'ext_localconf.php'
- 'ext_emconf.php'
- 'ext_tables.php'
- 'ServiceProvider.php' # avoid auto_import_names because of relative class name usage
exclude_rectors:
- Rector\Php55\Rector\String_\StringClassNameToClassConstantRector
......
......@@ -32,8 +32,12 @@ use TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction;
use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
use TYPO3\CMS\Core\Mail\FluidEmail;
use TYPO3\CMS\Core\Mail\Mailer;
use TYPO3\CMS\Core\Resource\Exception;
use TYPO3\CMS\Core\Resource\Filter\FileNameFilter;
use TYPO3\CMS\Core\Resource\Folder;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Resource\ResourceStorage;
use TYPO3\CMS\Core\Resource\StorageRepository;
use TYPO3\CMS\Core\SysLog\Action as SystemLogGenericAction;
use TYPO3\CMS\Core\SysLog\Action\Login as SystemLogLoginAction;
use TYPO3\CMS\Core\SysLog\Error as SystemLogErrorClassification;
......@@ -44,6 +48,7 @@ use TYPO3\CMS\Core\Type\Exception\InvalidEnumerationValueException;
use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\HttpUtility;
use TYPO3\CMS\Install\Service\SessionService;
/**
......@@ -1585,7 +1590,7 @@ TCAdefaults.sys_note.email = ' . $this->user['email'];
{
$this->fileStorages = [];
/** @var \TYPO3\CMS\Core\Resource\StorageRepository $storageRepository */
$storageRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
$storageRepository = GeneralUtility::makeInstance(StorageRepository::class);
// Admin users have all file storages visible, without any filters
if ($this->isAdmin()) {
$storageObjects = $storageRepository->findAll();
......@@ -1814,7 +1819,7 @@ TCAdefaults.sys_note.email = ' . $this->user['email'];
{
// Add the option for also displaying the non-hidden files
if ($this->uc['showHiddenFilesAndFolders']) {
\TYPO3\CMS\Core\Resource\Filter\FileNameFilter::setShowHiddenFilesAndFolders(true);
FileNameFilter::setShowHiddenFilesAndFolders(true);
}
}
......@@ -1911,7 +1916,7 @@ TCAdefaults.sys_note.email = ' . $this->user['email'];
* @param \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject
* @return array
*/
public function getFilePermissionsForStorage(\TYPO3\CMS\Core\Resource\ResourceStorage $storageObject)
public function getFilePermissionsForStorage(ResourceStorage $storageObject)
{
$finalUserPermissions = $this->getFilePermissions();
if (!$this->isAdmin()) {
......@@ -1959,13 +1964,13 @@ TCAdefaults.sys_note.email = ' . $this->user['email'];
break;
}
$uploadFolder = null;
} catch (\TYPO3\CMS\Core\Resource\Exception $folderAccessException) {
} catch (Exception $folderAccessException) {
// If the folder is not accessible (no permissions / does not exist) we skip this one.
}
break;
}
}
if (!$uploadFolder instanceof \TYPO3\CMS\Core\Resource\Folder) {
if (!$uploadFolder instanceof Folder) {
/** @var ResourceStorage $storage */
foreach ($this->getFileStorages() as $storage) {
if ($storage->isWritable()) {
......@@ -1975,7 +1980,7 @@ TCAdefaults.sys_note.email = ' . $this->user['email'];
break;
}
$uploadFolder = null;
} catch (\TYPO3\CMS\Core\Resource\Exception $folderAccessException) {
} catch (Exception $folderAccessException) {
// If the folder is not accessible (no permissions / does not exist) try the next one.
}
}
......@@ -1994,7 +1999,7 @@ TCAdefaults.sys_note.email = ' . $this->user['email'];
$uploadFolder = GeneralUtility::callUserFunction($_funcRef, $_params, $this);
}
if ($uploadFolder instanceof \TYPO3\CMS\Core\Resource\Folder) {
if ($uploadFolder instanceof Folder) {
return $uploadFolder;
}
return false;
......@@ -2019,7 +2024,7 @@ TCAdefaults.sys_note.email = ' . $this->user['email'];
if ($createFolder === true) {
try {
$defaultTemporaryFolder = $defaultFolder->createFolder($tempFolderName);
} catch (\TYPO3\CMS\Core\Resource\Exception $folderAccessException) {
} catch (Exception $folderAccessException) {
}
} else {
$defaultTemporaryFolder = $defaultFolder->getSubfolder($tempFolderName);
......@@ -2479,7 +2484,7 @@ TCAdefaults.sys_note.email = ' . $this->user['email'];
if (empty($this->user['uid'])) {
if ($proceedIfNoUserIsLoggedIn === false) {
$url = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir;
\TYPO3\CMS\Core\Utility\HttpUtility::redirect($url);
HttpUtility::redirect($url);
}
} else {
// ...and if that's the case, call these functions
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Cache\Backend;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -91,7 +92,7 @@ abstract class AbstractBackend implements BackendInterface, LoggerAwareInterface
*
* @param \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache The frontend for this backend
*/
public function setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
public function setCache(FrontendInterface $cache)
{
$this->cache = $cache;
$this->cacheIdentifier = $this->cache->getIdentifier();
......
......@@ -16,6 +16,7 @@
namespace TYPO3\CMS\Core\Cache\Backend;
use TYPO3\CMS\Core\Cache;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
/**
* A contract for a Cache Backend
......@@ -27,7 +28,7 @@ interface BackendInterface
*
* @param Cache\Frontend\FrontendInterface $cache The frontend for this backend
*/
public function setCache(Cache\Frontend\FrontendInterface $cache);
public function setCache(FrontendInterface $cache);
/**
* Saves data in the cache.
......
......@@ -15,9 +15,11 @@
namespace TYPO3\CMS\Core\Cache\Exception;
use TYPO3\CMS\Core\Cache\Exception;
/**
* A "Duplicate Identifier" exception
*/
class DuplicateIdentifierException extends \TYPO3\CMS\Core\Cache\Exception
class DuplicateIdentifierException extends Exception
{
}
......@@ -15,9 +15,11 @@
namespace TYPO3\CMS\Core\Cache\Exception;
use TYPO3\CMS\Core\Cache\Exception;
/**
* An "Invalid Backend" exception
*/
class InvalidBackendException extends \TYPO3\CMS\Core\Cache\Exception
class InvalidBackendException extends Exception
{
}
......@@ -15,9 +15,11 @@
namespace TYPO3\CMS\Core\Cache\Exception;
use TYPO3\CMS\Core\Cache\Exception;
/**
* An "Invalid Cache" exception
*/
class InvalidCacheException extends \TYPO3\CMS\Core\Cache\Exception
class InvalidCacheException extends Exception
{
}
......@@ -15,9 +15,11 @@
namespace TYPO3\CMS\Core\Cache\Exception;
use TYPO3\CMS\Core\Cache\Exception;
/**
* An "Invalid Data" exception
*/
class InvalidDataException extends \TYPO3\CMS\Core\Cache\Exception
class InvalidDataException extends Exception
{
}
......@@ -15,9 +15,11 @@
namespace TYPO3\CMS\Core\Cache\Exception;
use TYPO3\CMS\Core\Cache\Exception;
/**
* A "No Such Cache" exception
*/
class NoSuchCacheException extends \TYPO3\CMS\Core\Cache\Exception
class NoSuchCacheException extends Exception
{
}
......@@ -15,9 +15,11 @@
namespace TYPO3\CMS\Core\Cache\Exception;
use TYPO3\CMS\Core\Cache\Exception;
/**
* A "No Such Cache Group" exception
*/
class NoSuchCacheGroupException extends \TYPO3\CMS\Core\Cache\Exception
class NoSuchCacheGroupException extends Exception
{
}
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Collection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -369,7 +370,7 @@ abstract class AbstractRecordCollection implements RecordCollectionInterface, Pe
$data[trim(static::$storageTableName)][$uid]['pid'] = 0;
}
/** @var \TYPO3\CMS\Core\DataHandling\DataHandler $tce */
$tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
$tce = GeneralUtility::makeInstance(DataHandler::class);
$tce->start($data, []);
$tce->process_datamap();
}
......
......@@ -18,7 +18,7 @@ namespace TYPO3\CMS\Core\Collection;
/**
* Collection for handling records from a single database-table.
*/
interface RecordCollectionInterface extends \TYPO3\CMS\Core\Collection\CollectionInterface, \TYPO3\CMS\Core\Collection\NameableCollectionInterface
interface RecordCollectionInterface extends CollectionInterface, NameableCollectionInterface
{
/**
* Setter for the name of the data-source table
......
......@@ -15,11 +15,13 @@
namespace TYPO3\CMS\Core\Configuration\TypoScript\Exception;
use TYPO3\CMS\Core\Exception;
/**
* A "Your TypoScript condition is invalid" exception
* used when a TypoScript condition is called but not extending
* from the AbstractCondition class.
*/
class InvalidTypoScriptConditionException extends \TYPO3\CMS\Core\Exception
class InvalidTypoScriptConditionException extends Exception
{
}
......@@ -20,6 +20,7 @@ use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Psr\Container\ContainerInterface;
use Psr\EventDispatcher\EventDispatcherInterface;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Cache\Backend\BackendInterface;
use TYPO3\CMS\Core\Cache\Backend\NullBackend;
use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend;
......@@ -30,6 +31,7 @@ use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
use TYPO3\CMS\Core\Configuration\ConfigurationManager;
use TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface;
use TYPO3\CMS\Core\DependencyInjection\Cache\ContainerBackend;
use TYPO3\CMS\Core\DependencyInjection\ContainerBuilder;
use TYPO3\CMS\Core\Imaging\IconRegistry;
......@@ -39,6 +41,7 @@ use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Package\FailsafePackageManager;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Service\DependencyOrderingService;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\PharStreamWrapper\Behavior;
......@@ -238,7 +241,7 @@ class Bootstrap
*/
public static function createPackageManager($packageManagerClassName, FrontendInterface $coreCache): PackageManager
{
$dependencyOrderingService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Service\DependencyOrderingService::class);
$dependencyOrderingService = GeneralUtility::makeInstance(DependencyOrderingService::class);
/** @var \TYPO3\CMS\Core\Package\PackageManager $packageManager */
$packageManager = new $packageManagerClassName($dependencyOrderingService);
$packageManager->injectCoreCache($coreCache);
......@@ -552,7 +555,7 @@ class Bootstrap
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] ?? [] as $className) {
/** @var \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface $hookObject */
$hookObject = GeneralUtility::makeInstance($className);
if (!$hookObject instanceof \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface) {
if (!$hookObject instanceof TableConfigurationPostProcessingHookInterface) {
throw new \UnexpectedValueException(
'$hookObject "' . $className . '" must implement interface TYPO3\\CMS\\Core\\Database\\TableConfigurationPostProcessingHookInterface',
1320585902
......@@ -581,7 +584,7 @@ class Bootstrap
* @param string $className usually \TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class but can be used for CLI
* @internal This is not a public API method, do not use in own extensions
*/
public static function initializeBackendUser($className = \TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class)
public static function initializeBackendUser($className = BackendUserAuthentication::class)
{
/** @var \TYPO3\CMS\Core\Authentication\BackendUserAuthentication $backendUser */
$backendUser = GeneralUtility::makeInstance($className);
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Core;
use Composer\Autoload\ClassLoader;
use Composer\Autoload\ClassMapGenerator;
use TYPO3\CMS\Core\Error\Exception;
use TYPO3\CMS\Core\Package\PackageInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -179,7 +180,7 @@ class ClassLoadingInformationGenerator
if (!empty($manifest->extra->{'typo3/class-alias-loader'}->{'class-alias-maps'})) {
$possibleClassAliasFiles = $manifest->extra->{'typo3/class-alias-loader'}->{'class-alias-maps'};
if (!is_array($possibleClassAliasFiles)) {
throw new \TYPO3\CMS\Core\Error\Exception('"typo3/class-alias-loader"/"class-alias-maps" must return an array!', 1444142481);
throw new Exception('"typo3/class-alias-loader"/"class-alias-maps" must return an array!', 1444142481);
}
} else {
$possibleClassAliasFiles[] = 'Migrations/Code/ClassAliasMap.php';
......@@ -190,7 +191,7 @@ class ClassLoadingInformationGenerator
if (file_exists($possiblePathToClassAliasFile)) {
$packageAliasMap = require $possiblePathToClassAliasFile;
if (!is_array($packageAliasMap)) {
throw new \TYPO3\CMS\Core\Error\Exception('"class alias maps" must return an array', 1422625075);
throw new Exception('"class alias maps" must return an array', 1422625075);
}
foreach ($packageAliasMap as $aliasClassName => $className) {
$lowerCasedAliasClassName = strtolower($aliasClassName);
......
......@@ -17,9 +17,11 @@ declare(strict_types=1);
namespace TYPO3\CMS\Core\Crypto\PasswordHashing;
use TYPO3\CMS\Core\Exception;
/**
* InvalidPasswordHashException thrown if salting went wrong.
*/
class InvalidPasswordHashException extends \TYPO3\CMS\Core\Exception
class InvalidPasswordHashException extends Exception
{
}
......@@ -27,5 +27,5 @@ interface DataHandlerCheckModifyAccessListHookInterface
* @param string $table The name of the table to be modified
* @param \TYPO3\CMS\Core\DataHandling\DataHandler $parent The calling parent object
*/
public function checkModifyAccessList(&$accessAllowed, $table, \TYPO3\CMS\Core\DataHandling\DataHandler $parent);
public function checkModifyAccessList(&$accessAllowed, $table, DataHandler $parent);
}
......@@ -27,5 +27,5 @@ interface DataHandlerProcessUploadHookInterface
* @param string $filename The uploaded file
* @param \TYPO3\CMS\Core\DataHandling\DataHandler $parentObject
*/
public function processUpload_postProcessAction(&$filename, \TYPO3\CMS\Core\DataHandling\DataHandler $parentObject);
public function processUpload_postProcessAction(&$filename, DataHandler $parentObject);
}
......@@ -20,11 +20,14 @@ namespace TYPO3\CMS\Core\Database;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\VersionAwarePlatformDriver;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Database\Query\BulkInsertQuery;
use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -217,7 +220,7 @@ class Connection extends \Doctrine\DBAL\Connection implements LoggerAwareInterfa
*/
public function bulkInsert(string $tableName, array $data, array $columns = [], array $types = []): int
{
$query = GeneralUtility::makeInstance(Query\BulkInsertQuery::class, $this, $tableName, $columns);
$query = GeneralUtility::makeInstance(BulkInsertQuery::class, $this, $tableName, $columns);
foreach ($data as $values) {
$query->addValues($values, $types);
}
......@@ -394,11 +397,11 @@ class Connection extends \Doctrine\DBAL\Connection implements LoggerAwareInterfa
}
// Driver does not support version specific platforms.
if (!$this->getDriver() instanceof \Doctrine\DBAL\VersionAwarePlatformDriver) {
if (!$this->getDriver() instanceof VersionAwarePlatformDriver) {
return $version;
}
if ($this->getWrappedConnection() instanceof \Doctrine\DBAL\Driver\ServerInfoAwareConnection
if ($this->getWrappedConnection() instanceof ServerInfoAwareConnection
&& !$this->getWrappedConnection()->requiresQueryForServerVersion()
) {
$version .= ' ' . $this->getWrappedConnection()->getServerVersion();
......
......@@ -16,6 +16,7 @@
namespace TYPO3\CMS\Core\Database;
use Doctrine\DBAL\DBALException;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\Query\QueryHelper;
......@@ -698,7 +699,7 @@ class QueryView
}
$out .= '<td>';
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
if (!$row['deleted']) {
$out .= '<div class="btn-group" role="group">';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment