Skip to content

Commit 7a355cf

Browse files
committed
chore: use code style PER Coding Style 3.0
Add missing license header like most files.
1 parent 0846318 commit 7a355cf

16 files changed

+115
-107
lines changed

.php-cs-fixer.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
$config = new PhpCsFixer\Config();
55
$rules = [
6-
'@PSR12' => true, // The default rule.
6+
'@PER-CS3x0' => true, // The default rule.
77
'@autoPHPMigration' => true, // Uses min PHP version for regular migrations.
88
'blank_line_after_opening_tag' => false, // Do not waste space between <?php and declare.
9-
'declare_strict_types' => true,
9+
'concat_space' => ['spacing' => 'none'], // Custom library style.
10+
'declare_strict_types' => true, // Enforce strict code.
1011
'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false],
1112
'php_unit_attributes' => true,
1213
'php_unit_construct' => true,
@@ -20,5 +21,7 @@
2021
$config->setRules($rules);
2122
$config->setHideProgress(true);
2223
$config->setRiskyAllowed(true);
24+
$config->setUsingCache(false);
25+
$config->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect());
2326

2427
return $config;

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
}
2020
],
2121
"scripts": {
22-
"fix:syntax": "./vendor/bin/php-cs-fixer fix ./src --using-cache=no",
23-
"fix:syntax_tests": "./vendor/bin/php-cs-fixer fix ./tests --using-cache=no",
22+
"fix:syntax": "./vendor/bin/php-cs-fixer fix ./src",
23+
"fix:syntax_tests": "./vendor/bin/php-cs-fixer fix ./tests",
2424
"test:unit": "./vendor/bin/phpunit",
2525
"test:unit_offline": "./vendor/bin/phpunit --exclude-group=online",
2626
"test:typing": "./vendor/bin/phpstan analyse",
27-
"test:syntax": "./vendor/bin/php-cs-fixer fix ./src --dry-run --stop-on-violation --using-cache=no",
28-
"test:syntax_tests": "./vendor/bin/php-cs-fixer fix ./tests --dry-run --stop-on-violation --using-cache=no"
27+
"test:syntax": "./vendor/bin/php-cs-fixer fix ./src --dry-run --stop-on-violation",
28+
"test:syntax_tests": "./vendor/bin/php-cs-fixer fix ./tests --dry-run --stop-on-violation"
2929
},
3030
"require": {
3131
"php": ">=8.2",

src/ContentEncoding.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of the WebPush library.
4+
*
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*/
28

39
namespace Minishlink\WebPush;
410

511
enum ContentEncoding: string
612
{
713
/** Not recommended. Outdated historic encoding. Was used by some browsers before rfc standard. */
8-
case aesgcm = "aesgcm";
14+
case aesgcm = 'aesgcm';
915
/** Defined in rfc8291. */
10-
case aes128gcm = "aes128gcm";
16+
case aes128gcm = 'aes128gcm';
1117
}

src/Encryption.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php declare(strict_types=1);
2-
32
/*
43
* This file is part of the WebPush library.
54
*
@@ -38,7 +37,7 @@ public static function padPayload(string $payload, int $maxLengthToPad, ContentE
3837
}
3938

4039
// @phpstan-ignore deadCode.unreachable
41-
throw new \ErrorException("This content encoding is not implemented.");
40+
throw new \ErrorException('This content encoding is not implemented.');
4241
}
4342

4443
/**
@@ -146,7 +145,7 @@ public static function deterministicEncrypt(
146145
public static function getContentCodingHeader(string $salt, string $localPublicKey, ContentEncoding $contentEncoding): string
147146
{
148147
if ($contentEncoding === ContentEncoding::aesgcm) {
149-
return "";
148+
return '';
150149
}
151150
if ($contentEncoding === ContentEncoding::aes128gcm) {
152151
return $salt
@@ -156,7 +155,7 @@ public static function getContentCodingHeader(string $salt, string $localPublicK
156155
}
157156

158157
// @phpstan-ignore deadCode.unreachable
159-
throw new \ValueError("This content encoding is not implemented.");
158+
throw new \ValueError('This content encoding is not implemented.');
160159
}
161160

162161
/**
@@ -286,9 +285,9 @@ private static function getIKM(string $userAuthToken, string $userPublicKey, str
286285
if ($contentEncoding === ContentEncoding::aesgcm) {
287286
$info = 'Content-Encoding: auth'.chr(0);
288287
} elseif ($contentEncoding === ContentEncoding::aes128gcm) {
289-
$info = "WebPush: info".chr(0).$userPublicKey.$localPublicKey;
288+
$info = 'WebPush: info'.chr(0).$userPublicKey.$localPublicKey;
290289
} else {
291-
throw new \ValueError("This content encoding is not implemented.");
290+
throw new \ValueError('This content encoding is not implemented.');
292291
}
293292

294293
return self::hkdf($userAuthToken, $sharedSecret, $info, 32);

src/MessageSentReport.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<?php declare(strict_types=1);
2-
/**
2+
/*
3+
* This file is part of the WebPush library.
4+
*
35
* @author Igor Timoshenkov [[email protected]]
4-
* @started: 03.09.2018 9:21
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
59
*/
610

711
namespace Minishlink\WebPush;
@@ -19,8 +23,7 @@ public function __construct(
1923
protected ?ResponseInterface $response = null,
2024
protected bool $success = true,
2125
protected string $reason = 'OK'
22-
) {
23-
}
26+
) {}
2427

2528
public function isSuccess(): bool
2629
{

src/Notification.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
<?php
2-
3-
declare(strict_types=1);
4-
1+
<?php declare(strict_types=1);
52
/*
63
* This file is part of the WebPush library.
74
*
@@ -24,8 +21,7 @@ public function __construct(
2421
private ?string $payload,
2522
private array $options,
2623
private array $auth
27-
) {
28-
}
24+
) {}
2925

3026
public function getSubscription(): SubscriptionInterface
3127
{

src/Subscription.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
<?php
2-
3-
declare(strict_types=1);
4-
1+
<?php declare(strict_types=1);
52
/*
63
* This file is part of the WebPush library.
74
*

src/SubscriptionInterface.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
<?php
2-
3-
declare(strict_types=1);
4-
1+
<?php declare(strict_types=1);
52
/*
63
* This file is part of the WebPush library.
74
*

src/Utils.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
<?php
2-
3-
declare(strict_types=1);
4-
1+
<?php declare(strict_types=1);
52
/*
63
* This file is part of the WebPush library.
74
*
@@ -82,8 +79,8 @@ public static function checkRequirementExtension(): void
8279
}
8380

8481
// Check optional extensions.
85-
if (!extension_loaded("bcmath") && !extension_loaded("gmp")) {
86-
trigger_error("It is highly recommended to install the GMP or BCMath extension to speed up calculations. The fastest available calculator implementation will be automatically selected at runtime.", E_USER_NOTICE);
82+
if (!extension_loaded('bcmath') && !extension_loaded('gmp')) {
83+
trigger_error('It is highly recommended to install the GMP or BCMath extension to speed up calculations. The fastest available calculator implementation will be automatically selected at runtime.', E_USER_NOTICE);
8784
}
8885
}
8986

src/VAPID.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
<?php
2-
3-
declare(strict_types=1);
4-
1+
<?php declare(strict_types=1);
52
/*
63
* This file is part of the WebPush library.
74
*

0 commit comments

Comments
 (0)