Skip to content

Commit

Permalink
Add rector and apply suggestions (#38)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergei Predvoditelev <[email protected]>
  • Loading branch information
xepozz and vjik authored Sep 12, 2023
1 parent 0a3a2e9 commit 8856ebb
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 23 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/rector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

name: rector

jobs:
rector:
uses: yiisoft/actions/.github/workflows/rector.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
['7.4']
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"httpsoft/http-message": "^1.0",
"maglnet/composer-require-checker": "^3.8|^4.2",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.18.2",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.8",
Expand Down
27 changes: 27 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_74,
]);

$rectorConfig->skip([
ClosureToArrowFunctionRector::class,
]);
};
22 changes: 1 addition & 21 deletions src/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,6 @@ public function getValue(): string
/**
* Creates a cookie copy with a new time the cookie expires.
*
* @param DateTimeInterface $dateTime
*
* @return static
*
* @see $expires for more information.
*/
public function withExpires(DateTimeInterface $dateTime): self
Expand Down Expand Up @@ -298,10 +294,6 @@ public function expireWhenBrowserIsClosed(): self

/**
* Creates a cookie copy with a new domain set.
*
* @param string $domain
*
* @return static
*/
public function withDomain(string $domain): self
{
Expand All @@ -325,8 +317,6 @@ public function getDomain(): ?string
*
* @param string $path To be set for the cookie.
*
* @return static
*
* @see $path for more information.
*/
public function withPath(string $path): self
Expand Down Expand Up @@ -381,10 +371,6 @@ public function isSecure(): bool

/**
* Creates a cookie copy that would be accessible only through the HTTP protocol.
*
* @param bool $httpOnly
*
* @return static
*/
public function withHttpOnly(bool $httpOnly = true): self
{
Expand All @@ -405,10 +391,6 @@ public function isHttpOnly(): bool

/**
* Creates a cookie copy with SameSite attribute.
*
* @param string $sameSite
*
* @return static
*/
public function withSameSite(string $sameSite): self
{
Expand Down Expand Up @@ -449,8 +431,6 @@ public function getSameSite(): ?string
/**
* Adds the cookie to the response and returns it.
*
* @param ResponseInterface $response
*
* @return ResponseInterface Response with added cookie.
*/
public function addToResponse(ResponseInterface $response): ResponseInterface
Expand Down Expand Up @@ -582,7 +562,7 @@ public static function fromCookieString(string $string): self
private static function splitCookieAttribute(string $attribute): array
{
$parts = explode('=', $attribute, 2);
$parts[1] = $parts[1] ?? null;
$parts[1] ??= null;

return $parts;
}
Expand Down
1 change: 0 additions & 1 deletion src/CookieEncryptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use function rawurldecode;
use function rawurlencode;
use function strlen;
use function strpos;
use function substr;

/**
Expand Down
1 change: 0 additions & 1 deletion src/CookieSigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Yiisoft\Security\Mac;

use function md5;
use function strpos;
use function strlen;
use function substr;

Expand Down

0 comments on commit 8856ebb

Please sign in to comment.