Add PHP-CS-Fixer to check for unused imports

This commit is contained in:
Zach Borboa
2023-06-24 17:16:35 -07:00
parent c9ad23cf5c
commit 128a0c1ea2
10 changed files with 29 additions and 17 deletions
+1
View File
@@ -20,6 +20,7 @@
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "*",
"ext-gd": "*",
"friendsofphp/php-cs-fixer": "*",
"phpcompatibility/php-compatibility": "dev-develop",
"phpcsstandards/phpcsutils": "@alpha",
"phpunit/phpunit": "*",
-1
View File
@@ -2,7 +2,6 @@
require __DIR__ . '/../vendor/autoload.php';
require 'flickr.class.php';
use Curl\Curl;
use Flickr\Flickr;
$flickr = new Flickr();
@@ -1,7 +1,6 @@
<?php
require __DIR__ . '/../vendor/autoload.php';
use Curl\Curl;
use Curl\MultiCurl;
$concurrency = 3;
-2
View File
@@ -2,8 +2,6 @@
namespace Curl;
use Curl\CaseInsensitiveArray;
class ArrayUtil
{
/**
-4
View File
@@ -2,10 +2,6 @@
namespace Curl;
use Curl\ArrayUtil;
use Curl\BaseCurl;
use Curl\Url;
class Curl extends BaseCurl
{
const VERSION = '9.17.1';
-4
View File
@@ -2,10 +2,6 @@
namespace Curl;
use Curl\ArrayUtil;
use Curl\BaseCurl;
use Curl\Url;
class MultiCurl extends BaseCurl
{
public $baseUrl = null;
-2
View File
@@ -2,8 +2,6 @@
namespace Curl;
use Curl\StringUtil;
class Url
{
private $baseUrl = null;
+13
View File
@@ -0,0 +1,13 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(dirname(__DIR__));
$config = new PhpCsFixer\Config();
$config
->setRules([
'no_unused_imports' => true,
])
->setFinder($finder);
return $config;
+1 -1
View File
@@ -4008,7 +4008,7 @@ class PHPCurlClassTest extends \PHPUnit\Framework\TestCase
$expected_response = '{"name":"Alice","email":"alice@example.com"}';
$user = new \Helper\User('Alice', 'alice@example.com');
$user = new User('Alice', 'alice@example.com');
$this->assertEquals($expected_response, json_encode($user));
$test = new Test();
+14 -2
View File
@@ -132,6 +132,7 @@ if [[ ! -z "${is_null}" ]]; then
errors+=("${result}")
fi
# Run PHP_CodeSniffer.
if [[ "${CI_PHP_VERSION}" == "7.0" ]]; then :
elif [[ "${CI_PHP_VERSION}" == "7.1" ]]; then :
else
@@ -153,8 +154,19 @@ else
-s \
.
if [[ "${?}" -ne 0 ]]; then
echo "Error: found coding standard violation(s)"
errors+=("found coding standard violation(s)")
echo "Error: found PHP_CodeSniffer coding standard violation(s)"
errors+=("found PHP_CodeSniffer coding standard violation(s)")
fi
fi
# Run PHP-CS-Fixer.
if [[ "${CI_PHP_VERSION}" == "7.0" ]]; then :
else
vendor/bin/php-cs-fixer --version
vendor/bin/php-cs-fixer fix --ansi --config="tests/.php-cs-fixer.php" --diff --dry-run
if [[ "${?}" -ne 0 ]]; then
echo "Error: found PHP-CS-Fixer coding standard violation(s)"
errors+=("found PHP-CS-Fixer coding standard violation(s)")
fi
fi