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

Commit

Permalink
style : cs fixes (#30)
Browse files Browse the repository at this point in the history
feat : fixed phpstan errors
  • Loading branch information
prisis authored Nov 22, 2019
1 parent b708170 commit 3aa3263
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 34 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/coding-standard.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: 'Coding Standard'
name: "PHP Coding Standard"

on: [push, pull_request]
on:
push:
paths:
- "**.php"
pull_request:
paths:
- "**.php"

jobs:
php-cs-fixer:
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
name: 'Markdown Lint'
name: "Markdown Lint"

on: [push, pull_request]

jobs:
text-lint:
name: 'Markdown lint'
name: "Markdown lint"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Setup node
uses: actions/setup-node@v1
with:
node-version: '10.16.0'
node-version: "10.16.0"

- run: npm install

- run: npm run lint
25 changes: 17 additions & 8 deletions .github/workflows/static-analyze.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
name: 'Static analyzing'
name: 'PHP Static Analyze'

on:
push:
paths:
- '**.php'
- "**.php"
pull_request:
paths:
- '**.php'
- "**.php"

jobs:
php-cs-fixer:
name: 'PHPStan'
name: "PHPStan"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup PHP

- name: "Setup PHP"
uses: shivammathur/setup-php@master
with:
php-version: 7.3
- run: composer install
- name: 'analyze php code'
run: composer phpstan

- name: "Install Automatic Composer Prefetcher"
run: composer global require --no-progress --no-scripts --no-plugins narrowspark/automatic-composer-prefetcher:dev-master

- name: "analyze php code"
run: |
echo ::group::Composer install
composer update --no-progress --no-suggest --no-interaction --ansi
echo ::endgroup::
composer phpstan
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"require-dev": {
"composer/composer": "^1.6.0 || ^1.7.1 || ^1.8.0 || ^1.9.0",
"mockery/mockery": "^1.2.4",
"narrowspark/automatic-common": "dev-master",
"narrowspark/automatic-common": "^0.13.0",
"narrowspark/coding-standard": "^3.2.0",
"narrowspark/testing-helper": "^8.0.2",
"phpunit/phpunit": "^8.4.2",
Expand Down
5 changes: 4 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ includes:
- %rootDir%/../phpstan-phpunit/extension.neon
- %rootDir%/../phpstan-phpunit/rules.neon
- %rootDir%/../phpstan-strict-rules/rules.neon
# - %rootDir%/../../thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
- %rootDir%/../../thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
- %rootDir%/../phpstan/conf/bleedingEdge.neon
- %rootDir%/../../slam/phpstan-extensions/conf/slam-rules.neon

Expand All @@ -15,3 +15,6 @@ parameters:

autoload_directories:
- %currentWorkingDirectory%/src/

ignoreErrors:
- '#returns array<string, array<string, array|string>>#'
9 changes: 4 additions & 5 deletions src/AbstractClassConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use function preg_replace;
use function sprintf;
use function str_repeat;
use function unlink;

/**
* @internal
Expand Down Expand Up @@ -125,7 +124,7 @@ public function unconfigure(PackageContract $package): void

$contents[$env] = (string) file_get_contents($filePath);

unlink($filePath);
$this->filesystem->remove($filePath);
}

foreach ($sortedClasses as $env => $data) {
Expand All @@ -137,7 +136,7 @@ public function unconfigure(PackageContract $package): void
}

foreach ($contents as $key => $content) {
$this->dump($this->getConfFile((string) $key), $content);
$this->dump($this->getConfFile($key), $content);
}
}

Expand All @@ -160,7 +159,7 @@ protected function getConfFile(string $type): string
*
* @param \Narrowspark\Automatic\Common\Contract\Package $package
* @param string $filePath
* @param array $classes
* @param array<string, array<string, array|string>> $classes
* @param string $env
*
* @return string
Expand Down Expand Up @@ -206,7 +205,7 @@ protected function replaceContent(string $content, PackageContract $package): st
* @param \Narrowspark\Automatic\Common\Contract\Package $package
* @param string $key
*
* @return array
* @return array<string, array<string, array|string>>
*/
abstract protected function getSortedClasses(PackageContract $package, string $key): array;
}
8 changes: 3 additions & 5 deletions src/BootstrapConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
use Narrowspark\Automatic\Common\Contract\Package as PackageContract;
use function array_values;
use function count;
use function file_exists;
use function file_get_contents;
use function implode;
use function ltrim;
use function sprintf;
use function strpos;
use function unlink;

final class BootstrapConfigurator extends AbstractClassConfigurator
{
Expand Down Expand Up @@ -48,10 +46,10 @@ protected function generateFileContent(
array $classes,
string $env
): string {
if (file_exists($filePath)) {
if ($this->filesystem->exists($filePath)) {
$content = (string) file_get_contents($filePath);

unlink($filePath);
$this->filesystem->remove($filePath);
} else {
$content = '<?php' . "\n\n" . 'declare(strict_types=1);' . "\n\n" . 'return [' . "\n" . '];' . "\n";
}
Expand Down Expand Up @@ -88,7 +86,7 @@ protected function getSortedClasses(PackageContract $package, string $key): arra
* Builds a array value with class names.
*
* @param \Narrowspark\Automatic\Common\Contract\Package $package
* @param array $classes
* @param array<string, array> $classes
*
* @return string
*/
Expand Down
6 changes: 3 additions & 3 deletions src/OptionsConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function configure(PackageContract $package): void
$content .= $this->print($options[$env]) . ';' . "\n";

$this->dump(
$this->getConfigFilePath($package, $env),
$this->getConfigFilePath($package, (string) $env),
$content
);
}
Expand All @@ -83,8 +83,8 @@ public function unconfigure(PackageContract $package): void
/**
* Returns a pretty php array for saving or output.
*
* @param array $data
* @param int $indentLevel
* @param array<int | string, string> $data
* @param int $indentLevel
*
* @return string
*/
Expand Down
8 changes: 3 additions & 5 deletions src/ServiceProviderConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
use Narrowspark\Automatic\Common\Contract\Package as PackageContract;
use Narrowspark\Automatic\Configurator\Traits\GetSortedClassesTrait;
use function count;
use function file_exists;
use function file_get_contents;
use function sprintf;
use function strpos;
use function unlink;

final class ServiceProviderConfigurator extends AbstractClassConfigurator
{
Expand Down Expand Up @@ -47,10 +45,10 @@ protected function generateFileContent(
array $classes,
string $type
): string {
if (file_exists($filePath)) {
if ($this->filesystem->exists($filePath)) {
$content = (string) file_get_contents($filePath);

unlink($filePath);
$this->filesystem->remove($filePath);
} else {
$content = '<?php' . "\n\n" . 'declare(strict_types=1);' . "\n\n" . 'return [' . "\n" . '];' . "\n";
}
Expand All @@ -70,7 +68,7 @@ protected function generateFileContent(
* Builds a array value with class names.
*
* @param \Narrowspark\Automatic\Common\Contract\Package $package
* @param array $classes
* @param string[] $classes
* @param string $type
*
* @return string
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/GetSortedClassesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait GetSortedClassesTrait
* @param \Narrowspark\Automatic\Common\Contract\Package $package
* @param string $key
*
* @return array
* @return array<string, array<string, string>>
*/
protected function getSortedClasses(PackageContract $package, string $key): array
{
Expand Down

0 comments on commit 3aa3263

Please sign in to comment.