Skip to content

Commit

Permalink
bump dev dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
grachevko committed Aug 20, 2021
1 parent 7e2e843 commit 7313802
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 124 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.idea
/vendor
/composer.lock
/.php_cs.cache
/.php-cs-fixer.cache
/.phpunit.result.cache
46 changes: 46 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('var')
->exclude('vendor')
->exclude('public/bundles')
->exclude('public/css')
->exclude('public/fonts')
->exclude('public/js');

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'@PSR12' => true,
'@PSR12:risky' => true,
'blank_line_before_statement' => [
'statements' => [
'continue',
'do',
'exit',
'goto',
'if',
'return',
'switch',
'throw',
'try',
],
],
'declare_strict_types' => true,
'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true],
'php_unit_internal_class' => false,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'php_unit_test_class_requires_covers' => false,
'phpdoc_to_comment' => false,
'phpdoc_order_by_value' => ['annotations' => ['throws']],
'yoda_style' => true,
'trailing_comma_in_multiline' => [
'after_heredoc' => true,
'elements' => ['arrays', 'arguments', 'parameters']
],
])
->setFinder($finder)
->setCacheFile(__DIR__.'/.php-cs-fixer.cache');
50 changes: 0 additions & 50 deletions .php_cs

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VOLUMES = -v `pwd`:/data -w /data

php = docker run --rm $(OPTIONS) $(VOLUMES) php:7.4.1-alpine
composer = docker run --rm $(VOLUMES) composer:1.9.1
php = docker run --rm $(OPTIONS) $(VOLUMES) php:8.0-alpine
composer = docker run --rm $(VOLUMES) composer:2.1.5

all: install composer-validate php-cs-fixer psalm phpstan phpunit

Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
}
},
"require-dev": {
"phpunit/phpunit": "^8.2",
"friendsofphp/php-cs-fixer": "^2.15",
"phpstan/phpstan": "^0.11",
"vimeo/psalm": "^3.4",
"phpstan/phpstan-strict-rules": "^0.11",
"phpstan/phpstan-phpunit": "^0.11",
"doctrine/dbal": "^2.10"
"phpunit/phpunit": "^9.5",
"friendsofphp/php-cs-fixer": "^3.0",
"phpstan/phpstan": "^0.12.94",
"vimeo/psalm": "^4.9",
"phpstan/phpstan-strict-rules": "^0.12.10",
"phpstan/phpstan-phpunit": "^0.12.22",
"doctrine/dbal": "^2"
}
}
1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
totallyTyped="false"
useDocblockTypes="true"
allowPhpStormGenerics="true"
requireVoidReturnType="true"
ignoreInternalFunctionFalseReturn="false"
ignoreInternalFunctionNullReturn="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down
14 changes: 8 additions & 6 deletions src/Doctrine/EnumType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace Premier\Enum\Doctrine;

use function assert;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
use function filter_var;
use InvalidArgumentException;
use function is_subclass_of;
use Premier\Enum\Enum;
use function assert;
use function filter_var;
use function is_subclass_of;
use function sprintf;

/**
Expand Down Expand Up @@ -60,13 +60,13 @@ public function getName(): string
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
if ('id' === $this->property) {
return $platform->getSmallIntTypeDeclarationSQL($fieldDeclaration);
return $platform->getSmallIntTypeDeclarationSQL($column);
}

return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
return $platform->getVarcharTypeDeclarationSQL($column);
}

/**
Expand All @@ -79,6 +79,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?Enum
}

$class = $this->class;

if ($value instanceof $class) {
assert($value instanceof Enum);

Expand Down Expand Up @@ -116,6 +117,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
}

$class = $this->class;

if (!$value instanceof $class) {
throw ConversionException::conversionFailed($value, $this->getName());
}
Expand Down
26 changes: 14 additions & 12 deletions src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@

namespace Premier\Enum;

use BadMethodCallException;
use InvalidArgumentException;
use LogicException;
use ReflectionClass;
use ReflectionException;
use ReflectionProperty;
use Serializable;
use function array_diff;
use function array_flip;
use function array_key_exists;
use function array_keys;
use function array_map;
use function array_values;
use BadMethodCallException;
use function ctype_upper;
use function get_class;
use function in_array;
use InvalidArgumentException;
use function is_int;
use function lcfirst;
use LogicException;
use function preg_replace;
use ReflectionClass;
use ReflectionException;
use ReflectionProperty;
use Serializable;
use function sprintf;
use function strpos;
use function strtolower;
Expand Down Expand Up @@ -73,9 +73,9 @@ final public function __toString(): string
}

/**
* @throws ReflectionException
* @throws InvalidArgumentException
* @throws BadMethodCallException
* @throws InvalidArgumentException
* @throws ReflectionException
*
* @return bool|string
*/
Expand All @@ -95,9 +95,9 @@ final public function __call(string $name, array $arguments)
}

/**
* @throws ReflectionException
* @throws BadMethodCallException
* @throws LogicException
* @throws ReflectionException
*
* @return static
*/
Expand All @@ -123,6 +123,8 @@ final public static function __callStatic(string $name, array $arguments)
* @throws ReflectionException
*
* @return static
*
* @psalm-suppress UnsafeInstantiation
*/
final public static function create(int $id): self
{
Expand Down Expand Up @@ -161,8 +163,8 @@ final public function toName(): string
}

/**
* @throws ReflectionException
* @throws InvalidArgumentException
* @throws ReflectionException
*
* @return mixed
*/
Expand Down Expand Up @@ -242,8 +244,8 @@ private static function stringToConstant(string $string): string
}

/**
* @throws ReflectionException
* @throws LogicException
* @throws ReflectionException
*/
private static function getReflection(): ReflectionClass
{
Expand Down
15 changes: 9 additions & 6 deletions tests/Doctrine/EnumTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testRegister(): void
{
EnumType::register(TestEnum::class, 'test_enum');

static::assertInstanceOf(EnumType::class, Type::getType('test_enum'));
self::assertInstanceOf(EnumType::class, Type::getType('test_enum'));
}

/**
Expand All @@ -41,8 +41,8 @@ public function testRegister(): void
*/
public function testConversion(Type $type, Enum $enum, $value): void
{
static::assertSame($value, $type->convertToDatabaseValue($enum, self::$platform));
static::assertSame($enum, $type->convertToPHPValue($value, self::$platform));
self::assertSame($value, $type->convertToDatabaseValue($enum, self::$platform));
self::assertSame($enum, $type->convertToPHPValue($value, self::$platform));
}

public function conversionDataProvider(): Generator
Expand All @@ -59,7 +59,7 @@ public function conversionDataProvider(): Generator
*/
public function testDeclaration(EnumType $type, string $declaration): void
{
static::assertSame($declaration, $type->getSQLDeclaration([], self::$platform));
self::assertSame($declaration, $type->getSQLDeclaration([], self::$platform));
}

public function declarationDataProvider(): Generator
Expand All @@ -78,14 +78,17 @@ private function getType(string $name, string $property = 'id'): Type
}
}

/**
* @psalm-suppress DeprecatedClass
*/
class EnumTestPlatform extends SQLAnywherePlatform
{
public function getVarcharTypeDeclarationSQL(array $field): string
public function getVarcharTypeDeclarationSQL(array $column): string
{
return 'varchar';
}

public function getSmallIntTypeDeclarationSQL(array $columnDef): string
public function getSmallIntTypeDeclarationSQL(array $column): string
{
return 'smallint';
}
Expand Down
Loading

0 comments on commit 7313802

Please sign in to comment.