Skip to content

Commit

Permalink
apply CI fix
Browse files Browse the repository at this point in the history
  • Loading branch information
guanguans committed Jan 15, 2024
1 parent c592672 commit bd51d97
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 84 deletions.
12 changes: 6 additions & 6 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$header = <<<'EOF'
This file is part of the guanguans/soar-php.
$header = <<<'HEADER'
This file is part of the guanguans/soar-php.
(c) guanguans <ityaozm@gmail.com>
(c) guanguans <ityaozm@gmail.com>
This source file is subject to the MIT license that is bundled.
EOF;
This source file is subject to the MIT license that is bundled.
HEADER;

/** @noinspection PhpParamsInspection */
$finder = Finder::create()
Expand Down Expand Up @@ -66,7 +66,7 @@
'@PHP70Migration:risky' => true,
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
// '@PHP73Migration' => true,
'@PHP73Migration' => true,
// '@PHP74Migration' => true,
// '@PHP74Migration:risky' => true,
// '@PHP80Migration' => true,
Expand Down
20 changes: 10 additions & 10 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
testdox="true"
verbose="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<directory>src/Support</directory>
<file>src/PDOConnector-xxx.php</file>
</exclude>
</coverage>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
<exclude>
<directory>src/Support</directory>
<file>src/PDOConnector-xxx.php</file>
</exclude>
</whitelist>
</filter>
<listeners>
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener">
<arguments>
Expand Down
12 changes: 4 additions & 8 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector;
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector;
use Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector;
use Rector\CodingStyle\Rector\Closure\StaticClosureRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
Expand Down Expand Up @@ -48,7 +47,7 @@
// $rectorConfig->disableParallel();
$rectorConfig->parallel(240);
$rectorConfig->phpstanConfig(__DIR__.'/phpstan.neon');
$rectorConfig->phpVersion(PhpVersion::PHP_72);
$rectorConfig->phpVersion(PhpVersion::PHP_73);
// $rectorConfig->cacheClass(FileCacheStorage::class);
// $rectorConfig->cacheDirectory(__DIR__.'/build/rector');
// $rectorConfig->containerCacheDirectory(__DIR__.'/build/rector');
Expand Down Expand Up @@ -79,7 +78,6 @@

$rectorConfig->skip([
// rules
// AddArrayDefaultToArrayPropertyRector::class,
// CallableThisArrayToAnonymousFunctionRector::class,
// ChangeAndIfToEarlyReturnRector::class,
// RemoveEmptyClassMethodRector::class,
Expand Down Expand Up @@ -131,9 +129,8 @@
]);

$rectorConfig->sets([
// DowngradeLevelSetList::DOWN_TO_PHP_72,
LevelSetList::UP_TO_PHP_72,
SetList::PHP_72,
DowngradeLevelSetList::DOWN_TO_PHP_73,
LevelSetList::UP_TO_PHP_73,
// SetList::ACTION_INJECTION_TO_CONSTRUCTOR_INJECTION,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
Expand All @@ -148,8 +145,7 @@
SetList::EARLY_RETURN,
SetList::INSTANCEOF,

PHPUnitLevelSetList::UP_TO_PHPUNIT_80,
PHPUnitSetList::PHPUNIT_80,
PHPUnitLevelSetList::UP_TO_PHPUNIT_90,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
]);

Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/HasOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ trait HasOptions
public function __call(string $name, array $arguments)
{
foreach (['add', 'remove', 'only', 'set', 'merge', 'get'] as $prefix) {
if (str_starts_with($name, $prefix)) {
if (0 === strncmp($name, $prefix, \strlen($prefix))) {
$key = '-'.str_snake(substr($name, \strlen($prefix)), '-');
$newName = $prefix.'Option';

Expand Down
2 changes: 0 additions & 2 deletions src/Concerns/WithDumpable.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ trait WithDumpable
{
/**
* @codeCoverageIgnore
*
* @return never-return
*/
public function dd(...$args): void
{
Expand Down
72 changes: 36 additions & 36 deletions src/Support/ComposerScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ public static function dumpSoarDocblock(Event $event): int
require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php';

$prefix = <<<'docblock'
<?php
<?php
declare(strict_types=1);
declare(strict_types=1);
/**
* This file is part of the guanguans/soar-php.
*
* (c) guanguans <ityaozm@gmail.com>
*
* This source file is subject to the MIT license that is bundled.
*/
/**
docblock;
/**
* This file is part of the guanguans/soar-php.
*
* (c) guanguans <ityaozm@gmail.com>
*
* This source file is subject to the MIT license that is bundled.
*/
/**
docblock;

$suffix = <<<'docblock'
* @mixin \Guanguans\SoarPHP\Soar
*/
* @mixin \Guanguans\SoarPHP\Soar
*/

docblock;
docblock;

$methodMapper = [
'add' => ' * @method self add{method}({type} ${name})',
Expand All @@ -64,7 +64,7 @@ public static function dumpSoarDocblock(Event $event): int
$option['type'] = 'int';
}

if (str_starts_with($typeOfMethod, 'get') && null === $option['type']) {
if (0 === strncmp($typeOfMethod, 'get', \strlen('get')) && null === $option['type']) {
$option['type'] = 'mixed';
}

Expand Down Expand Up @@ -93,37 +93,37 @@ public static function dumpSoarConfig(Event $event): int
require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php';

$prefix = <<<'PHP'
<?php
<?php
declare(strict_types=1);
declare(strict_types=1);
/**
* This file is part of the guanguans/soar-php.
*
* (c) guanguans <ityaozm@gmail.com>
*
* This source file is subject to the MIT license that is bundled.
*/
/**
* This file is part of the guanguans/soar-php.
*
* (c) guanguans <ityaozm@gmail.com>
*
* This source file is subject to the MIT license that is bundled.
*/
// +----------------------------------------------------------------------+//
// | 请参考 @see https://github.com/XiaoMi/soar |//
// +----------------------------------------------------------------------+//
// +----------------------------------------------------------------------+//
// | 请参考 @see https://github.com/XiaoMi/soar |//
// +----------------------------------------------------------------------+//
return [
PHP;
return [
PHP;

$suffix = '];'.PHP_EOL;

$code = array_reduce(self::extractOptionsFromHelp(), static function (string $code, array $options): string {
null === $options['default'] and $options['default'] = 'null';

$item = <<<PHP
/**
* {$options['description']}.
*/
'{$options['name']}' => {$options['default']},
/**
* {$options['description']}.
*/
'{$options['name']}' => {$options['default']},
PHP;
PHP;

return $code.PHP_EOL.$item;
}, '');
Expand All @@ -142,7 +142,7 @@ public static function dumpSoarConfig(Event $event): int
public static function extractOptionsFromHelp(): array
{
$arrayMap = array_map(static function (string $option): ?string {
if (! str_starts_with($option, ' ')) {
if (0 !== strncmp($option, ' ', \strlen(' '))) {
return null;
}

Expand All @@ -154,7 +154,7 @@ public static function extractOptionsFromHelp(): array
preg_match('/\\(default .*\\)/', $option[1], $defaults);

$default = $defaults[0] ?? null;
if (\is_string($default) && str_starts_with($default, $pre = '(default ')) {
if (\is_string($default) && 0 === strncmp($default, $pre = '(default ', \strlen($pre = '(default '))) {
$default = rtrim(substr($default, \strlen($pre)), ')');
}

Expand Down
42 changes: 21 additions & 21 deletions tests/Concerns/ConcreteScoresTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,34 @@ public function testArrayScores(): void
{
$soar = Soar::create();
$sqls = <<<'sqls'
SELECT * FROM `post` WHERE `name`='so"a`r';
SELECT DATE_FORMAT (t.last_update,'%Y-%m-%d'),COUNT (DISTINCT (t.city)) FROM city t WHERE t.last_update> '2018-10-22 00:00:00' AND t.city LIKE '%Chrome%' AND t.city='eip' GROUP BY DATE_FORMAT(t.last_update,'%Y-%m-%d') ORDER BY DATE_FORMAT(t.last_update,'%Y-%m-%d');
SELECT * FROM `post` WHERE `name`='so"a`r';
SELECT DATE_FORMAT (t.last_update,'%Y-%m-%d'),COUNT (DISTINCT (t.city)) FROM city t WHERE t.last_update> '2018-10-22 00:00:00' AND t.city LIKE '%Chrome%' AND t.city='eip' GROUP BY DATE_FORMAT(t.last_update,'%Y-%m-%d') ORDER BY DATE_FORMAT(t.last_update,'%Y-%m-%d');
DELETE city FROM city LEFT JOIN country ON city.country_id=country.country_id WHERE country.country IS NULL;
DELETE city FROM city LEFT JOIN country ON city.country_id=country.country_id WHERE country.country IS NULL;
UPDATE city INNER JOIN country ON city.country_id=country.country_id INNER JOIN address ON city.city_id=address.city_id SET city.city='Abha',city.last_update='2006-02-15 04:45:25',country.country='Afghanistan' WHERE city.city_id=10;
UPDATE city INNER JOIN country ON city.country_id=country.country_id INNER JOIN address ON city.city_id=address.city_id SET city.city='Abha',city.last_update='2006-02-15 04:45:25',country.country='Afghanistan' WHERE city.city_id=10;
INSERT INTO city (country_id) SELECT country_id FROM country;
INSERT INTO city (country_id) SELECT country_id FROM country;
REPLACE INTO city (country_id) SELECT country_id FROM country;
REPLACE INTO city (country_id) SELECT country_id FROM country;
ALTER TABLE inventory ADD INDEX `idx_store_film` (`store_id`,`film_id`),ADD INDEX `idx_store_film` (`store_id`,`film_id`),ADD INDEX `idx_store_film` (`store_id`,`film_id`);
ALTER TABLE inventory ADD INDEX `idx_store_film` (`store_id`,`film_id`),ADD INDEX `idx_store_film` (`store_id`,`film_id`),ADD INDEX `idx_store_film` (`store_id`,`film_id`);
DROP TABLE `users`;
DROP TABLE `users`;
CREATE TABLE `users` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
sqls;
CREATE TABLE `users` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
sqls;
$arrayScores = $soar->arrayScores($sqls);

$this->assertIsArray($arrayScores);
Expand Down

0 comments on commit bd51d97

Please sign in to comment.