Skip to content

Commit

Permalink
Update StyleCI config + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark committed Nov 20, 2020
1 parent e756a71 commit db4b0a6
Show file tree
Hide file tree
Showing 12 changed files with 234 additions and 156 deletions.
90 changes: 87 additions & 3 deletions .styleci.yml
@@ -1,6 +1,90 @@
preset: psr12
risky: true

version: 8

finder:
exclude:
- docs
- vendor
exclude:
- docs
- vendor
- resources
- views
- public
not-name:
- UnionCar.php

enabled:
- alpha_ordered_imports
- alpha_ordered_traits
- array_indentation
- array_push
- combine_consecutive_issets
- combine_consecutive_unsets
- combine_nested_dirname
- declare_strict_types
- dir_constant
- final_static_access
- fully_qualified_strict_types
- function_to_constant
- hash_to_slash_comment
- is_null
- logical_operators
- magic_constant_casing
- magic_method_casing
- method_separation
- modernize_types_casting
- native_function_casing
- native_function_type_declaration_casing
- no_alias_functions
- no_alternative_syntax
- no_empty_comment
- no_empty_phpdoc
- no_empty_statement
- no_extra_block_blank_lines
- no_short_bool_cast
- no_short_echo_tag
- no_superfluous_elseif
- no_unneeded_control_parentheses
- no_unneeded_curly_braces
- no_unneeded_final_method
- no_unset_cast
- no_unused_imports
- no_unused_lambda_imports
- no_useless_else
- no_useless_return
- normalize_index_brace
- php_unit_dedicate_assert
- php_unit_dedicate_assert_internal_type
- php_unit_expectation
- php_unit_mock
- php_unit_mock_short_will_return
- php_unit_namespaced
- php_unit_no_expectation_annotation
- phpdoc_no_empty_return
- phpdoc_no_useless_inheritdoc
- phpdoc_order
- phpdoc_property
- phpdoc_scalar
- phpdoc_separation
- phpdoc_singular_inheritdoc
- phpdoc_trim
- phpdoc_trim_consecutive_blank_line_separation
- phpdoc_type_to_var
- phpdoc_types
- phpdoc_types_order
- phpdoc_var_without_name
- print_to_echo
- regular_callable_call
- return_assignment
- self_accessor
- self_static_accessor
- set_type_to_cast
- short_array_syntax
- short_list_syntax
- simplified_if_return
- single_quote
- standardize_not_equals
- ternary_to_null_coalescing
- trailing_comma_in_multiline_array
- unalign_double_arrow
- unalign_equals
14 changes: 7 additions & 7 deletions src/ArrayExpressionBuilder.php
Expand Up @@ -4,24 +4,24 @@

namespace Yiisoft\Db\Pgsql;

use function get_class;
use function implode;
use function in_array;
use function is_array;
use function str_repeat;
use Traversable;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidArgumentException;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Expression\ArrayExpression;

use Yiisoft\Db\Expression\ExpressionBuilderInterface;
use Yiisoft\Db\Expression\ExpressionBuilderTrait;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Expression\JsonExpression;
use Yiisoft\Db\Query\Query;

use function get_class;
use function implode;
use function in_array;
use function is_array;
use function str_repeat;

final class ArrayExpressionBuilder implements ExpressionBuilderInterface
{
use ExpressionBuilderTrait;
Expand Down Expand Up @@ -140,7 +140,7 @@ protected function buildSubqueryArray(string $sql, ArrayExpression $expression):
* @param ArrayExpression $expression
* @param mixed $value
*
* @return int|ExpressionInterface
* @return ExpressionInterface|int
*/
protected function typecastValue(ArrayExpression $expression, $value)
{
Expand Down
14 changes: 7 additions & 7 deletions src/ColumnSchema.php
Expand Up @@ -4,18 +4,18 @@

namespace Yiisoft\Db\Pgsql;

use JsonException;
use Yiisoft\Db\Expression\ArrayExpression;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Expression\JsonExpression;
use Yiisoft\Db\Schema\ColumnSchema as AbstractColumnSchema;

use function array_walk_recursive;
use function in_array;
use function is_array;
use function is_string;
use function json_decode;

use JsonException;
use function strtolower;
use Yiisoft\Db\Expression\ArrayExpression;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Expression\JsonExpression;
use Yiisoft\Db\Schema\ColumnSchema as AbstractColumnSchema;

final class ColumnSchema extends AbstractColumnSchema
{
Expand Down Expand Up @@ -94,7 +94,7 @@ public function phpTypecast($value)
/**
* Casts $value after retrieving from the DBMS to PHP representation.
*
* @param string|int|null $value
* @param int|string|null $value
*
* @throws JsonException
*
Expand Down
2 changes: 1 addition & 1 deletion src/Connection.php
Expand Up @@ -5,8 +5,8 @@
namespace Yiisoft\Db\Pgsql;

use PDO;
use Yiisoft\Db\Connection\Connection as AbstractConnection;
use Yiisoft\Db\Command\Command;
use Yiisoft\Db\Connection\Connection as AbstractConnection;

/**
* Database connection class prefilled for PGSQL Server.
Expand Down
2 changes: 1 addition & 1 deletion src/JsonExpressionBuilder.php
Expand Up @@ -27,7 +27,7 @@ final class JsonExpressionBuilder implements ExpressionBuilderInterface
* @param ExpressionInterface $expression the expression to be built.
* @param array $params the binding parameters.
*
* @throws Exception|JsonException|InvalidArgumentException|InvalidConfigException|NotSupportedException
* @throws Exception|InvalidArgumentException|InvalidConfigException|JsonException|NotSupportedException
*
* @return string the raw SQL that will not be additionally escaped or quoted.
*/
Expand Down
41 changes: 20 additions & 21 deletions src/QueryBuilder.php
Expand Up @@ -4,10 +4,25 @@

namespace Yiisoft\Db\Pgsql;

use function array_diff;
use function array_merge;
use function array_unshift;
use function count;
use function explode;
use Generator;
use function implode;
use function is_bool;
use function is_float;
use function is_string;
use JsonException;
use PDO;
use Generator;
use Yiisoft\Db\Connection\ConnectionInterface;
use function preg_match;
use function preg_replace;
use function reset;
use function strpos;
use function strrpos;

use function version_compare;
use Yiisoft\Db\Constraint\Constraint;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidArgumentException;
Expand All @@ -23,22 +38,6 @@
use Yiisoft\Db\Query\QueryBuilder as AbstractQueryBuilder;
use Yiisoft\Strings\NumericHelper;

use function array_diff;
use function array_merge;
use function array_unshift;
use function count;
use function explode;
use function implode;
use function is_bool;
use function is_float;
use function is_string;
use function preg_match;
use function preg_replace;
use function reset;
use function strpos;
use function strrpos;
use function version_compare;

final class QueryBuilder extends AbstractQueryBuilder
{
/**
Expand Down Expand Up @@ -134,7 +133,7 @@ protected function defaultExpressionBuilders(): array
* @param string $name the name of the index. The name will be properly quoted by the method.
* @param string $table the table that the new index will be created for. The table name will be properly quoted by
* the method.
* @param string|array $columns the column(s) that should be included in the index. If there are multiple columns,
* @param array|string $columns the column(s) that should be included in the index. If there are multiple columns,
* separate them with commas or use an array to represent them. Each column name will be properly quoted by the
* method, unless a parenthesis is found in the name.
* @param bool|string $unique whether to make this a UNIQUE index constraint. You can pass `true` or
Expand Down Expand Up @@ -419,7 +418,7 @@ public function insert(string $table, $columns, array &$params = []): string
* @param array $params the binding parameters that will be generated by this method.
* They should be bound to the DB command later.
*
* @throws Exception|JsonException|InvalidConfigException|NotSupportedException if this is not supported by the
* @throws Exception|InvalidConfigException|JsonException|NotSupportedException if this is not supported by the
* underlying DBMS.
*
* @return string the resulting SQL.
Expand Down Expand Up @@ -449,7 +448,7 @@ public function upsert(string $table, $insertColumns, $updateColumns, array &$pa
* @param array|bool $updateColumns
* @param array $params
*
* @throws Exception|JsonException|InvalidArgumentException|InvalidConfigException|NotSupportedException
* @throws Exception|InvalidArgumentException|InvalidConfigException|JsonException|NotSupportedException
*
* @return string
*/
Expand Down
31 changes: 15 additions & 16 deletions src/Schema.php
Expand Up @@ -4,14 +4,25 @@

namespace Yiisoft\Db\Pgsql;

use function array_change_key_case;
use function array_merge;
use function array_unique;
use function array_values;
use function bindec;
use function explode;
use function implode;
use JsonException;
use PDO;
use function preg_match;
use function preg_replace;
use function str_replace;
use function substr;
use Throwable;
use Yiisoft\Arrays\ArrayHelper;
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Constraint\CheckConstraint;
use Yiisoft\Db\Constraint\Constraint;
use Yiisoft\Db\Constraint\ConstraintFinderInterface;

use Yiisoft\Db\Constraint\ConstraintFinderTrait;
use Yiisoft\Db\Constraint\DefaultValueConstraint;
use Yiisoft\Db\Constraint\ForeignKeyConstraint;
Expand All @@ -24,22 +35,10 @@
use Yiisoft\Db\Schema\Schema as AbstractSchema;
use Yiisoft\Db\View\ViewFinderTrait;

use function array_change_key_case;
use function array_merge;
use function array_unique;
use function array_values;
use function bindec;
use function explode;
use function implode;
use function preg_match;
use function preg_replace;
use function str_replace;
use function substr;

final class Schema extends AbstractSchema implements ConstraintFinderInterface
{
use ViewFinderTrait;
use ConstraintFinderTrait;
use ViewFinderTrait;

public const TYPE_JSONB = 'jsonb';

Expand Down Expand Up @@ -558,7 +557,7 @@ public function findUniqueIndexes(TableSchema $table): array
*
* @param TableSchema $table the table metadata.
*
* @throws Exception|JsonException|InvalidConfigException|Throwable
* @throws Exception|InvalidConfigException|JsonException|Throwable
*
* @return bool whether the table exists in the database.
*/
Expand Down Expand Up @@ -913,7 +912,7 @@ private function createColumnSchema(): ColumnSchema
* This method may be overridden by child classes to create a DBMS-specific column schema builder.
*
* @param string $type type of the column. See {@see ColumnSchemaBuilder::$type}.
* @param int|string|array|null $length length or precision of the column. See {@see ColumnSchemaBuilder::$length}.
* @param array|int|string|null $length length or precision of the column. See {@see ColumnSchemaBuilder::$length}.
*
* @return ColumnSchemaBuilder column schema builder instance
*/
Expand Down

0 comments on commit db4b0a6

Please sign in to comment.