Skip to content

Commit

Permalink
[TASK] Remove unused variables throughout core
Browse files Browse the repository at this point in the history
Due to refactoring or very old code some places in the core define
unused variables or variables, which are immediately overridden.
They are mostly unnecessary. Even in places, where they might be
slightly helpful if defined at the beginning of a function, the benefit
doesn't excuse the existence.

Resolves: #94528
Releases: master
Change-Id: I6071bb0bc96472a4b4b7f679bfabbacfb761f472
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69805
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
nhovratov authored and bmack committed Jul 12, 2021
1 parent 4c78f44 commit 6141e85
Show file tree
Hide file tree
Showing 36 changed files with 23 additions and 51 deletions.
2 changes: 1 addition & 1 deletion typo3/sysext/backend/Classes/Clipboard/Clipboard.php
Expand Up @@ -1026,7 +1026,7 @@ public function makeDeleteCmdArray($CMD)
*/
public function makePasteCmdArray_file($ref, $FILE)
{
[$pTable, $pUid] = explode('|', $ref);
$pUid = explode('|', $ref)[1];
$elements = $this->elFromTable('_FILE');
$mode = $this->currentMode() === 'copy' ? 'copy' : 'move';
// Traverse elements and make CMD array
Expand Down
Expand Up @@ -437,7 +437,6 @@ protected function handlePageEditing(ServerRequestInterface $request): string
*/
protected function getStartupModule(ServerRequestInterface $request): array
{
$startModule = null;
$redirectRoute = $request->getQueryParams()['redirect'] ?? '';
// Check if the route has been registered
if ($redirectRoute !== '' && $redirectRoute !== 'main' && isset(GeneralUtility::makeInstance(Router::class)->getRoutes()[$redirectRoute])) {
Expand Down
2 changes: 0 additions & 2 deletions typo3/sysext/backend/Tests/Unit/Form/NodeFactoryTest.php
Expand Up @@ -20,7 +20,6 @@
use TYPO3\CMS\Backend\Form\Element\UnknownElement;
use TYPO3\CMS\Backend\Form\Exception;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Backend\Form\NodeInterface;
use TYPO3\CMS\Backend\Tests\Unit\Form\Fixtures\NodeFactory\NodeElements\BarElement;
use TYPO3\CMS\Backend\Tests\Unit\Form\Fixtures\NodeFactory\NodeElements\FooElement;
use TYPO3\CMS\Backend\Tests\Unit\Form\Fixtures\NodeFactory\NodeResolvers\BarResolver;
Expand Down Expand Up @@ -431,7 +430,6 @@ public function createInstantiatesResolverWithHighestPriorityFirstWithOneGivenOr
'class' => FooElement::class,
],
];
$mockNode = $this->createMock(NodeInterface::class);

$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeResolver'] = [
1433156887 => [
Expand Down
2 changes: 0 additions & 2 deletions typo3/sysext/core/Classes/Core/Bootstrap.php
Expand Up @@ -357,8 +357,6 @@ protected static function setDefaultTimezone()
protected static function initializeErrorHandling()
{
static::initializeBasicErrorReporting();
$displayErrors = 0;
$exceptionHandlerClassName = null;
$productionExceptionHandlerClassName = $GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'];
$debugExceptionHandlerClassName = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];

Expand Down
2 changes: 0 additions & 2 deletions typo3/sysext/core/Classes/DataHandling/DataHandler.php
Expand Up @@ -906,7 +906,6 @@ public function process_datamap()
// Checking access to the record
// ******************************
$createNewVersion = false;
$recordAccess = false;
$old_pid_value = '';
// Is it a new record? (Then Id is a string)
if (!MathUtility::canBeInterpretedAsInteger($id)) {
Expand Down Expand Up @@ -5449,7 +5448,6 @@ public function discard(string $table, ?int $uid, array $record = null): void
}

// Gather versioned record
$versionRecord = null;
if ((int)$record['t3ver_wsid'] === 0) {
$record = BackendUtility::getWorkspaceVersionOfRecord($userWorkspace, $table, $uid);
}
Expand Down
Expand Up @@ -416,7 +416,7 @@ protected function extractId($idValue)
return $idValue;
}
// @todo Handle if $tableName does not match $this->tableName
[$tableName, $id] = BackendUtility::splitTable_Uid($idValue);
$id = BackendUtility::splitTable_Uid($idValue)[1];
return $id;
}

Expand Down
1 change: 0 additions & 1 deletion typo3/sysext/core/Classes/DataHandling/SlugHelper.php
Expand Up @@ -605,7 +605,6 @@ function (array $record) {
*/
protected function resolveParentPageRecord(int $pid, int $languageId): ?array
{
$parentPageRecord = null;
$rootLine = BackendUtility::BEgetRootLine($pid, '', true, ['nav_title']);
$excludeDokTypes = [
PageRepository::DOKTYPE_SPACER,
Expand Down
2 changes: 1 addition & 1 deletion typo3/sysext/core/Classes/Database/QueryGenerator.php
Expand Up @@ -1661,7 +1661,7 @@ public function getSelectQuery($qString = ''): string
$webMountPageTreePrefix = ',';
}
$webMountPageTree .= $webMountPageTreePrefix
. $this->getTreeList($webMount, 999, $begin = 0, $perms_clause);
. $this->getTreeList($webMount, 999, 0, $perms_clause);
}
// createNamedParameter() is not used here because the SQL fragment will only include
// the :dcValueX placeholder when the query is returned as a string. The value for the
Expand Down
2 changes: 1 addition & 1 deletion typo3/sysext/core/Classes/Database/QueryView.php
Expand Up @@ -1065,7 +1065,7 @@ public function makeValueList($fieldName, $fieldValue, $conf, $table, $splitStri
$webMountPageTreePrefix = ',';
}
$webMountPageTree .= $webMountPageTreePrefix
. $this->getTreeList($webMount, 999, $begin = 0, $perms_clause);
. $this->getTreeList($webMount, 999, 0, $perms_clause);
}
if ($from_table === 'pages') {
$queryBuilder->where(
Expand Down
14 changes: 7 additions & 7 deletions typo3/sysext/core/Classes/Database/Schema/ConnectionMigrator.php
Expand Up @@ -928,12 +928,12 @@ protected function migrateUnprefixedRemovedTablesToRenames(SchemaDiff $schemaDif
$tableDiff = GeneralUtility::makeInstance(
TableDiff::class,
$removedTable->getQuotedName($this->connection->getDatabasePlatform()),
$addedColumns = [],
$changedColumns = [],
$removedColumns = [],
$addedIndexes = [],
$changedIndexes = [],
$removedIndexes = [],
[], // added columns
[], // changed columns
[], // removed columns
[], // added indexes
[], // changed indexes
[], // removed indexed
$this->buildQuotedTable($removedTable)
);

Expand Down Expand Up @@ -989,7 +989,7 @@ protected function migrateUnprefixedRemovedFieldsToRenames(SchemaDiff $schemaDif
ColumnDiff::class,
$removedColumn->getQuotedName($this->connection->getDatabasePlatform()),
$renamedColumn,
$changedProperties = [],
[], // changed properties
$this->buildQuotedColumn($removedColumn)
);

Expand Down
Expand Up @@ -328,7 +328,6 @@ function (IndexColumnName $columnName) {
*/
protected function getDoctrineColumnTypeName(AbstractDataType $dataType): string
{
$doctrineType = null;
switch (get_class($dataType)) {
case TinyIntDataType::class:
// TINYINT is MySQL specific and mapped to a standard SMALLINT
Expand Down
2 changes: 1 addition & 1 deletion typo3/sysext/core/Classes/Database/SoftReferenceIndex.php
Expand Up @@ -553,7 +553,7 @@ public function setTypoLinkPartsElement($tLP, &$elements, $content, $idx)
// Output content will be the token instead:
$content = '{softref:' . $tokenID . '}';
} elseif ($tLP['identifier']) {
[$linkHandlerKeyword, $linkHandlerValue] = explode(':', trim($tLP['identifier']), 2);
$linkHandlerValue = explode(':', trim($tLP['identifier']), 2)[1];
if (MathUtility::canBeInterpretedAsInteger($linkHandlerValue)) {
// Token and substitute value
$elements[$tokenID . ':' . $idx]['subst'] = [
Expand Down
1 change: 0 additions & 1 deletion typo3/sysext/core/Classes/Mail/Rfc822AddressesParser.php
Expand Up @@ -632,7 +632,6 @@ protected function validateMailbox(&$mailbox)
*/
protected function _validateRouteAddr($route_addr)
{
$route = '';
$return = [];
// Check for colon.
if (strpos($route_addr, ':') !== false) {
Expand Down
2 changes: 0 additions & 2 deletions typo3/sysext/core/Classes/Mail/TransportFactory.php
Expand Up @@ -73,7 +73,6 @@ public function get(array $mailSettings): TransportInterface
throw new \InvalidArgumentException('Mail transport can not be set to "spool"', 1469363238);
}

$transport = null;
$transportType = isset($mailSettings['transport_spool_type'])
&& !empty($mailSettings['transport_spool_type'])
? 'spool' : $mailSettings['transport'];
Expand Down Expand Up @@ -190,7 +189,6 @@ public function get(array $mailSettings): TransportInterface
*/
protected function createSpool(array $mailSettings): DelayedTransportInterface
{
$spool = null;
switch ($mailSettings['transport_spool_type']) {
case self::SPOOL_FILE:
$path = GeneralUtility::getFileAbsFileName($mailSettings['transport_spool_filepath']);
Expand Down
2 changes: 0 additions & 2 deletions typo3/sysext/core/Classes/Type/File/ImageInfo.php
Expand Up @@ -117,8 +117,6 @@ protected function getImageSizes()
*/
protected function extractSvgImageSizes()
{
$imagesSizes = [];

$fileContent = file_get_contents($this->getPathname());
if ($fileContent === false) {
return false;
Expand Down
Expand Up @@ -90,7 +90,7 @@ public function testCycleException()
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionMessage('Your dependencies have cycles. That will not work out. Cycles found: legacy-hook->package4.listener, package4.listener->legacy-hook');

$container = $this->getContainerWithListenerProvider([
$this->getContainerWithListenerProvider([
__DIR__ . '/Fixtures/Package1',
__DIR__ . '/Fixtures/Package4Cycle',
]);
Expand Down
Expand Up @@ -188,7 +188,7 @@ public function testExceptionForNonNullableExtensionArgument()
$this->expectException(\Exception::class);
$this->expectExceptionMessage('A registered extension for the service "serviceA" requires the service to be available, which is missing.');

$container = $this->getContainer([
$this->getContainer([
TestServiceProviderOverride::class,
]);
}
Expand Down
2 changes: 1 addition & 1 deletion typo3/sysext/core/Tests/Unit/Mail/FileSpoolTest.php
Expand Up @@ -57,7 +57,7 @@ protected function setUp(): void
public function spoolsMessagesCorrectly(int $count)
{
for ($i = 1; $i <= $count; $i++) {
$sentMessage = $this->subject->send(
$this->subject->send(
new RawMessage('test message ' . $i),
new Envelope(new Address('sender@example.com'), [new Address('recipient@example.com')])
);
Expand Down
Expand Up @@ -769,7 +769,6 @@ protected function getErrorFlashMessage()
*/
protected function forwardToReferringRequest(): ?ResponseInterface
{
$referringRequest = null;
$referringRequestArguments = $this->request->getInternalArguments()['__referrer'] ?? null;
if (is_string($referringRequestArguments['@request'] ?? null)) {
$referrerArray = json_decode(
Expand Down
Expand Up @@ -192,7 +192,6 @@ public function contains($object)
public function count()
{
$columnMap = $this->dataMapper->getDataMap(get_class($this->parentObject))->getColumnMap($this->propertyName);
$numberOfElements = null;
if (!$this->isInitialized && $columnMap->getTypeOfRelation() === ColumnMap::RELATION_HAS_MANY) {
$numberOfElements = $this->dataMapper->countRelated($this->parentObject, $this->propertyName, $this->fieldValue);
} else {
Expand Down
Expand Up @@ -406,7 +406,6 @@ protected function parseDynamicOperand(ComparisonInterface $comparison, SourceIn
{
$value = $comparison->getOperand2();
$fieldName = $this->parseOperand($comparison->getOperand1(), $source);
$expr = null;
$exprBuilder = $this->queryBuilder->expr();
switch ($comparison->getOperator()) {
case QueryInterface::OPERATOR_IN:
Expand Down
2 changes: 0 additions & 2 deletions typo3/sysext/extbase/Classes/Utility/ExtensionUtility.php
Expand Up @@ -54,7 +54,6 @@ public static function configurePlugin($extensionName, $pluginName, array $contr
self::checkExtensionNameFormat($extensionName);

// Check if vendor name is prepended to extensionName in the format {vendorName}.{extensionName}
$vendorName = null;
$delimiterPosition = strrpos($extensionName, '.');
if ($delimiterPosition !== false) {
$vendorName = str_replace('.', '\\', substr($extensionName, 0, $delimiterPosition));
Expand Down Expand Up @@ -190,7 +189,6 @@ public static function registerModule($extensionName, $mainModuleName = '', $sub
self::checkExtensionNameFormat($extensionName);

// Check if vendor name is prepended to extensionName in the format {vendorName}.{extensionName}
$vendorName = '';
if (false !== $delimiterPosition = strrpos($extensionName, '.')) {
trigger_error(
'Calling method ' . __METHOD__ . ' with argument $extensionName containing the vendor name is deprecated and will stop working in TYPO3 11.0.',
Expand Down
Expand Up @@ -129,7 +129,6 @@ public function getIdentifierByObjectReturnsIdentifierForLazyObject()
{
$fakeUuid = 'fakeUuid';
$configurationManager = $this->createMock(ConfigurationManagerInterface::class);
$parentObject = new \stdClass();
$proxy = $this->getMockBuilder(LazyLoadingProxy::class)
->setMethods(['_loadRealInstance'])
->disableOriginalConstructor()
Expand Down
Expand Up @@ -318,7 +318,7 @@ public function mapObjectToClassPropertyReturnsExistingObjectWithoutCallingFetch
$psrContainer->expects(self::any())->method('has')->willReturn(false);
$container = new Container($psrContainer);

$session = new Session(new Container($psrContainer));
$session = new Session($container);
$session->registerObject($child, $identifier);

$mockReflectionService = $this->getMockBuilder(ReflectionService::class)
Expand Down
Expand Up @@ -206,7 +206,7 @@ public function installDistributionAction(Extension $extension)
if (!ExtensionManagementUtility::isLoaded('impexp')) {
return (new ForwardResponse('distributions'))->withControllerName('List');
}
[$result, $errorMessages] = $this->installFromTer($extension);
$errorMessages = $this->installFromTer($extension)[1];
if ($errorMessages) {
foreach ($errorMessages as $extensionKey => $messages) {
foreach ($messages as $message) {
Expand Down
Expand Up @@ -272,7 +272,7 @@ public function writeExtensionFilesWritesFiles()
'content' => 'FEEL FREE TO ADD SOME DOCUMENTATION HERE'
]
];
$rootPath = ($extDirPath = $this->fakedExtensions[$this->createFakeExtension()]['packagePath']);
$rootPath = $this->fakedExtensions[$this->createFakeExtension()]['packagePath'];
$fileHandlerMock = $this->getAccessibleMock(FileHandlingUtility::class, ['makeAndClearExtensionDir']);
$fileHandlerMock->_call('writeExtensionFiles', $files, $rootPath);
self::assertTrue(file_exists($rootPath . 'ChangeLog'));
Expand Down
Expand Up @@ -3793,7 +3793,6 @@ public function http_makelinks($data, $conf)
{
$parts = [];
$aTagParams = $this->getATagParams($conf);
$textstr = '';
foreach (['http://', 'https://'] as $scheme) {
$textpieces = explode($scheme, $data);
$pieces = count($textpieces);
Expand Down
Expand Up @@ -2069,7 +2069,7 @@ public function calculateLinkVars(array $queryParams)
return;
}
foreach ($linkVars as $linkVar) {
$test = $value = '';
$test = '';
if (preg_match('/^(.*)\\((.+)\\)$/', $linkVar, $match)) {
$linkVar = trim($match[1]);
$test = trim($match[2]);
Expand Down
Expand Up @@ -94,7 +94,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
public function properSiteConfigurationLoadsPageRouter()
{
$incomingUrl = 'https://king.com/lotus-flower/en/mr-magpie/bloom';
$pageRecord = ['uid' => 13, 'l10n_parent' => 0, 'slug' => '/mr-magpie/bloom'];
/** @var MockObject|Site $site */
$site = $this->getMockBuilder(Site::class)->setConstructorArgs([
'lotus-flower', 13, [
Expand Down Expand Up @@ -136,7 +135,6 @@ public function properSiteConfigurationLoadsPageRouter()
public function properSiteConfigurationLoadsPageRouterWithRedirect()
{
$incomingUrl = 'https://king.com/lotus-flower/en/mr-magpie/bloom/';
$pageRecord = ['uid' => 13, 'l10n_parent' => 0, 'slug' => '/mr-magpie/bloom'];
/** @var MockObject|Site $site */
$site = $this->getMockBuilder(Site::class)->setConstructorArgs([
'lotus-flower', 13, [
Expand Down Expand Up @@ -176,7 +174,6 @@ public function properSiteConfigurationLoadsPageRouterWithRedirect()
public function properSiteConfigurationLoadsPageRouterWithRedirectWithoutTrailingSlash()
{
$incomingUrl = 'https://king.com/lotus-flower/en/mr-magpie/bloom';
$pageRecord = ['uid' => 13, 'l10n_parent' => 0, 'slug' => '/mr-magpie/bloom/'];
/** @var MockObject|Site $site */
$site = $this->getMockBuilder(Site::class)->setConstructorArgs([
'lotus-flower', 13, [
Expand Down
1 change: 0 additions & 1 deletion typo3/sysext/indexed_search/Classes/FileContentParser.php
Expand Up @@ -461,7 +461,6 @@ protected function sL($reference)
*/
public function readFileContent($ext, $absFile, $cPKey)
{
$cmd = null;
$contentArr = null;
// Return immediately if initialization didn't set support up:
if (!$this->supportedExtensions[$ext]) {
Expand Down
1 change: 0 additions & 1 deletion typo3/sysext/indexed_search/Classes/Indexer.php
Expand Up @@ -700,7 +700,6 @@ public function getUrlHeaders($url)
*/
protected function createLocalPath($sourcePath)
{
$localPath = '';
$pathFunctions = [
'createLocalPathUsingAbsRefPrefix',
'createLocalPathUsingDomainURL',
Expand Down
Expand Up @@ -521,7 +521,7 @@ public function fixSelfCallsFixPermissionIfFileExistsButPermissionAreWrong()
$node->expects(self::any())->method('exists')->willReturn(true);
$node->expects(self::once())->method('isFile')->willReturn(false);
$node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
$resultArray = $node->_call('fixSelf');
$node->_call('fixSelf');
}

/**
Expand Down
Expand Up @@ -757,7 +757,6 @@ public function migrateSaltedPasswordsSettingsDoesNothingIfExtensionConfigsAreEm
public function migrateSaltedPasswordsSettingsRemovesExtensionsConfigAndSetsNothingElseIfArgon2iIsAvailable()
{
$configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
$configurationManagerException = new MissingArrayPathException('Path does not exist in array', 1533989428);
$configurationManagerProphecy->getLocalConfigurationValueByPath('EXTENSIONS/saltedpasswords')
->shouldBeCalled()->willReturn(['thereIs' => 'something']);
$argonBeProphecy = $this->prophesize(Argon2iPasswordHash::class);
Expand Down
4 changes: 2 additions & 2 deletions typo3/sysext/lowlevel/Classes/Database/QueryGenerator.php
Expand Up @@ -1279,7 +1279,7 @@ protected function makeValueList($fieldName, $fieldValue, $conf, $table, $splitS
$webMountPageTreePrefix = ',';
}
$webMountPageTree .= $webMountPageTreePrefix
. $this->getTreeList($webMount, 999, $begin = 0, $perms_clause);
. $this->getTreeList($webMount, 999, 0, $perms_clause);
}
if ($from_table === 'pages') {
$queryBuilder->where(
Expand Down Expand Up @@ -2710,7 +2710,7 @@ protected function getSelectQuery($qString = ''): string
$webMountPageTreePrefix = ',';
}
$webMountPageTree .= $webMountPageTreePrefix
. $this->getTreeList($webMount, 999, $begin = 0, $perms_clause);
. $this->getTreeList($webMount, 999, 0, $perms_clause);
}
// createNamedParameter() is not used here because the SQL fragment will only include
// the :dcValueX placeholder when the query is returned as a string. The value for the
Expand Down
1 change: 0 additions & 1 deletion typo3/sysext/recordlist/Classes/Browser/FileBrowser.php
Expand Up @@ -116,7 +116,6 @@ public function processSessionData($data)
*/
public function render()
{
$_MCONF = [];
$backendUser = $this->getBackendUser();

// The key number 3 of the bparams contains the "allowed" string. Disallowed is not passed to
Expand Down
2 changes: 1 addition & 1 deletion typo3/sysext/redirects/Classes/Service/RedirectService.php
Expand Up @@ -324,7 +324,7 @@ protected function bootFrontendController(SiteInterface $site, array $queryParam
$site,
$site->getDefaultLanguage(),
new PageArguments($site->getRootPageId(), '0', []),
$frontendUserAuthentication = $originalRequest->getAttribute('frontend.user')
$originalRequest->getAttribute('frontend.user')
);
$controller->determineId($originalRequest);
$controller->calculateLinkVars($queryParams);
Expand Down

0 comments on commit 6141e85

Please sign in to comment.