Skip to content

Update dev tools version (PHP-CS-Fixer + PHPStan) #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
<?php

declare(strict_types=1);

/*
* Copyright MacFJA
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* ----------
*
* This document has been generated with
* https://mlocati.github.io/php-cs-fixer-configurator/#version:3.0.0|configurator
* you can change this configuration by importing this file.
*/

$config = new PhpCsFixer\Config();

return $config
->setRiskyAllowed(true)
->setRules([
Expand All @@ -17,15 +39,15 @@
'@PhpCsFixer' => true,
'combine_nested_dirname' => true,
'dir_constant' => true,
'global_namespace_import' => ['import_functions'=>true],
'header_comment' => ['comment_type'=>'comment','header'=>"Copyright MacFJA\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\ndocumentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\nrights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the\nSoftware.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\nWARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\nOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",'location'=>'after_declare_strict'],
'global_namespace_import' => ['import_functions' => true],
'header_comment' => ['comment_type' => 'comment', 'header' => "Copyright MacFJA\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\ndocumentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\nrights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the\nSoftware.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\nWARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\nOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", 'location' => 'after_declare_strict'],
'implode_call' => true,
'logical_operators' => true,
'modernize_types_casting' => true,
'native_function_invocation' => true,
'no_alias_functions' => ['sets'=>['@all']],
'no_alias_functions' => ['sets' => ['@all']],
'no_php4_constructor' => true,
'no_superfluous_phpdoc_tags' => ['allow_mixed'=>true,'remove_inheritdoc'=>true],
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true, 'remove_inheritdoc' => true],
'no_unreachable_default_argument_value' => true,
'no_useless_sprintf' => true,
'php_unit_dedicate_assert' => true,
Expand All @@ -43,9 +65,10 @@
'ternary_to_elvis_operator' => true,
'void_return' => true,
])
->setFinder(PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
->setFinder(
PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
)
;
;
24 changes: 10 additions & 14 deletions .unused.dist.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@

<?php

$projectPath = __DIR__ . '/';
$projectPath = __DIR__.'/';

$scanDirectories = [
$projectPath . '/src/',
$projectPath . '/tests/',
$projectPath.'/src/',
$projectPath.'/tests/',
];

return [
/**
* Required params
**/
'composerJsonPath' => $projectPath . '/composer.json',
'vendorPath' => $projectPath . '/vendor/',
// Required params
'composerJsonPath' => $projectPath.'/composer.json',
'vendorPath' => $projectPath.'/vendor/',
'scanDirectories' => $scanDirectories,

/**
* Optional params
**/
// Optional params
'skipPackages' => [
'phpmd/phpmd', // QA tool
'vimeo/psalm', // QA tool
Expand All @@ -28,10 +24,10 @@
'enlightn/security-checker', // QA tool
'php-parallel-lint/php-parallel-lint', // QA tool
'sebastian/phpcpd', // QA tool
'ukko/phpredis-phpdoc' // Stubs
'ukko/phpredis-phpdoc', // Stubs
],
'excludeDirectories' => [],
'scanFiles' => [],
'extensions' => ['*.php'],
'requireDev' => true
];
'requireDev' => true,
];
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased v2.x]

### Changed

- (dev) Update version and rules of PHP-CS-Fixer and PHPStan

## [2.1.1]

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

analyze: | vendor
$(COMPOSER) exec -v parallel-lint -- src
$(COMPOSER) exec -v php-cs-fixer -- fix --dry-run
$(COMPOSER) exec -v php-cs-fixer -- fix --dry-run -v
$(COMPOSER) exec -v unused_scanner -- .unused.dist.php
$(COMPOSER) exec -v security-checker -- security:check
$(COMPOSER) exec -v phpcpd -- --fuzzy src
Expand All @@ -13,7 +13,7 @@ analyze: | vendor

fix-code: | vendor
$(COMPOSER) normalize
$(COMPOSER) exec -v php-cs-fixer -- fix
$(COMPOSER) exec -v php-cs-fixer -- fix -v

test: | vendor
$(COMPOSER) exec -v phpunit
Expand Down Expand Up @@ -55,4 +55,4 @@ ifneq ($(shell command -v composer > /dev/null ; echo $$?), 0)
COMPOSER=php composer.phar
else
COMPOSER=composer
endif
endif
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
{
"name": "macfja/redisearch",
"type": "library",
"description": "PHP Client for RediSearch",
"license": "MIT",
"type": "library",
"keywords": [
"Redis",
"RediSearch",
"Search Engine",
"Suggestion"
],
"readme": "README.md",
"license": "MIT",
"authors": [
{
"name": "MacFJA"
}
],
"support": {
"issues": "https://github.com/MacFJA/php-redisearch/issues",
"source": "https://github.com/MacFJA/php-redisearch"
},
"require": {
"php": "^7.2 || ^8.0",
"ext-intl": "*",
Expand Down Expand Up @@ -55,12 +59,6 @@
"ptrofimov/tinyredisclient": "To use TinyRedisClient implementation",
"redisent/redisent": "To use Redisent implementation"
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"ergebnis/composer-normalize": true
}
},
"autoload": {
"psr-4": {
"MacFJA\\RediSearch\\": "src/"
Expand All @@ -71,8 +69,10 @@
"MacFJA\\RediSearch\\tests\\": "tests/"
}
},
"support": {
"issues": "https://github.com/MacFJA/php-redisearch/issues",
"source": "https://github.com/MacFJA/php-redisearch"
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"ergebnis/composer-normalize": true
}
}
}
3 changes: 3 additions & 0 deletions src/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ class Index
{
/** @var Client */
private $client;

/** @var InfoResponse */
private $info;

/** @var string */
private $index;

/** @var string */
private $version;

Expand Down
18 changes: 18 additions & 0 deletions src/IndexBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,40 +97,58 @@ class IndexBuilder
use AddFieldOptionTrait;

private const IS_ARRAY = ['prefixes', 'stopWords', 'fields'];

/** @var null|string */
private $index;

/** @var null|string */
private $structure;

/** @var array<string> */
private $prefixes = [];

/** @var null|string */
private $filter;

/** @var null|string */
private $defaultLanguage;

/** @var null|string */
private $languageField;

/** @var null|float */
private $defaultScore;

/** @var null|string */
private $scoreField;

/** @var null|string */
private $payloadField;

/** @var bool */
private $maxTextFields = false;

/** @var null|int */
private $temporary;

/** @var bool */
private $noOffsets = false;

/** @var bool */
private $noHighLight = false;

/** @var bool */
private $noFields = false;

/** @var bool */
private $noFrequencies = false;

/** @var bool */
private $skipInitialScan = false;

/** @var null|array<string> */
private $stopWords;

/** @var array<CreateCommandFieldOption> */
private $fields = [];

Expand Down
3 changes: 3 additions & 0 deletions src/Query/Builder/EncapsulationGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ class EncapsulationGroup implements QueryElement, QueryElementDecorator
{
/** @var string */
private $open;

/** @var string */
private $close;

/** @var bool */
private $omitIfNoSpace;

/** @var QueryElement */
private $element;

Expand Down
1 change: 1 addition & 0 deletions src/Query/Builder/FieldFacet.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class FieldFacet implements QueryElement
{
/** @var array<string> */
private $fields;

/** @var QueryElement */
private $element;

Expand Down
1 change: 1 addition & 0 deletions src/Query/Builder/Fuzzy.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Fuzzy implements QueryElement
{
/** @var string */
private $word;

/** @var int */
private $distance;

Expand Down
2 changes: 0 additions & 2 deletions src/Redis/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public function execute(Command $command);
public function executeRaw(...$args);

/**
* @param Command ...$commands
*
* @return array<mixed>
*/
public function pipeline(Command ...$commands): array;
Expand Down
2 changes: 0 additions & 2 deletions src/Redis/Client/AbstractClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public function pipeline(Command ...$commands): array
}

/**
* @param Command ...$commands
*
* @return array<mixed>
*/
abstract protected function doPipeline(Command ...$commands): array;
Expand Down
3 changes: 0 additions & 3 deletions src/Redis/Client/ClientFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ public function getClient($redis): Client
{
/** @var Client $factory */
foreach ($this->factories as $factory) {
if (!is_subclass_of($factory, Client::class)) {
continue;
}
if ($factory::supports($redis)) {
return $factory::make($redis);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Redis/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ abstract class AbstractCommand implements Command
{
public const MAX_IMPLEMENTED_VERSION = '2.0.12';
public const MIN_IMPLEMENTED_VERSION = '2.0.0';

/**
* @var array<array<CommandOption>|CommandOption|mixed>
*/
protected $options;

/** @var string */
private $rediSearchVersion;

Expand Down
1 change: 1 addition & 0 deletions src/Redis/Command/AggregateCommand/GroupByOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class GroupByOption extends AbstractCommandOption

/** @var array<ReduceOption> */
private $reducers = [];

/** @var array<string> */
private $fields;

Expand Down
2 changes: 2 additions & 0 deletions src/Redis/Command/AggregateCommand/SortByOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
class SortByOption extends AbstractCommandOption
{
use PrefixFieldName;

/** @var array<string,null|string> */
private $fields = [];

/** @var null|int */
private $max;

Expand Down
1 change: 1 addition & 0 deletions src/Redis/Command/CreateCommand/JSONFieldOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class JSONFieldOption extends AbstractCommandOption implements CreateCommandJSON
{
/** @var CreateCommandFieldOption */
private $decorated;

/** @var string */
private $path;

Expand Down
1 change: 1 addition & 0 deletions src/Redis/Command/Option/AbstractCommandOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace MacFJA\RediSearch\Redis\Command\Option;

use Composer\Semver\Semver;
use function is_scalar;
use UnexpectedValueException;

abstract class AbstractCommandOption implements CommandOption
Expand Down
1 change: 1 addition & 0 deletions src/Redis/Command/Option/FlagOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class FlagOption extends AbstractCommandOption
{
/** @var string */
private $name;

/** @var bool */
private $active;

Expand Down
Loading