Skip to content

Commit

Permalink
Bump min PHP version to 8.0 and update deps (#646)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba authored Aug 9, 2021
1 parent eabc889 commit 35ba29c
Show file tree
Hide file tree
Showing 24 changed files with 174 additions and 154 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v1
with:
php-version: 7.3
php-version: 8.0
extensions: pdo_sqlite, pdo_mysql, pdo_pgsql
coverage: none

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

- uses: shivammathur/setup-php@v1
with:
php-version: 7.3
php-version: 8.0
extensions: pdo_sqlite, pdo_mysql, pdo_pgsql
coverage: none

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ jobs:
strategy:
matrix:
php:
- 7.3
- 7.4
- 8.0

name: Test ${{ matrix.php }}
Expand Down
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{ "name": "Knplabs", "homepage": "http://knplabs.com" }
],
"require": {
"php": ">=7.3",
"php": ">=8.0",
"doctrine/common": "^3.0",
"doctrine/persistence": "^2.0",
"doctrine/dbal": "^2.9",
Expand All @@ -35,17 +35,17 @@
"doctrine/annotations": "^1.12",
"doctrine/doctrine-bundle": "^2.2",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/phpstan": "^0.12.83",
"phpstan/phpstan": "^0.12.84",
"phpunit/phpunit": "^9.5",
"rector/rector-prefixed": "^0.10.4",
"symplify/easy-coding-standard": "^9.2.18",
"symplify/phpstan-extensions": "^9.2.18",
"phpstan/phpstan-doctrine": "^0.12.33",
"phpstan/phpstan-phpunit": "^0.12.18",
"symplify/package-builder": "^9.2.18",
"symplify/phpstan-rules": "^9.2.18",
"symplify/config-transformer": "^9.2",
"symplify/amnesia": "^9.2",
"rector/rector": "^0.11.45",
"symplify/easy-coding-standard": "^9.4",
"symplify/phpstan-extensions": "^9.4",
"phpstan/phpstan-doctrine": "^0.12.42",
"phpstan/phpstan-phpunit": "^0.12",
"symplify/package-builder": "^9.4",
"symplify/phpstan-rules": "^9.4",
"symplify/config-transformer": "^9.4",
"symplify/amnesia": "^9.4",
"phpstan/extension-installer": "^1.1"
},
"autoload": {
Expand Down
8 changes: 5 additions & 3 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\ClassNotation\FinalClassFixer;
use PhpCsFixer\Fixer\Comment\HeaderCommentFixer;
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
use PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer;
Expand All @@ -13,6 +12,11 @@
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(SetList::PSR_12);
$containerConfigurator->import(SetList::SYMPLIFY);
$containerConfigurator->import(SetList::COMMON);
$containerConfigurator->import(SetList::CLEAN_CODE);

$parameters = $containerConfigurator->parameters();

$parameters->set(Option::PATHS, [
Expand All @@ -24,8 +28,6 @@
__DIR__ . '/rector.php',
]);

$parameters->set(Option::SETS, [SetList::PSR_12, SetList::SYMPLIFY, SetList::COMMON, SetList::CLEAN_CODE]);

$parameters->set(Option::SKIP, [
UnaryOperatorSpacesFixer::class,
PhpUnitStrictFixer::class => [__DIR__ . '/tests/ORM/Timestampable/TimestampableTest.php'],
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,6 @@ parameters:
-
message: '#Use dependency injection instead of dependency juggling#'
path: tests/DatabaseLoader.php

# known retype
- '#Cannot cast array\|bool\|float\|int\|string\|null to string#'
27 changes: 10 additions & 17 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\DeadCode\Rector\Class_\RemoveUnusedDoctrineEntityMethodAndPropertyRector;
use Rector\Nette\Set\NetteSetList;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

Expand All @@ -12,20 +12,13 @@

$parameters->set(Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/utils']);

$parameters->set(Option::SETS, [
SetList::DEAD_CODE,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::NETTE_UTILS_CODE_QUALITY,
SetList::NAMING,
SetList::PHP_70,
SetList::PHP_71,
SetList::PHP_72,
SetList::PHP_73,
]);

$parameters->set(Option::SKIP, [
RemoveUnusedDoctrineEntityMethodAndPropertyRector::class,
__DIR__ . '/src/Model/Translatable/TranslatableMethodsTrait.php',
]);
$containerConfigurator->import(SetList::DEAD_CODE);
$containerConfigurator->import(SetList::CODE_QUALITY);
$containerConfigurator->import(SetList::CODING_STYLE);
$containerConfigurator->import(NetteSetList::NETTE_CODE_QUALITY);
$containerConfigurator->import(SetList::NAMING);
$containerConfigurator->import(SetList::PHP_70);
$containerConfigurator->import(SetList::PHP_71);
$containerConfigurator->import(SetList::PHP_72);
$containerConfigurator->import(SetList::PHP_73);
};
14 changes: 0 additions & 14 deletions src/Bundle/DoctrineBehaviorsBundle.php

This file was deleted.

1 change: 1 addition & 0 deletions src/Model/Blameable/BlameableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
trait BlameableTrait
{
use BlameablePropertiesTrait;

use BlameableMethodsTrait;
}
1 change: 1 addition & 0 deletions src/Model/Sluggable/SluggableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
trait SluggableTrait
{
use SluggablePropertiesTrait;

use SluggableMethodsTrait;
}
1 change: 1 addition & 0 deletions src/Model/SoftDeletable/SoftDeletableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
trait SoftDeletableTrait
{
use SoftDeletablePropertiesTrait;

use SoftDeletableMethodsTrait;
}
1 change: 1 addition & 0 deletions src/Model/Timestampable/TimestampableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
trait TimestampableTrait
{
use TimestampablePropertiesTrait;

use TimestampableMethodsTrait;
}
8 changes: 3 additions & 5 deletions src/Model/Translatable/TranslatableMethodsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ public function getCurrentLocale(): string
return $this->currentLocale ?: $this->getDefaultLocale();
}

/**
* @param mixed $locale the default locale
*/
public function setDefaultLocale($locale): void
public function setDefaultLocale(string $locale): void
{
$this->defaultLocale = $locale;
}
Expand Down Expand Up @@ -223,7 +220,8 @@ private function ensureIsIterableOrCollection($translations): void
return;
}

throw new TranslatableException(sprintf('$translations parameter must be iterable or %s', Collection::class)
throw new TranslatableException(
sprintf('$translations parameter must be iterable or %s', Collection::class)
);
}

Expand Down
1 change: 1 addition & 0 deletions src/Model/Translatable/TranslatableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
trait TranslatableTrait
{
use TranslatablePropertiesTrait;

use TranslatableMethodsTrait;
}
1 change: 1 addition & 0 deletions src/Model/Translatable/TranslationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
trait TranslationTrait
{
use TranslationPropertiesTrait;

use TranslationMethodsTrait;
}
10 changes: 8 additions & 2 deletions src/Model/Tree/TreeNodeMethodsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Knp\DoctrineBehaviors\Contract\Entity\TreeNodeInterface;
use Knp\DoctrineBehaviors\Exception\ShouldNotHappenException;
use Knp\DoctrineBehaviors\Exception\TreeException;
use Nette\Utils\Json;

Expand Down Expand Up @@ -54,7 +55,7 @@ public function getParentMaterializedPath(): string
return static::getMaterializedPathSeparator() . implode(static::getMaterializedPathSeparator(), $path);
}

public function setParentMaterializedPath($path): void
public function setParentMaterializedPath(string $path): void
{
$this->parentNodePath = $path;
}
Expand Down Expand Up @@ -273,7 +274,12 @@ public function offsetGet($offset)
*/
protected function getExplodedPath(): array
{
$path = explode(static::getMaterializedPathSeparator(), $this->getRealMaterializedPath());
$separator = static::getMaterializedPathSeparator();
if ($separator === '') {
throw new ShouldNotHappenException();
}

$path = explode($separator, $this->getRealMaterializedPath());

return array_filter($path, function ($item) {
return $item !== '';
Expand Down
1 change: 1 addition & 0 deletions src/Model/Tree/TreeNodeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
trait TreeNodeTrait
{
use TreeNodeMethodsTrait;

use TreeNodePropertiesTrait;
}
5 changes: 5 additions & 0 deletions src/Model/Uuidable/UuidableMethodsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Knp\DoctrineBehaviors\Model\Uuidable;

use Knp\DoctrineBehaviors\Exception\ShouldNotHappenException;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;

Expand All @@ -17,6 +18,10 @@ public function setUuid(UuidInterface $uuid): void
public function getUuid(): ?UuidInterface
{
if (is_string($this->uuid)) {
if ($this->uuid === '') {
throw new ShouldNotHappenException();
}

return Uuid::fromString($this->uuid);
}

Expand Down
1 change: 1 addition & 0 deletions src/Model/Uuidable/UuidableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
trait UuidableTrait
{
use UuidablePropertiesTrait;

use UuidableMethodsTrait;
}
7 changes: 4 additions & 3 deletions src/Provider/LocaleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Contracts\Translation\LocaleAwareInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand Down Expand Up @@ -42,7 +43,7 @@ public function __construct(
public function provideCurrentLocale(): ?string
{
$currentRequest = $this->requestStack->getCurrentRequest();
if ($currentRequest === null) {
if (! $currentRequest instanceof Request) {
return null;
}

Expand All @@ -67,10 +68,10 @@ public function provideFallbackLocale(): ?string

try {
if ($this->parameterBag->has('locale')) {
return $this->parameterBag->get('locale');
return (string) $this->parameterBag->get('locale');
}

return $this->parameterBag->get('kernel.default_locale');
return (string) $this->parameterBag->get('kernel.default_locale');
} catch (ParameterNotFoundException | InvalidArgumentException $parameterNotFoundException) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
class SluggableTranslatableEntityTranslation implements TranslationInterface, SluggableInterface
{
use SluggableTrait;

use TranslationTrait;

/**
Expand Down
10 changes: 10 additions & 0 deletions tests/ORM/Timestampable/Source/SomeClassForMetadata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Knp\DoctrineBehaviors\Tests\ORM\Timestampable\Source;

final class SomeClassForMetadata
{
public string $name;
}
4 changes: 2 additions & 2 deletions tests/ORM/Timestampable/TimestampableMakeEntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\ORM\Events;
use Doctrine\ORM\Mapping\ClassMetadata;
use Knp\DoctrineBehaviors\Tests\AbstractBehaviorTestCase;
use Knp\DoctrineBehaviors\Tests\ORM\Timestampable\Source\SomeClassForMetadata;

/**
* When console make:entity creates a new class, the event arguments are not fully populated
Expand All @@ -19,8 +20,7 @@ final class TimestampableMakeEntityTest extends AbstractBehaviorTestCase
{
public function testMakeEntityEmptyEvent(): void
{
$className = 'App\Entity\MyClass';
$classMetadata = new ClassMetadata($className);
$classMetadata = new ClassMetadata(SomeClassForMetadata::class);
$loadClassMetadataEventArgs = new LoadClassMetadataEventArgs($classMetadata, $this->entityManager);

$doctrineEventManager = $this->entityManager->getEventManager();
Expand Down
Loading

0 comments on commit 35ba29c

Please sign in to comment.