Skip to content

Commit b2c0c0c

Browse files
committed
Introduce and apply automatic code style fixes
1 parent 9b229a9 commit b2c0c0c

File tree

12 files changed

+102
-58
lines changed

12 files changed

+102
-58
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.gitattributes export-ignore
2+
/.gitignore export-ignore
3+
/.php_cs.dist export-ignore
4+
/.travis.yml export-ignore
5+
/tests

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
vendor
2-
composer.lock
1+
/.php_cs.cache
2+
/vendor
3+
/composer.lock

.php_cs.dist

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
return PhpCsFixer\Config::create()
3+
->setRiskyAllowed(true)
4+
->setRules([
5+
'@PSR2' => true,
6+
'concat_space' => [
7+
'spacing' => 'one',
8+
],
9+
'function_typehint_space' => true,
10+
'hash_to_slash_comment' => true,
11+
'lowercase_cast' => true,
12+
'ordered_imports' => true,
13+
'native_function_casing' => true,
14+
'no_alias_functions' => true,
15+
'no_blank_lines_after_phpdoc' => true,
16+
'no_leading_namespace_whitespace' => true,
17+
'no_trailing_comma_in_singleline_array' => true,
18+
'no_singleline_whitespace_before_semicolons' => true,
19+
'no_unused_imports' => true,
20+
'no_whitespace_in_blank_line' => true,
21+
'no_empty_statement' => true,
22+
'no_extra_consecutive_blank_lines' => [
23+
'continue',
24+
'curly_brace_block',
25+
'extra',
26+
'parenthesis_brace_block',
27+
'square_brace_block',
28+
'throw',
29+
],
30+
'no_short_bool_cast' => true,
31+
'no_unneeded_control_parentheses' => [
32+
'break',
33+
'clone',
34+
'continue',
35+
'echo_print',
36+
'return',
37+
'switch_case',
38+
],
39+
'phpdoc_no_package' => true,
40+
'phpdoc_scalar' => true,
41+
'self_accessor' => true,
42+
'single_quote' => true,
43+
'whitespace_after_comma_in_array' => true,
44+
])
45+
->setFinder(
46+
PhpCsFixer\Finder::create()
47+
->exclude('vendor')
48+
->in(__DIR__)
49+
);

.travis.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,20 @@ matrix:
66
- php: 5.3
77
dist: precise
88
- php: 5.5
9+
dist: precise
910
- php: 5.6
1011
- php: 7
1112
- php: 7.1
1213
- php: 7.2
14+
- php: 7.3
1315

1416
sudo: false
1517

1618
cache:
1719
directories:
1820
- $HOME/.composer/cache
1921

20-
env:
21-
global:
22-
secure: hL/ws+UJCh7H910RdJiT8A/TJ1DohXP1HnHbO7xhXYMA0PCgbPNDrRk8gD216IKqv+Zq1Pt7szDWlK017d7gwKhk1QJkRho96O9ZpEm795ARg7TR21sHx9jjvznD7cuL7c/nWyfIscEE3D9Bm+xn9IPxG6rYegYEBR1X9e1cGfM=
23-
2422
before_script:
25-
- if [ "$GITHUB_COMPOSER_AUTH" ]; then composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH; fi
2623
- composer install
2724

2825
script:

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
"psr-4": { "TYPO3\\ClassAliasLoader\\": "src/"}
1818
},
1919
"autoload-dev": {
20-
"psr-4": { "TYPO3\\ClassAliasLoader\\Tests\\": "tests/"}
20+
"psr-4": { "TYPO3\\ClassAliasLoader\\Test\\": "tests/"}
2121
},
2222
"require": {
2323
"php": ">=5.3.7",
2424
"composer-plugin-api": "^1.0"
2525
},
2626
"require-dev": {
27-
"composer/composer": "dev-master",
28-
"mikey179/vfsstream": "1.4.*@dev",
27+
"composer/composer": "^1.1@dev",
28+
"mikey179/vfsstream": "~1.4.0@dev",
2929
"phpunit/phpunit": "^4.8"
3030
},
3131
"replace": {
@@ -34,7 +34,7 @@
3434
"extra": {
3535
"class": "TYPO3\\ClassAliasLoader\\Plugin",
3636
"branch-alias": {
37-
"dev-master": "1.0.x-dev"
37+
"dev-master": "1.1.x-dev"
3838
}
3939
}
4040
}

src/ClassAliasLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function setAliasMap(array $aliasMap)
5555
}
5656

5757
/**
58-
* @param boolean $caseSensitiveClassLoading
58+
* @param bool $caseSensitiveClassLoading
5959
*/
6060
public function setCaseSensitiveClassLoading($caseSensitiveClassLoading)
6161
{
@@ -126,7 +126,8 @@ public function loadClassWithAlias($className)
126126
* @param string $className
127127
* @return bool|null
128128
*/
129-
public function loadClass($className) {
129+
public function loadClass($className)
130+
{
130131
$classFound = $this->composerClassLoader->loadClass($className);
131132
if (!$classFound && !$this->caseSensitiveClassLoading) {
132133
$classFound = $this->composerClassLoader->loadClass(strtolower($className));
@@ -153,7 +154,7 @@ protected function getOriginalClassName($aliasOrClassName)
153154
return $this->aliasMap['aliasToClassNameMapping'][$lowerCasedClassName];
154155
}
155156
// No alias registered for this class name, return and remember that info
156-
return $this->aliasMap['classNameToAliasMapping'][$aliasOrClassName] = NULL;
157+
return $this->aliasMap['classNameToAliasMapping'][$aliasOrClassName] = null;
157158
}
158159

159160
/**
@@ -203,5 +204,4 @@ public function __call($method, $arguments)
203204

204205
return call_user_func_array(array($this->composerClassLoader, $method), $arguments);
205206
}
206-
207207
}

src/ClassAliasMap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class ClassAliasMap
3030
* @param string $classNameOrAlias
3131
* @return string
3232
*/
33-
public static function getClassNameForAlias($classNameOrAlias) {
33+
public static function getClassNameForAlias($classNameOrAlias)
34+
{
3435
if (!static::$classAliasLoader) {
3536
return $classNameOrAlias;
3637
}
@@ -72,5 +73,4 @@ public static function setClassAliasLoader(ClassAliasLoader $classAliasLoader)
7273
}
7374
static::$classAliasLoader = $classAliasLoader;
7475
}
75-
7676
}

src/ClassAliasMapGenerator.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ClassAliasMapGenerator
3333
/**
3434
* @var IOInterface
3535
*/
36-
protected $IO;
36+
protected $io;
3737

3838
/**
3939
* @var bool
@@ -42,13 +42,13 @@ class ClassAliasMapGenerator
4242

4343
/**
4444
* @param Composer $composer
45-
* @param IOInterface $IO
45+
* @param IOInterface $io
4646
* @param bool $optimizeAutoloadFiles
4747
*/
48-
public function __construct(Composer $composer, IOInterface $IO = null, $optimizeAutoloadFiles = false)
48+
public function __construct(Composer $composer, IOInterface $io = null, $optimizeAutoloadFiles = false)
4949
{
5050
$this->composer = $composer;
51-
$this->IO = $IO ?: new NullIO();
51+
$this->io = $io ?: new NullIO();
5252
$this->optimizeAutoloadFiles = $optimizeAutoloadFiles;
5353
}
5454

@@ -79,15 +79,15 @@ public function generateAliasMap()
7979
foreach ($packageMap as $item) {
8080
/** @var PackageInterface $package */
8181
list($package, $installPath) = $item;
82-
$aliasLoaderConfig = new \TYPO3\ClassAliasLoader\Config($package, $this->IO);
82+
$aliasLoaderConfig = new \TYPO3\ClassAliasLoader\Config($package, $this->io);
8383
if ($aliasLoaderConfig->get('class-alias-maps') !== null) {
8484
if (!is_array($aliasLoaderConfig->get('class-alias-maps'))) {
8585
throw new \Exception('Configuration option "class-alias-maps" must be an array');
8686
}
8787
foreach ($aliasLoaderConfig->get('class-alias-maps') as $mapFile) {
8888
$mapFilePath = ($installPath ?: $basePath) . '/' . $filesystem->normalizePath($mapFile);
8989
if (!is_file($mapFilePath)) {
90-
$this->IO->writeError(sprintf('The class alias map file "%s" configured in package "%s" was not found!', $mapFile, $package->getName()));
90+
$this->io->writeError(sprintf('The class alias map file "%s" configured in package "%s" was not found!', $mapFile, $package->getName()));
9191
} else {
9292
$packageAliasMap = require $mapFilePath;
9393
if (!is_array($packageAliasMap)) {
@@ -117,7 +117,7 @@ public function generateAliasMap()
117117
}
118118

119119
$caseSensitiveClassLoadingString = $caseSensitiveClassLoading ? 'true' : 'false';
120-
$this->IO->write('<info>Generating ' . ($classAliasMappingFound ? '' : 'empty ') . 'class alias map file</info>');
120+
$this->io->write('<info>Generating ' . ($classAliasMappingFound ? '' : 'empty ') . 'class alias map file</info>');
121121
$this->generateAliasMapFile($aliasToClassNameMapping, $classNameToAliasMapping, $targetDir);
122122

123123
$suffix = null;
@@ -165,14 +165,14 @@ public static function initializeClassAliasLoader(\$composerClassLoader) {
165165
file_put_contents($targetDir . '/autoload_alias_loader_real.php', $aliasLoaderInitClassContent);
166166

167167
if (!$caseSensitiveClassLoading) {
168-
$this->IO->write('<info>Re-writing class map to support case insensitive class loading</info>');
168+
$this->io->write('<info>Re-writing class map to support case insensitive class loading</info>');
169169
if (!$this->optimizeAutoloadFiles) {
170-
$this->IO->write('<warning>Case insensitive class loading only works reliably if you use the optimize class loading feature of composer</warning>');
170+
$this->io->write('<warning>Case insensitive class loading only works reliably if you use the optimize class loading feature of composer</warning>');
171171
}
172172
$this->rewriteClassMapWithLowerCaseClassNames($targetDir);
173173
}
174174

175-
$this->IO->write('<info>Inserting class alias loader into main autoload.php file</info>');
175+
$this->io->write('<info>Inserting class alias loader into main autoload.php file</info>');
176176
$this->modifyMainAutoloadFile($vendorPath . '/autoload.php', $suffix);
177177

178178
return true;
@@ -200,7 +200,6 @@ protected function modifyMainAutoloadFile($autoloadFile, $suffix)
200200
EOF;
201201

202202
file_put_contents($autoloadFile, $autoloadFileContent);
203-
204203
}
205204

206205
/**
@@ -237,18 +236,17 @@ protected function rewriteClassMapWithLowerCaseClassNames($targetDir)
237236
file_put_contents($targetDir . '/autoload_classmap.php', $classMapContents);
238237
}
239238

240-
241239
/**
242-
* Extracts the bas path out of composer config
240+
* Extracts the base path out of composer config
243241
*
244242
* @param \Composer\Config $config
245243
* @return mixed
246244
*/
247-
protected function extractBasePath(\Composer\Config $config) {
245+
protected function extractBasePath(\Composer\Config $config)
246+
{
248247
$reflectionClass = new \ReflectionClass($config);
249248
$reflectionProperty = $reflectionClass->getProperty('baseDir');
250249
$reflectionProperty->setAccessible(true);
251250
return $reflectionProperty->getValue($config);
252251
}
253-
254252
}

src/Config.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ class Config
3030
'autoload-case-sensitivity' => true
3131
);
3232

33-
/**
34-
* @var IOInterface
35-
*/
36-
protected $IO;
33+
/**
34+
* @var IOInterface
35+
*/
36+
protected $io;
3737

3838
/**
3939
* @param PackageInterface $package
40-
* @param IOInterface $IO
40+
* @param IOInterface $io
4141
*/
42-
public function __construct(PackageInterface $package, IOInterface $IO = null)
42+
public function __construct(PackageInterface $package, IOInterface $io = null)
4343
{
44-
$this->IO = $IO ?: new NullIO();
44+
$this->io = $io ?: new NullIO();
4545
$this->setAliasLoaderConfigFromPackage($package);
4646
}
4747

@@ -69,7 +69,6 @@ public function get($configKey)
6969
return $value;
7070
}
7171

72-
7372
/**
7473
* @param PackageInterface $package
7574
*/
@@ -123,9 +122,8 @@ protected function handleDeprecatedConfigurationInPackage(PackageInterface $pack
123122
}
124123
}
125124
if (!empty($messages)) {
126-
$this->IO->writeError($messages);
125+
$this->io->writeError($messages);
127126
}
128127
return $extraConfig;
129128
}
130-
131129
}

src/Plugin.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
*/
1212

1313
use Composer\Composer;
14+
use Composer\EventDispatcher\EventSubscriberInterface;
1415
use Composer\IO\IOInterface;
1516
use Composer\Plugin\PluginInterface;
16-
use Composer\EventDispatcher\EventSubscriberInterface;
1717

1818
/**
1919
* Class Plugin
@@ -87,5 +87,4 @@ public function onPostAutoloadDump(\Composer\Script\Event $event)
8787

8888
return $aliasMapGenerator->generateAliasMap();
8989
}
90-
9190
}

0 commit comments

Comments
 (0)