Skip to content

Commit

Permalink
update to latest dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklog committed Dec 2, 2023
1 parent 9a4bb69 commit 2559154
Show file tree
Hide file tree
Showing 20 changed files with 107 additions and 223 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
php-versions: [ '7.4', '8.0', '8.1' ]
php-versions: [ '8.2', '8.3' ]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/vendor/
/composer.phar
/composer.lock
.phpunit.result.cache
/.phpunit.cache/
phpcs.cache
45 changes: 0 additions & 45 deletions Makefile

This file was deleted.

47 changes: 23 additions & 24 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,35 @@
}
],
"require": {
"php": "^7.4|^8.0",
"php": "^8.2",

"symfony/framework-bundle": "^4.4|^5.4|^6.0",
"symfony/config": "^4.4|^5.4|^6.0",
"symfony/http-kernel": "^4.4|^5.4|^6.0",
"symfony/dependency-injection": "^4.4|^5.4|^6.0",
"symfony/form": "^4.4|^5.4|^6.0",
"symfony/yaml": "^4.4|^5.4|^6.0",
"symfony/options-resolver": "^4.4|^5.4|^6.0",
"symfony/property-access": "^4.4|^5.4|^6.0",
"symfony/property-info": "^4.4|^5.4|^6.0",
"symfony/framework-bundle": "^5.4 || ^6.4 || ^7.0",
"symfony/config": "^5.4 || ^6.4 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.4 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0",
"symfony/form": "^5.4 || ^6.4 || ^7.0",
"symfony/yaml": "^5.4 || ^6.4 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.4 || ^7.0",
"symfony/property-access": "^5.4 || ^6.4 || ^7.0",
"symfony/property-info": "^5.4 || ^6.4 || ^7.0",

"doctrine/persistence": "^1.3|^2.0|^3.0",
"doctrine/persistence": "^3.0",
"webmozart/assert": "^1.9"
},
"require-dev": {
"icanhazstring/composer-unused": "~0.7",
"doctrine/coding-standard": "^9.0",
"icanhazstring/composer-unused": "~0.8",
"doctrine/coding-standard": "^12.0",
"roave/security-advisories": "dev-master",
"squizlabs/php_codesniffer": "^3.6",
"phpstan/phpstan": "~1.2",
"phpstan/phpstan-deprecation-rules": "~1.0",
"phpstan/phpstan-phpunit": "~1.0",
"phpstan/phpstan-strict-rules": "~1.1",
"phpstan/phpstan-webmozart-assert": "~1.0",
"maglnet/composer-require-checker": "^4.0",
"phpunit/phpunit": "^9.5",
"symfony/var-dumper": "^6.0",
"phpstan/phpstan-symfony": "^1.0"
"squizlabs/php_codesniffer": "^3.7",
"phpstan/phpstan": "~1.10",
"phpstan/phpstan-deprecation-rules": "~1.1",
"phpstan/phpstan-phpunit": "~1.3",
"phpstan/phpstan-strict-rules": "~1.5",
"phpstan/phpstan-webmozart-assert": "~1.2",
"maglnet/composer-require-checker": "^4.7",
"phpstan/phpstan-symfony": "^1.3",
"phpunit/phpunit": "^10.5",
"symfony/var-dumper": "^7.0"
},
"autoload": {
"psr-4": {
Expand All @@ -74,7 +74,6 @@
"check": [
"@crc",
"@unused",
"@cs-fix",
"@cs-check",
"@phpstan",
"@phpunit"
Expand Down
7 changes: 4 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
version: '3.6'
services:
app:
image: webdevops/php:7.4
image: webdevops/php:8.3
volumes:
- ./:/app/
env_file:
- etc/environment.yml
environment:
PHP_MEMORY_LIMIT: 4G
PHP_DATE_TIMEZONE: Europe/Berlin
28 changes: 0 additions & 28 deletions etc/environment.yml

This file was deleted.

2 changes: 1 addition & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<arg name="parallel" value="4"/>
<arg name="cache" value="./phpcs.cache" />

<config name="php_version" value="70419"/>
<config name="php_version" value="80300"/>

<file>src/</file>
<file>tests/</file>
Expand Down
20 changes: 10 additions & 10 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.4/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
cacheDirectory=".phpunit.cache"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
>
<coverage/>
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<source>
<include>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</include>
</source>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

class ShapecodeHiddenEntityTypeExtension extends Extension
{
/**
* @inheritDoc
*/
/** @inheritDoc */
public function load(array $configs, ContainerBuilder $container): void
{
$locator = new FileLocator(__DIR__ . '/../Resources/config');
Expand Down
41 changes: 16 additions & 25 deletions src/Form/DataTransformer/ObjectToIdTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,52 +13,40 @@
use function is_string;
use function sprintf;

/**
* @template-extends Transformer<object, string>
*/
/** @template-extends Transformer<object, string> */
class ObjectToIdTransformer extends Transformer
{
/**
* @phpstan-param object|null $entity
*
* @phpstan-return string|null
*/
public function transform($entity)
public function transform(mixed $value): mixed
{
if ($entity === null) {
if ($value === null) {
return null;
}

Assert::isInstanceOf($entity, $this->class);
Assert::isInstanceOf($value, $this->class);

$accessor = PropertyAccess::createPropertyAccessor();
$property = $this->getProperty();

if (! $accessor->isReadable($entity, $property)) {
if (! $accessor->isReadable($value, $property)) {
return null;
}

$value = $accessor->getValue($entity, $property);
$valueObject = $accessor->getValue($value, $property);

if ($value === null) {
if ($valueObject === null) {
return null;
}

if (! is_string($value) && ! is_numeric($value)) {
if (! is_string($valueObject) && ! is_numeric($valueObject)) {
throw new LogicException('id hast to be string or integer', 1653564596059);
}

return (string) $value;
return (string) $valueObject;
}

/**
* @phpstan-param string|null $id
*
* @phpstan-return object|null
*/
public function reverseTransform($id): ?object
public function reverseTransform(mixed $value): mixed
{
if ($id === null) {
if ($value === null) {
return null;
}

Expand All @@ -67,11 +55,14 @@ public function reverseTransform($id): ?object
$class = $this->getClass();

$result = $repo->findOneBy([
$property => $id,
$property => $value,
]);

if ($result === null) {
throw new TransformationFailedException(sprintf('Can\'t find entity of class "%s" with property "%s" = "%s".', $class, $property, $id));
throw new TransformationFailedException(
sprintf('Can\'t find entity of class "%s" with property "%s" = "%s".', $class, $property, $value),
1701526691297,
);
}

Assert::isInstanceOf($result, $this->class);
Expand Down
39 changes: 15 additions & 24 deletions src/Form/DataTransformer/ObjectsToIdTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,61 +13,52 @@
use function implode;
use function sprintf;

/**
* @template-extends Transformer<object[], string>
*/
/** @template-extends Transformer<object[], string> */
class ObjectsToIdTransformer extends Transformer
{
/**
* @phpstan-param object[]|null $entity
*
* @phpstan-return string|null
*/
public function transform($entity)
public function transform(mixed $value): mixed
{
if ($entity === null) {
if ($value === null) {
return null;
}

Assert::allIsInstanceOf($entity, $this->class);
Assert::allIsInstanceOf($value, $this->class);

$accessor = PropertyAccess::createPropertyAccessor();
$property = $this->getProperty();

$value = [];
$valueIds = [];

foreach ($entity as $e) {
foreach ($value as $e) {
if (! $accessor->isReadable($e, $property)) {
continue;
}

$value[] = $accessor->getValue($e, $property);
$valueIds[] = $accessor->getValue($e, $property);
}

return implode(',', $value);
return implode(',', $valueIds);
}

/**
* @phpstan-param string|null $id
*
* @phpstan-return object[]
*/
public function reverseTransform($id): array
public function reverseTransform(mixed $value): mixed
{
if ($id === null) {
if ($value === null) {
return [];
}

$repo = $this->getRepository();
$property = $this->getProperty();
$class = $this->getClass();

$ids = explode(',', $id);
$ids = explode(',', $value);

$results = $repo->findBy([$property => $ids]);

if (count($results) === 0) {
throw new TransformationFailedException(sprintf('Can\'t find entity of class "%s" with property "%s" = "%s".', $class, $property, $id));
throw new TransformationFailedException(
sprintf('Can\'t find entity of class "%s" with property "%s" = "%s".', $class, $property, $value),
1701526676576,
);
}

Assert::allIsInstanceOf($results, $this->class);
Expand Down
Loading

0 comments on commit 2559154

Please sign in to comment.