Commit 7cfb9210 authored by Georg Ringer's avatar Georg Ringer Committed by Andreas Fernandez
Browse files

[TASK] Add more rules for Code sniffer

In order to improve code quality, the following code sniffers are added:

- cast_spaces
- declare_equal_normalize
- dir_constant

Resolves: #84590
Releases: master, 8.7
Change-Id: Ib8a353b9ec47bff146b5decc3d5f97d242672efa
Reviewed-on: https://review.typo3.org/56533

Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarMathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: default avatarMathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Sybille Peters's avatarSybille Peters <sypets@gmx.de>
Tested-by: Sybille Peters's avatarSybille Peters <sypets@gmx.de>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 1b64feb6
......@@ -25,8 +25,8 @@
* inside the TYPO3 directory. Warning: This may take up to 10 minutes.
*
* For more information read:
* http://www.php-fig.org/psr/psr-2/
* http://cs.sensiolabs.org
* https://www.php-fig.org/psr/psr-2/
* https://cs.sensiolabs.org
*/
if (PHP_SAPI !== 'cli') {
die('This script supports command line usage only. Please check your command.');
......@@ -84,5 +84,8 @@ return PhpCsFixer\Config::create()
'phpdoc_types' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'return_type_declaration' => ['space_before' => 'none'],
'cast_spaces' => ['space' => 'none'],
'declare_equal_normalize' => ['space' => 'single'],
'dir_constant' => true,
])
->setFinder($finder);
#!/usr/bin/env php
<?php
declare(strict_types=1);
declare(strict_types = 1);
/*
* This file is part of the TYPO3 CMS project.
......
#!/usr/bin/env php
<?php
declare(strict_types=1);
declare(strict_types = 1);
/*
* This file is part of the TYPO3 CMS project.
......
<?php
declare(strict_types=1);
declare(strict_types = 1);
namespace TYPO3\CMS\Backend\Form\FieldInformation;
......
......@@ -440,7 +440,7 @@ class LocalizationControllerTest extends \TYPO3\TestingFramework\Core\Functional
$recordLocalizeSummaryResponse = $this->subject->getRecordLocalizeSummary($request, new Response());
// Reduce the fetched record summary to list of uids
if ($recordLocalizeSummary = json_decode((string) $recordLocalizeSummaryResponse->getBody(), true)) {
if ($recordLocalizeSummary = json_decode((string)$recordLocalizeSummaryResponse->getBody(), true)) {
foreach ($recordLocalizeSummary as &$record) {
if (is_array($record)) {
$record = array_intersect_key($record, ['uid' => '']);
......
<?php
declare(strict_types=1);
declare(strict_types = 1);
namespace TYPO3\CMS\Backend\Tests\UnitDeprecated\Form\FormDataProvider;
/*
......
<?php
declare(strict_types=1);
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Database\Platform;
......
<?php
declare(strict_types=1);
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
/*
......
<?php
declare(strict_types=1);
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Tests\Functional\Command;
/*
......
<?php
declare(strict_types=1);
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Tests\Unit\Database\Platform;
......
<?php
declare(strict_types=1);
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Tests\Unit\Error;
/*
......
<?php
declare(strict_types=1);
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Tests\Unit\Html;
/*
......
......@@ -194,7 +194,7 @@ class MessageTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'int' => [1],
'float' => [1.1],
'array' => [['foo' => ['bar']]],
'object' => [(object) ['foo' => 'bar']],
'object' => [(object)['foo' => 'bar']],
];
}
......@@ -219,7 +219,7 @@ class MessageTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'false' => [false],
'int' => [1],
'float' => [1.1],
'object' => [(object) ['foo' => 'bar']],
'object' => [(object)['foo' => 'bar']],
];
}
......
......@@ -80,7 +80,7 @@ class RequestTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
$request2 = $request->withUri(new Uri('/baz/bat?foo=bar'));
$this->assertNotSame($this->request, $request2);
$this->assertNotSame($request, $request2);
$this->assertEquals('/baz/bat?foo=bar', (string) $request2->getUri());
$this->assertEquals('/baz/bat?foo=bar', (string)$request2->getUri());
}
/**
......@@ -121,7 +121,7 @@ class RequestTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'int' => [1],
'float' => [1.1],
'array' => [['http://example.com']],
'stdClass' => [(object) ['href' => 'http://example.com']],
'stdClass' => [(object)['href' => 'http://example.com']],
];
}
......@@ -147,7 +147,7 @@ class RequestTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'int' => [1],
'float' => [1.1],
'array' => [['POST']],
'stdClass' => [(object) ['method' => 'POST']],
'stdClass' => [(object)['method' => 'POST']],
];
}
......@@ -183,7 +183,7 @@ class RequestTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'int' => [1],
'float' => [1.1],
'array' => [['BODY']],
'stdClass' => [(object) ['body' => 'BODY']],
'stdClass' => [(object)['body' => 'BODY']],
];
}
......@@ -209,7 +209,7 @@ class RequestTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'x-invalid-true' => true,
'x-invalid-false' => false,
'x-invalid-int' => 1,
'x-invalid-object' => (object) ['INVALID'],
'x-invalid-object' => (object)['INVALID'],
'x-valid-string' => 'VALID',
'x-valid-array' => ['VALID'],
];
......
......@@ -64,7 +64,7 @@ class ResponseTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'bool' => [true],
'string' => ['foo'],
'array' => [[200]],
'object' => [(object) [200]],
'object' => [(object)[200]],
];
}
......@@ -133,7 +133,7 @@ class ResponseTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'float' => [100.1],
'bad-string' => ['Two hundred'],
'array' => [[200]],
'object' => [(object) ['statusCode' => 200]],
'object' => [(object)['statusCode' => 200]],
'too-small' => [1],
'too-big' => [600],
];
......@@ -161,7 +161,7 @@ class ResponseTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'int' => [1],
'float' => [1.1],
'array' => [['BODY']],
'stdClass' => [(object) ['body' => 'BODY']],
'stdClass' => [(object)['body' => 'BODY']],
];
}
......@@ -187,7 +187,7 @@ class ResponseTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'x-invalid-true' => true,
'x-invalid-false' => false,
'x-invalid-int' => 1,
'x-invalid-object' => (object) ['INVALID'],
'x-invalid-object' => (object)['INVALID'],
'x-valid-string' => 'VALID',
'x-valid-array' => ['VALID'],
];
......
......@@ -79,7 +79,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
{
$message = 'foo bar';
$this->stream->write($message);
$this->assertEquals($message, (string) $this->stream);
$this->assertEquals($message, (string)$this->stream);
}
/**
......@@ -428,7 +428,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'int' => [1],
'float' => [1.1],
'array' => [[fopen($fileName, 'r+')]],
'object' => [(object) ['resource' => fopen($fileName, 'r+')]],
'object' => [(object)['resource' => fopen($fileName, 'r+')]],
];
}
......@@ -484,7 +484,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
fwrite($resource, 'FooBar');
$this->stream->rewind();
$test = (string) $this->stream;
$test = (string)$this->stream;
$this->assertEquals('FooBar', $test);
}
......
......@@ -56,7 +56,7 @@ class UploadedFileTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'invalid-path' => [ ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) ? '[:]' : 'foo' . chr(0) ],
*/
'array' => [['filename']],
'object' => [(object) ['filename']],
'object' => [(object)['filename']],
];
}
......@@ -82,7 +82,7 @@ class UploadedFileTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'float' => [1.1],
'string' => ['1'],
'array' => [[1]],
'object' => [(object) [1]],
'object' => [(object)[1]],
];
}
......@@ -109,7 +109,7 @@ class UploadedFileTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'float' => [1.1],
'string' => ['1'],
'array' => [[1]],
'object' => [(object) [1]],
'object' => [(object)[1]],
'negative' => [-1],
'too-big' => [9],
];
......@@ -137,7 +137,7 @@ class UploadedFileTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'int' => [1],
'float' => [1.1],
'array' => [['string']],
'object' => [(object) ['string']],
'object' => [(object)['string']],
];
}
......@@ -226,7 +226,7 @@ class UploadedFileTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'float' => [1.1],
'empty' => [''],
'array' => [['filename']],
'object' => [(object) ['filename']],
'object' => [(object)['filename']],
];
}
......
......@@ -46,7 +46,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
{
$url = 'https://user:pass@local.example.com:3001/foo?bar=baz#quz';
$uri = new Uri($url);
$this->assertEquals($url, (string) $uri);
$this->assertEquals($url, (string)$uri);
}
/**
......@@ -58,7 +58,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
$new = $uri->withScheme('http');
$this->assertNotSame($uri, $new);
$this->assertEquals('http', $new->getScheme());
$this->assertEquals('http://user:pass@local.example.com:3001/foo?bar=baz#quz', (string) $new);
$this->assertEquals('http://user:pass@local.example.com:3001/foo?bar=baz#quz', (string)$new);
}
/**
......@@ -70,7 +70,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
$new = $uri->withUserInfo('matthew');
$this->assertNotSame($uri, $new);
$this->assertEquals('matthew', $new->getUserInfo());
$this->assertEquals('https://matthew@local.example.com:3001/foo?bar=baz#quz', (string) $new);
$this->assertEquals('https://matthew@local.example.com:3001/foo?bar=baz#quz', (string)$new);
}
/**
......@@ -82,7 +82,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
$new = $uri->withUserInfo('matthew', 'zf2');
$this->assertNotSame($uri, $new);
$this->assertEquals('matthew:zf2', $new->getUserInfo());
$this->assertEquals('https://matthew:zf2@local.example.com:3001/foo?bar=baz#quz', (string) $new);
$this->assertEquals('https://matthew:zf2@local.example.com:3001/foo?bar=baz#quz', (string)$new);
}
/**
......@@ -94,7 +94,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
$new = $uri->withHost('framework.zend.com');
$this->assertNotSame($uri, $new);
$this->assertEquals('framework.zend.com', $new->getHost());
$this->assertEquals('https://user:pass@framework.zend.com:3001/foo?bar=baz#quz', (string) $new);
$this->assertEquals('https://user:pass@framework.zend.com:3001/foo?bar=baz#quz', (string)$new);
}
/**
......@@ -106,7 +106,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
$new = $uri->withPort(null);
$this->assertEquals(
'https://user:pass@local.example.com/foo?bar=baz#quz',
(string) $new
(string)$new
);
}
/**
......@@ -132,7 +132,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
$this->assertEquals($port, $new->getPort());
$this->assertEquals(
sprintf('https://user:pass@local.example.com:%d/foo?bar=baz#quz', $port),
(string) $new
(string)$new
);
}
......@@ -145,7 +145,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'false' => [false],
'string' => ['string'],
'array' => [[3000]],
'object' => [(object) [3000]],
'object' => [(object)[3000]],
];
}
......@@ -209,7 +209,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
$new = $uri->withPath('/bar/baz');
$this->assertNotSame($uri, $new);
$this->assertEquals('/bar/baz', $new->getPath());
$this->assertEquals('https://user:pass@local.example.com:3001/bar/baz?bar=baz#quz', (string) $new);
$this->assertEquals('https://user:pass@local.example.com:3001/bar/baz?bar=baz#quz', (string)$new);
}
/**
......@@ -222,7 +222,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'true' => [true],
'false' => [false],
'array' => [['/bar/baz']],
'object' => [(object) ['/bar/baz']],
'object' => [(object)['/bar/baz']],
];
}
......@@ -269,7 +269,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
$new = $uri->withQuery('baz=bat');
$this->assertNotSame($uri, $new);
$this->assertEquals('baz=bat', $new->getQuery());
$this->assertEquals('https://user:pass@local.example.com:3001/foo?baz=bat#quz', (string) $new);
$this->assertEquals('https://user:pass@local.example.com:3001/foo?baz=bat#quz', (string)$new);
}
/**
......@@ -282,7 +282,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'true' => [true],
'false' => [false],
'array' => [['baz=bat']],
'object' => [(object) ['baz=bat']],
'object' => [(object)['baz=bat']],
];
}
......@@ -318,7 +318,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
$new = $uri->withFragment('qat');
$this->assertNotSame($uri, $new);
$this->assertEquals('qat', $new->getFragment());
$this->assertEquals('https://user:pass@local.example.com:3001/foo?bar=baz#qat', (string) $new);
$this->assertEquals('https://user:pass@local.example.com:3001/foo?bar=baz#qat', (string)$new);
}
/**
......@@ -351,7 +351,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
{
$url = '/foo/bar?baz=bat';
$uri = new Uri($url);
$this->assertEquals($url, (string) $uri);
$this->assertEquals($url, (string)$uri);
}
/**
......@@ -370,7 +370,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
public function stringRepresentationOfAbsoluteUriWithNoPathSetsAnEmptyPath()
{
$uri = new Uri('http://example.com');
$this->assertEquals('http://example.com', (string) $uri);
$this->assertEquals('http://example.com', (string)$uri);
}
/**
......@@ -388,7 +388,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
public function stringRepresentationOfOriginFormWithNoPathRetainsEmptyPath()
{
$uri = new Uri('?foo=bar');
$this->assertEquals('?foo=bar', (string) $uri);
$this->assertEquals('?foo=bar', (string)$uri);
}
/**
......@@ -403,7 +403,7 @@ class UriTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
'int' => [1],
'float' => [1.1],
'array' => [['http://example.com/']],
'object' => [(object) ['uri' => 'http://example.com/']],
'object' => [(object)['uri' => 'http://example.com/']],
];
}
......
......@@ -54,7 +54,7 @@ class GraphicalFunctionsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
'origH' => 0,
'max' => 0,
0 => 150,
1 => (float) 120
1 => (float)120
],
],
'Get image scale with a maximum width of 100px' => [
......@@ -73,7 +73,7 @@ class GraphicalFunctionsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
'origH' => 0,
'max' => 1,
0 => 100,
1 => (float) 80
1 => (float)80
],
],
'Get image scale with a minimum width of 200px' => [
......@@ -92,7 +92,7 @@ class GraphicalFunctionsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
'origH' => 0,
'max' => 0,
0 => 200,
1 => (float) 136
1 => (float)136
],
],
];
......
<?php
declare(strict_types=1);
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Tests\Unit\Mail;
/*
......
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