Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit ebbb58d

Browse files
author
danielbannert
committed
added narrowspark/coding-standard
cs fixes and phpstan fixes
1 parent 3f2e10b commit ebbb58d

File tree

15 files changed

+49
-31
lines changed

15 files changed

+49
-31
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ before_install:
2020
chmod a+x ./build/travis/configure_php.sh
2121
chmod a+x ./build/travis/script.sh
2222
- ./build/travis/configure_php.sh
23+
- composer validate
2324

2425
install:
2526
- composer global require hirak/prestissimo

composer.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@
2626
"require-dev": {
2727
"composer/composer": "^1.6.0",
2828
"mockery/mockery": "^1.0.0",
29-
"narrowspark/php-cs-fixer-config": "^3.0.1",
29+
"narrowspark/coding-standard": "^1.0.0",
3030
"narrowspark/testing-helper": "^6.0.0",
31-
"phpstan/phpstan": "^0.9.0",
32-
"phpstan/phpstan-phpunit": "^0.9.0",
33-
"phpunit/phpunit": "^7.0.0",
31+
"phpunit/phpunit": "^7.2.0",
3432
"symfony/phpunit-bridge": "^4.0.8"
3533
},
3634
"config": {

phpstan.neon

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
includes:
2+
# - vendor/pepakriz/phpstan-exception-rules/extension.neon
3+
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
24
- vendor/phpstan/phpstan-phpunit/extension.neon
35
- vendor/phpstan/phpstan-phpunit/rules.neon
6+
# - vendor/phpstan/phpstan-strict-rules/rules.neon
7+
# - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
48

59
parameters:
610
autoload_directories:
711
- %currentWorkingDirectory%/src
812

13+
excludes_analyse:
14+
- %currentWorkingDirectory%/src/Discovery/Prefetcher/CurlDownloader.php
15+
916
ignoreErrors:
1017
# QuestionInstallationManager
1118
- '#Call to an undefined method Composer\\Installer\\InstallationManager::getOperations#'
1219
- '#\$package of method Composer\\Package\\Version\\VersionSelector\:\:findRecommendedRequireVersion\(\) expects Composer\\Package\\PackageInterface, Composer\\Package\\PackageInterface\|true given#'
1320
# ScriptExecutor
1421
- '#Call to static method cerebroBinary\(\) on an unknown class Viserio\\Component\\Console\\Application#'
22+
- '#Parameter \#1 \$stream of class Symfony\\Component\\Console\\Output\\StreamOutput constructor expects resource, resource\|false given#'
1523

1624
- '#Call to an undefined method Composer\\DependencyResolver\\Operation\\OperationInterface\:\:getPackage#'
1725

@@ -22,5 +30,6 @@ parameters:
2230
- '#Call to an undefined method Composer\\Downloader\\DownloaderInterface\:\:getCacheKey#'
2331
# ParallelDownloader
2432
- '#Call to an undefined static method Composer\\Util\\RemoteFilesystem\:\:getRemoteContents#'
33+
- '#Call to function method_exists\(\) with #'
2534
# Discovery
2635
- '#does not call parent constructor from Composer\\Repository\\ComposerRepository#'

src/Common/Configurator/AbstractConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function write($messages): void
9292
*/
9393
protected function isFileMarked(string $packageName, string $file): bool
9494
{
95-
return \is_file($file) && \mb_strpos(\file_get_contents($file), \sprintf('###> %s ###', $packageName)) !== false;
95+
return \is_file($file) && \mb_strpos((string) \file_get_contents($file), \sprintf('###> %s ###', $packageName)) !== false;
9696
}
9797

9898
/**

src/Common/Traits/ExpandTargetDirTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
trait ExpandTargetDirTrait
66
{
77
/**
8-
* @param array $options
9-
* @param string $target
8+
* @param string[] $options
9+
* @param string $target
1010
*
1111
* @return string
1212
*/

src/Discovery/ClassFinder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static function find(string $directory): array
2020

2121
/** @var \SplFileInfo $file */
2222
foreach ($finder as $file) {
23-
$realPath = $file->getRealPath();
23+
$realPath = (string) $file->getRealPath();
2424
$class = self::findClassOrTraitOrInterface($realPath);
2525

2626
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
@@ -50,7 +50,7 @@ public static function find(string $directory): array
5050
private static function findClassOrTraitOrInterface(string $path): ?string
5151
{
5252
$namespace = null;
53-
$tokens = \token_get_all(\file_get_contents($path));
53+
$tokens = \token_get_all((string) \file_get_contents($path));
5454

5555
foreach ($tokens as $key => $token) {
5656
if (\is_array($token)) {

src/Discovery/Configurator/EnvConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function unconfigure(PackageContract $package): void
7575
$contents = \preg_replace(
7676
\sprintf('{%s*###> %s ###.*###< %s ###%s+}s', "\n", $package->getName(), $package->getName(), "\n"),
7777
'',
78-
\file_get_contents($env),
78+
(string) \file_get_contents($env),
7979
-1,
8080
$count
8181
);

src/Discovery/Configurator/GitIgnoreConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function unconfigure(PackageContract $package): void
5454
$contents = \preg_replace(
5555
\sprintf('{%s*###> %s ###.*###< %s ###%s+}s', "\n", $package->getName(), $package->getName(), "\n"),
5656
"\n",
57-
\file_get_contents($file),
57+
(string) \file_get_contents($file),
5858
-1,
5959
$count
6060
);

src/Discovery/Discovery.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ public function onCommand(CommandEvent $event): void
310310
if ($event->getInput()->hasOption('no-suggest')) {
311311
$event->getInput()->setOption('no-suggest', true);
312312
}
313+
314+
if ($event->getInput()->hasOption('remove-vcs')) {
315+
$event->getInput()->setOption('remove-vcs', true);
316+
}
313317
}
314318

315319
/**
@@ -621,11 +625,11 @@ private function updateComposerLock(): void
621625
$lockFile,
622626
$this->composer->getRepositoryManager(),
623627
$this->composer->getInstallationManager(),
624-
$composerJson
628+
(string) $composerJson
625629
);
626630

627631
$lockData = $locker->getLockData();
628-
$lockData['_content-hash'] = Locker::getContentHash($composerJson);
632+
$lockData['_content-hash'] = Locker::getContentHash((string) $composerJson);
629633

630634
$lockFile->write($lockData);
631635
}
@@ -786,14 +790,16 @@ private function doUninstall(PackageContract $package, PackageConfigurator $pack
786790
*/
787791
private function getErrorMessage(): ?string
788792
{
789-
$errorMessage = null;
790-
791793
if (! \extension_loaded('openssl')) {
792-
$errorMessage = 'You must enable the openssl extension in your "php.ini" file.';
793-
} elseif (\version_compare('1.6', Composer::VERSION, '>')) {
794-
$errorMessage = \sprintf('Your version "%s" of Composer is too old; Please upgrade.', Composer::VERSION);
794+
return 'You must enable the openssl extension in your "php.ini" file.';
795+
}
796+
797+
\preg_match_all('/\d+.\d+.\d+/m', Composer::VERSION, $matches, \PREG_SET_ORDER, 0);
798+
799+
if ($matches !== null && \version_compare('1.6.0', $matches[0], '<=')) {
800+
return \sprintf('Your version "%s" of Composer is too old; Please upgrade.', Composer::VERSION);
795801
}
796802

797-
return $errorMessage;
803+
return null;
798804
}
799805
}

src/Discovery/Installer/ConfiguratorInstaller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ protected function saveConfiguratorsToLockFile(array $autoload, string $name): a
121121
}
122122

123123
if ($this->lock->has(self::LOCK_KEY)) {
124-
$configurators = \array_merge($this->lock->get(self::LOCK_KEY), $configurators);
124+
$configurators = \array_merge((array) $this->lock->get(self::LOCK_KEY), $configurators);
125125
}
126126

127127
$this->lock->add(self::LOCK_KEY, $configurators);

0 commit comments

Comments
 (0)