Skip to content

Commit

Permalink
php8.3 support (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
riki137 authored Oct 22, 2024
1 parent 7d472c7 commit 92da9bf
Show file tree
Hide file tree
Showing 17 changed files with 219 additions and 99 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/composer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]

name: Composer outdated PHP ${{ matrix.php }}

Expand All @@ -29,4 +29,4 @@ jobs:
run: composer update --no-progress --no-interaction

- name: Composer outdated
run: composer outdated -D --strict
run: composer outdated -D --strict --ignore=phpunit/phpunit
2 changes: 1 addition & 1 deletion .github/workflows/extensions_finder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: composer update --no-progress --no-interaction

- name: Install PHP extensions finder as dev dependency
run: composer require efabrica/php-extensions-finder --dev
run: composer require -W efabrica/php-extensions-finder --dev

- name: PHP extensions finder
run: vendor/bin/php-extensions-finder check src tests
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]

name: PHPStan PHP ${{ matrix.php }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit_mysql_5_7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]

name: PHPunit PHP ${{ matrix.php }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit_mysql_8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]

name: PHPunit PHP ${{ matrix.php }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit_psql_10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]

name: PHPunit PHP ${{ matrix.php }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit_psql_14.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]

name: PHPunit PHP ${{ matrix.php }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/syntax_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]

name: PHP syntax checker PHP ${{ matrix.php }}

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## Change Log

### [Unreleased][unreleased]
#### Added
- PHP8.3 support
- Symfony 7 support

### [1.2.0] - 2023-08-29
#### Changed
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
"keywords": ["PHP", "Database", "Fake data"],
"license": "MIT",
"require": {
"php": ">=7.4 <8.3",
"php": "^7.4 || ^8.0",
"ext-json": "*",
"ext-pdo": "*",
"fakerphp/faker": "^1.17",
"symfony/console": "^4.2 | ^5.0 | ^6.0",
"symfony/console": "^4.2 | ^5.0 | ^6.0 | ^7.0",
"nette/database": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"lulco/phoenix": "^2.3"
"lulco/phoenix": "^2.3",
"phpstan/phpstan": "^1.12"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 4 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
parameters:
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: true
level: max
reportUnmatchedIgnoredErrors: false
ignoreErrors:
-
identifier: missingType.iterableValue
- '#Parameter \#2 \$cacheStorage of class Nette\\Database\\Structure constructor expects Nette\\Caching\\IStorage, Nette\\Caching\\Storages\\MemoryStorage given\.#'
2 changes: 1 addition & 1 deletion src/DataType/TextDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ class TextDataType extends AbstractDataType

public function populate(Column $column): string
{
return $this->faker->realTextBetween(1, mt_rand(10, $this->max));
return $this->faker->realTextBetween(10, $this->max);
}
}
5 changes: 3 additions & 2 deletions src/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(
) {
$this->name = $name;
try {
$connection = new Connection($dsn, $user, $password, $options);
$connection = new Connection($dsn, $user, $password, $options ?? []);
$cacheStorage = new MemoryStorage();
$structure = new Structure($connection, $cacheStorage);
$database = new Explorer($connection, $structure);
Expand Down Expand Up @@ -141,7 +141,7 @@ private function addForeignKeysToTable(Table $table): void
$table->addForeignKey(new ForeignKey(
[$columnName],
$referencedTableName,
[$this->database->getStructure()->getPrimaryKey($referencedTableName)] // this is not always primary key, but nette database ignores this fact
[$this->database->getStructure()->getPrimaryKey($referencedTableName)] // this is not always primary key, but nette database ignores this fact
));
}
}
Expand Down Expand Up @@ -217,6 +217,7 @@ private function getExtendedColumnSettings(array $column): array
$fullType = $column['vendor']['type'];
$pattern = '/(.*?)\((.*?)\)(.*)/';
preg_match($pattern, $fullType, $matches);
/** @var array<int, string> $matches */
$type = trim($matches[1]);
if (in_array($type, ['enum', 'set'])) {
$values = str_replace("'", '', $matches[2]);
Expand Down
2 changes: 1 addition & 1 deletion src/Populator/AutomaticPopulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private function findDataTypeClassName(Column $column, Generator $faker)

$class = new $className($faker);
if (!$class instanceof DataTypeInterface) {
throw new Exception('Class "' . $className . '" is not type of ' . DataTypeInterface::class);
throw new Exception('Class "' . $className . '" is not type of ' . DataTypeInterface::class);
}
return $class;
}
Expand Down
87 changes: 6 additions & 81 deletions tests/Event/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,89 +17,15 @@ abstract class EventTest extends TestCase
{
protected function createInput(): InputInterface
{
return new class implements InputInterface
{
public function bind(InputDefinition $definition)
{

}

public function getArgument($name)
{

}

public function getArguments(): array
{

}

public function getFirstArgument(): string
{

}

public function getOption($name)
{

}

public function getOptions(): array
{

}

public function getParameterOption($values, $default = false, $onlyParams = false)
{

}

public function hasArgument($name): bool
{

}

public function hasOption($name): bool
{

}

public function hasParameterOption($values, $onlyParams = false): bool
{

}

public function isInteractive(): bool
{

}

public function setArgument($name, $value)
{

}

public function setInteractive($interactive)
{

}

public function setOption($name, $value)
{

}

public function validate()
{

}
};
if (PHP_VERSION_ID < 80200) {
return require __DIR__ . '/NullInputSymfony6.php';
}
return require __DIR__ . '/NullInputSymfony7.php';
}

protected function createOutput(): OutputInterface
{
return new class implements OutputInterface
{
return new class implements OutputInterface {
private array $messages = [];

private OutputFormatterInterface $formatter;
Expand Down Expand Up @@ -194,8 +120,7 @@ public function isVeryVerbose(): bool

protected function createPopulator(string $table, int $count = 10, ?string $databaseIdentifier = null): PopulatorInterface
{
return new class($table, $count, $databaseIdentifier) extends AbstractPopulator
{
return new class($table, $count, $databaseIdentifier) extends AbstractPopulator {
protected function generateData(Generator $faker): array
{
return [];
Expand Down
83 changes: 83 additions & 0 deletions tests/Event/NullInputSymfony6.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

declare(strict_types=1);

use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;

return new class implements InputInterface {
public function bind(InputDefinition $definition)
{

}

public function getArgument($name)
{

}

public function getArguments(): array
{

}

public function getFirstArgument(): string
{

}

public function getOption($name)
{

}

public function getOptions(): array
{

}

public function getParameterOption($values, $default = false, $onlyParams = false)
{

}

public function hasArgument($name): bool
{

}

public function hasOption($name): bool
{

}

public function hasParameterOption($values, $onlyParams = false): bool
{

}

public function isInteractive(): bool
{

}

public function setArgument($name, $value)
{

}

public function setInteractive($interactive)
{

}

public function setOption($name, $value)
{

}

public function validate()
{

}
};
Loading

0 comments on commit 92da9bf

Please sign in to comment.