Skip to content

Commit 885ed32

Browse files
committed
style(phpcs): Update styling to phpcs fixer 3
1 parent 62ad4aa commit 885ed32

File tree

5 files changed

+71
-101
lines changed

5 files changed

+71
-101
lines changed

.php-cs-fixer.dist.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
$header = <<<'EOF'
4+
@package PHP Prefixer REST API CLI
5+
6+
@author Desarrollos Inteligentes Virtuales, SL. <[email protected]>
7+
@copyright Copyright (c)2019-2021 Desarrollos Inteligentes Virtuales, SL. All rights reserved.
8+
@license MIT
9+
10+
@see https://php-prefixer.com
11+
EOF;
12+
13+
// Symfony PHP framework 5.4/.php-cs-fixer.dist.php
14+
// https://github.com/symfony/symfony/blob/5.4/.php-cs-fixer.dist.php
15+
16+
// PHP CS Fixer 3.0.0 config. working with Laravel 8 / PHP8
17+
// https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200#gistcomment-3749314
18+
19+
return (new PhpCsFixer\Config())
20+
->setRules([
21+
'@PHP71Migration' => true,
22+
'@PHPUnit75Migration:risky' => true,
23+
'@Symfony' => true,
24+
'@Symfony:risky' => true,
25+
'protected_to_private' => false,
26+
'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => false],
27+
28+
'header_comment' => ['header' => $header],
29+
])
30+
->setRiskyAllowed(true)
31+
->setFinder(
32+
(new PhpCsFixer\Finder())
33+
->in(__DIR__.'/app')
34+
->in(__DIR__.'/tests')
35+
->append([__FILE__])
36+
->notPath('#/Fixtures/#')
37+
->exclude([
38+
// directories containing files with content that is autogenerated by `var_export`, which breaks CS in output code
39+
// fixture templates
40+
'Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom',
41+
// resource templates
42+
'Symfony/Bundle/FrameworkBundle/Resources/views/Form',
43+
// explicit trigger_error tests
44+
'Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/',
45+
'Symfony/Component/Intl/Resources/data/',
46+
])
47+
// Support for older PHPunit version
48+
->notPath('Symfony/Bridge/PhpUnit/SymfonyTestsListener.php')
49+
->notPath('#Symfony/Bridge/PhpUnit/.*Mock\.php#')
50+
->notPath('#Symfony/Bridge/PhpUnit/.*Legacy#')
51+
// file content autogenerated by `var_export`
52+
->notPath('Symfony/Component/Translation/Tests/fixtures/resources.php')
53+
// file content autogenerated by `VarExporter::export`
54+
->notPath('Symfony/Component/Serializer/Tests/Fixtures/serializer.class.metadata.php')
55+
// test template
56+
->notPath('Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_entry_label.html.php')
57+
// explicit trigger_error tests
58+
->notPath('Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php')
59+
)
60+
->setCacheFile('.php-cs-fixer.cache')
61+
;

.php_cs.dist

Lines changed: 0 additions & 91 deletions
This file was deleted.

app/Commands/PrefixCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ private function renderOutput($state, $start)
147147

148148
switch ($state) {
149149
case 'success':
150-
$this->info('PHP-Prefixer: project prefixed successfully');
151-
$this->notify('PHP-Prefixer CLI', 'Project prefixed successfully');
150+
$this->info('PHP-Prefixer: project prefixing completed');
151+
$this->notify('PHP-Prefixer CLI', 'Project prefixing completed');
152152
$this->info($formattedProcessingTime);
153153

154154
return 0;

app/Support/PrefixerClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class PrefixerClient
2020
{
21-
const API_BASE_URI = 'https://php-prefixer.com/api/v1';
21+
public const API_BASE_URI = 'https://php-prefixer.com/api/v1';
2222

2323
private $personalAccessToken;
2424

@@ -171,7 +171,7 @@ private function headers()
171171
private function filename($response)
172172
{
173173
$contentDisposition = $response->getHeader('Content-Disposition');
174-
list(, $filename) = explode('filename=', $contentDisposition[0]);
174+
[, $filename] = explode('filename=', $contentDisposition[0]);
175175

176176
return $filename;
177177
}

app/Support/ZipManager.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
class ZipManager
2020
{
2121
// Patterns to produce clean packages
22-
const HIDDEN_FILES_PATTERN = '~(\/(\.[^/]+))|(^\.[^/]+)~';
23-
const VENDOR_PATTERN = '~(^vendor\/|\/vendor\/)~';
24-
const NODE_MODULES_PATTERN = '~(^node_modules\/|\/node_modules\/)~';
22+
public const HIDDEN_FILES_PATTERN = '~(\/(\.[^/]+))|(^\.[^/]+)~';
23+
public const VENDOR_PATTERN = '~(^vendor\/|\/vendor\/)~';
24+
public const NODE_MODULES_PATTERN = '~(^node_modules\/|\/node_modules\/)~';
2525

2626
private $excludeVendor = true;
2727

@@ -88,7 +88,7 @@ private function addDirRecursiveToZipFile(string $projectPath): ZipFile
8888
return $this->addDirRecursive($zipFile, $projectPath);
8989
}
9090

91-
private function addDirRecursive(ZipFile $zipFile, string $inputDir, string $localPath = '/', ?int $compressionMethod = null): ZipFile
91+
private function addDirRecursive(ZipFile $zipFile, string $inputDir, string $localPath = '/', int $compressionMethod = null): ZipFile
9292
{
9393
if ('' === $inputDir) {
9494
throw new InvalidArgumentException('The input directory is not specified');
@@ -108,7 +108,7 @@ private function addFilesFromIterator(
108108
ZipFile $zipFile,
109109
\Iterator $iterator,
110110
string $localPath = '/',
111-
?int $compressionMethod = null
111+
int $compressionMethod = null
112112
): ZipFile {
113113
if ('' !== $localPath) {
114114
$localPath = trim($localPath, '\\/');
@@ -166,7 +166,7 @@ private function doAddFiles(
166166
string $fileSystemDir,
167167
array $files,
168168
string $zipPath,
169-
?int $compressionMethod = null
169+
int $compressionMethod = null
170170
): void {
171171
$fileSystemDir = rtrim($fileSystemDir, '/\\').\DIRECTORY_SEPARATOR;
172172

0 commit comments

Comments
 (0)