Skip to content

Commit

Permalink
phpcs: init
Browse files Browse the repository at this point in the history
  • Loading branch information
OxCom committed Jul 13, 2023
1 parent 13af1ad commit e6909fa
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
/vendor/
/var/

.phpcs-cache
.phpunit.result.cache
composer.lock
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: php

php:
- 8.1
- 8.2

before_install:
- curl -s https://getcomposer.org/installer | php
- composer req roave/security-advisories:dev-master --no-update
- composer install

script:
- php -v
- vendor/bin/phpcs --standard=psr2 src/
- vendor/bin/phpunit

after_success:
- bash <(curl -s https://codecov.io/bash)
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
"require-dev": {
"roave/security-advisories": "dev-latest",
"symfony/test-pack": "^1.1",
"symfony/framework-bundle": "^6.3"
"symfony/framework-bundle": "^6.3",
"squizlabs/php_codesniffer": "^3.7",
"slevomat/coding-standard": "^8.13"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
28 changes: 28 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>

<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">

<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="encoding" value="utf8" />

<rule ref="PSR12" />

<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"/>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions">
<properties>
<property name="includeSpecialFunctions" value="true"/>
</properties>
</rule>

<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array" value="eval=>null,dd=>null,sizeof=>count,delete=>unset,print=>echo,dump=>null,var_dump=>null,create_function=>null,eval=>null,system=>null"/>
</properties>
</rule>

<file>src/</file>
</ruleset>
21 changes: 21 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
includes:
- vendor/phpstan/phpstan-symfony/extension.neon
- vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
level: 1

paths:
- src
excludePaths:
- tests
- var
- vendor

parallel:
jobSize: 32
maximumNumberOfProcesses: 64
minimumNumberOfJobsPerProcess: 4

symfony:
containerXmlPath: var/cache/test/App_KernelDevDebugContainer.xml
12 changes: 7 additions & 5 deletions src/Providers/ImgProxy/Builder/Processing/Zoom.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Zoom implements ProcessOptionInterface
{
private const ZOOM_TPL = 'z:%zoom_x_y';
private const ZOOM_TPL = 'z:%zoom_x_y';
private const ZOOM_XY_TPL = 'z:%zoom_x:%zoom_y';

public function __construct(protected string $zoomX = "1", protected ?string $zoomY = null)
Expand All @@ -33,11 +33,13 @@ public function __construct(protected string $zoomX = "1", protected ?string $zo
public function compile(): string
{
$equal = $this->zoomX === $this->zoomY;
$tpl = $equal ? self::ZOOM_TPL : self::ZOOM_XY_TPL;
$tpl = $equal ? self::ZOOM_TPL : self::ZOOM_XY_TPL;

return \strtr($tpl, $equal
? ['%zoom_x_y' => $this->zoomX]
: ['%zoom_x' => $this->zoomX, '%zoom_y' => $this->zoomY]
return \strtr(
$tpl,
$equal
? ['%zoom_x_y' => $this->zoomX]
: ['%zoom_x' => $this->zoomX, '%zoom_y' => $this->zoomY]
);
}
}
5 changes: 3 additions & 2 deletions src/Providers/ImgProxy/Security.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<?php

namespace SymfonyImageProxyBundle\Providers\ImgProxy;

class Security
{
private string $key;
private string $salt;

public function __construct(string $key, string $salt, private readonly int $size = 32)
{
if (\mb_strlen($key) > 0) {
if ($key !== '') {
try {
$this->key = \pack('H', \mb_strtoupper($key));
} catch (\Throwable $e) {
throw new \InvalidArgumentException('The sign key must be hex-encoded string', $e->getCode(), $e);
}
}

if (\mb_strlen($salt) > 0) {
if ($salt !== '') {
try {
$this->salt = \pack('H', \mb_strtoupper($salt));
} catch (\Throwable $e) {
Expand Down
1 change: 0 additions & 1 deletion src/Providers/Thumbor/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

class Security
{

}

0 comments on commit e6909fa

Please sign in to comment.