Skip to content

Commit

Permalink
init symfony 7 support
Browse files Browse the repository at this point in the history
apply suggested change for Prophecy trait usage

update dependencies

switch to xml mapping to avoid annotation/attribute retrocompatibility issues

add sqlite extension to ci

add missing behat test to makefile command

set minimum php version requirement to 8.0

bump dependencies to versions supporting php 8.0

use attribute mapping

update makefile
  • Loading branch information
Sakonokode committed Jun 3, 2024
1 parent e678e10 commit a53dd8a
Show file tree
Hide file tree
Showing 61 changed files with 184 additions and 166 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ jobs:
name: Unit tests
strategy:
matrix:
php: [ 8.0, 8.1, 8.2 ]
php: [ 8.1, 8.2 ]
os: [ ubuntu-latest ]
include:
- os: [ ubuntu-latest ]
php: 7.4
php: 8.0
composer-flag: "'--prefer-lowest'"

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -72,11 +72,11 @@ jobs:
name: Functionnal tests
strategy:
matrix:
php: [ 8.0, 8.1, 8.2 ]
php: [ 8.1, 8.2 ]
os: [ ubuntu-latest ]
include:
- os: [ ubuntu-latest ]
php: 7.4
php: 8.0
composer-flag: "'--prefer-lowest'"

runs-on: ${{ matrix.os }}
Expand All @@ -87,6 +87,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: sqlite3

- uses: actions/cache@v2
id: cache-composer
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ vendor
tests/TestApplication/var
.couscous
.phpunit.result.cache
.idea
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ clean: ## Stop the project and remove generated files
# -------
#

test: test.composer test.phpcs test.phpunit ## Run all tests
test: test.composer test.phpcs test.phpunit test.behat ## Run all tests
.PHONY: test

test.composer: ## Validate composer.json
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Features

Learn more in the [complete documentation](https://melodiia.swag.industries).

Requirements
-------
Melodiia requires PHP 8.0 or higher.

Install
-------

Expand Down
39 changes: 26 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,43 @@
"post-install-cmd": "make hooks.install"
},
"require": {
"php": ">=7.3",
"php": ">=8.0",
"nekland/tools": "^2.5.1",
"symfony/event-dispatcher": "^5.3 || ^6.0",
"symfony/event-dispatcher": "^5.3 || ^6.0 || 7.0.8",
"pagerfanta/pagerfanta": "^2.0.1 || ^3.0.0",
"symfony/yaml": "^5.3 || ^6.0",
"symfony/serializer": "^5.3 || ^6.0",
"symfony/yaml": "^5.3 || ^6.0 || 7.0.8",
"symfony/serializer": "^5.3.12 || ^6.0 || 7.0.8",
"pagerfanta/doctrine-orm-adapter": "^3.5"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"psr/container": "^v1.1.1 || ^2.0",
"phpunit/phpunit": "^8.5",
"friendsofphp/php-cs-fixer": "^v3.3.2",
"phpunit/phpunit": "^9.6 || ^10.0.0 || ^11.1.3",
"friendsofphp/php-cs-fixer": "3.58.0",
"phpspec/prophecy": "^1.8",
"twig/twig": "^2.5",
"symfony/symfony": "^5.3 || ^6.0",
"doctrine/orm": "^v2.6.6",
"twig/twig": "^2.5 || ^3.10",
"doctrine/orm": "^2.6.6 || ^2.17.0",
"justinrainbow/json-schema": "^5.2",
"doctrine/annotations": "^1.8",
"doctrine/doctrine-bundle": "^2.1",
"behat/behat": "3.10.0",
"doctrine/doctrine-bundle": "^2.12.0",
"behat/behat": "3.14.0",
"friends-of-behat/symfony-extension": "^2.3.0",
"fakerphp/faker": "^1.12.1",
"monolog/monolog": "^3.4 || ^2.9",
"masterminds/html5": "^2.8"
"masterminds/html5": "^2.8",
"phpspec/prophecy-phpunit": "^2.0.0",
"symfony/dotenv": "^5.3 || ^6.0 || 7.0.8",
"symfony/security-bundle": "^5.4.20 || ^6.2.6 || 7.0.8",
"symfony/twig-bundle": "^5.3 || ^6.0 || 7.0.8",
"symfony/web-profiler-bundle": "^5.3 || ^6.0 || 7.0.8",
"symfony/asset": "^5.3 || ^6.0 || 7.0.8",
"symfony/form": "^5.3 || ^6.0 || 7.0.8",
"symfony/validator": "^5.3 || ^6.0 || 7.0.8",
"symfony/framework-bundle": "^5.3 || ^6.0 || 7.0.8",
"symfony/dependency-injection": "^5.3 || ^6.0 || 7.0.8",
"symfony/config": "^5.3 || ^6.0 || 7.0.8",
"symfony/proxy-manager-bridge": "^5.3 || ^6.4",
"symfony/browser-kit": "^5.3 || ^6.0 || 7.0.8",
"symfony/doctrine-bridge": "^5.3 || ^6.0 || 7.0.8"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Crud/Controller/BaseCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(EventDispatcherInterface $eventDispatcher)
/**
* @return ApiResponse|FormInterface
*/
protected function decodeInputData(FormFactoryInterface $formFactory, string $form, Request $request, bool $clearMissing = null, object $data = null)
protected function decodeInputData(FormFactoryInterface $formFactory, string $form, Request $request, ?bool $clearMissing = null, ?object $data = null)
{
$form = $formFactory->createNamed('', $form, $data, ['clear_missing' => $clearMissing]);
$form->handleRequest($request);
Expand Down
2 changes: 1 addition & 1 deletion src/Crud/Controller/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class Create extends BaseCrudController
/** @var AuthorizationCheckerInterface|null */
private $checker;

public function __construct(DataStoreInterface $dataStore, FormFactoryInterface $formFactory, EventDispatcherInterface $dispatcher, AuthorizationCheckerInterface $checker = null)
public function __construct(DataStoreInterface $dataStore, FormFactoryInterface $formFactory, EventDispatcherInterface $dispatcher, ?AuthorizationCheckerInterface $checker = null)
{
parent::__construct($dispatcher);
$this->dataStore = $dataStore;
Expand Down
2 changes: 1 addition & 1 deletion src/Crud/Controller/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class Delete extends BaseCrudController implements CrudControllerInterface
/** @var IdResolverInterface */
private $idResolver;

public function __construct(DataStoreInterface $dataStore, EventDispatcherInterface $dispatcher, IdResolverInterface $idResolver = null, AuthorizationCheckerInterface $checker = null)
public function __construct(DataStoreInterface $dataStore, EventDispatcherInterface $dispatcher, ?IdResolverInterface $idResolver = null, ?AuthorizationCheckerInterface $checker = null)
{
parent::__construct($dispatcher);
$this->dataStore = $dataStore;
Expand Down
2 changes: 1 addition & 1 deletion src/Crud/Controller/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class Get implements CrudControllerInterface
/** @var IdResolverInterface */
private $idResolver;

public function __construct(DataStoreInterface $dataStore, IdResolverInterface $idResolver = null, AuthorizationCheckerInterface $checker = null)
public function __construct(DataStoreInterface $dataStore, ?IdResolverInterface $idResolver = null, ?AuthorizationCheckerInterface $checker = null)
{
$this->dataStore = $dataStore;
$this->idResolver = $idResolver ?? new SimpleIdResolver();
Expand Down
2 changes: 1 addition & 1 deletion src/Crud/Controller/GetAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
DataStoreInterface $dataStore,
FilterCollectionFactoryInterface $collectionFactory,
PaginationRequestFactoryInterface $pagesRequestFactory,
AuthorizationCheckerInterface $checker = null
?AuthorizationCheckerInterface $checker = null
) {
$this->dataStore = $dataStore;
$this->checker = $checker;
Expand Down
2 changes: 1 addition & 1 deletion src/Crud/Controller/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class Update extends BaseCrudController
/** @var IdResolverInterface */
private $idResolver;

public function __construct(DataStoreInterface $dataStore, FormFactoryInterface $formFactory, EventDispatcherInterface $dispatcher, IdResolverInterface $idResolver = null, AuthorizationCheckerInterface $checker = null)
public function __construct(DataStoreInterface $dataStore, FormFactoryInterface $formFactory, EventDispatcherInterface $dispatcher, ?IdResolverInterface $idResolver = null, ?AuthorizationCheckerInterface $checker = null)
{
parent::__construct($dispatcher);
$this->dataStore = $dataStore;
Expand Down
6 changes: 0 additions & 6 deletions src/Crud/Event/CrudEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@

class CrudEvent extends Event
{
/**
* @var mixed
*/
private $data;

/**
* @param mixed $data
*/
public function __construct($data)
{
$this->data = $data;
Expand Down
2 changes: 0 additions & 2 deletions src/Crud/FilterCollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ public function add(FilterInterface $filter): void;

/**
* Executes filters against a query.
*
* @param mixed $query
*/
public function filter($query): void;

Expand Down
3 changes: 0 additions & 3 deletions src/Crud/Pagination/PaginationRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ public function __construct(MelodiiaConfigurationInterface $configuration)
$this->configuration = $configuration;
}

/**
* {@inheritdoc}
*/
public function createPaginationRequest(Request $request): PaginationRequest
{
$page = $request->query->getInt('page', self::DEFAULT_PAGE);
Expand Down
2 changes: 1 addition & 1 deletion src/Crud/Persistence/DataStoreInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ public function find(string $type, $id): ?object;
/**
* @param int $maxPerPage
*/
public function getPaginated(string $type, int $page, FilterCollectionInterface $filters, $maxPerPage = 30): PagerFanta;
public function getPaginated(string $type, int $page, FilterCollectionInterface $filters, $maxPerPage = 30): Pagerfanta;
}
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('melodiia');

Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/DoctrineDataStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function find(string $type, $id): ?object
return $this->getEntityManager()->getRepository($type)->find($id);
}

public function getPaginated(string $type, int $page, FilterCollectionInterface $filters, $maxPerPage = 30): PagerFanta
public function getPaginated(string $type, int $page, FilterCollectionInterface $filters, $maxPerPage = 30): Pagerfanta
{
$doctrineRepository = $this->getEntityManager()->getRepository($type);

Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/ExceptionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(
MelodiiaConfigurationInterface $config,
OnError $controller,
bool $debug,
ErrorListener $errorListener = null
?ErrorListener $errorListener = null
) {
$this->errorListener = $errorListener ?? new ErrorListener($controller, null, $debug);
$this->config = $config;
Expand Down
4 changes: 1 addition & 3 deletions src/Form/ApiRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class ApiRequestHandler implements RequestHandlerInterface
{
public function handleRequest(FormInterface $form, $request = null)
public function handleRequest(FormInterface $form, $request = null): void
{
if (!$request instanceof Request) {
throw new UnexpectedTypeException($request, 'Symfony\Component\HttpFoundation\Request');
Expand Down Expand Up @@ -44,8 +44,6 @@ public function handleRequest(FormInterface $form, $request = null)

/**
* Notice: this impacts allow_file_upload field.
*
* @param mixed $data
*/
public function isFileUpload($data): bool
{
Expand Down
5 changes: 1 addition & 4 deletions src/Form/DomainObjectDataMapperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@

interface DomainObjectDataMapperInterface extends DataMapperInterface
{
/**
* @return mixed
*/
public function createObject(iterable $form, string $dataClass = null);
public function createObject(iterable $form, ?string $dataClass = null);
}
5 changes: 1 addition & 4 deletions src/Form/DomainObjectsDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
*/
class DomainObjectsDataMapperBase extends DataMapper implements DomainObjectDataMapperInterface
{
/**
* {@inheritdoc}
*/
public function createObject(iterable $form, string $dataClass = null)
public function createObject(iterable $form, ?string $dataClass = null)
{
if (null === $dataClass && $form instanceof FormInterface) {
$dataClass = $form->getConfig()->getOption('data_class');
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/ApiType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ApiType extends AbstractType
/** @var DataMapperInterface */
private $dataMapper;

public function __construct(DataMapperInterface $dataMapper = null)
public function __construct(?DataMapperInterface $dataMapper = null)
{
$this->dataMapper = $dataMapper ?? new DomainObjectsDataMapper();
}
Expand Down
6 changes: 0 additions & 6 deletions src/Form/Type/CollectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@

class CollectionType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$resizeListener = new ResizeFormListener(
Expand All @@ -32,9 +29,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder->addEventSubscriber($reorderInputDataListener);
}

/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
Expand Down
6 changes: 0 additions & 6 deletions src/Form/Type/DateTimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

class DateTimeType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver
Expand All @@ -24,9 +21,6 @@ public function configureOptions(OptionsResolver $resolver)
;
}

/**
* {@inheritdoc}
*/
public function getParent()
{
return OriginalDateTimeType::class;
Expand Down
3 changes: 0 additions & 3 deletions src/MelodiiaBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

class MelodiiaBundle extends Bundle
{
/**
* {@inheritdoc}
*/
public function getContainerExtension(): ?ExtensionInterface
{
return new MelodiiaExtension();
Expand Down
3 changes: 0 additions & 3 deletions src/MelodiiaConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public function __construct(array $config)
$this->config = $config;
}

/**
* {@inheritdoc}
*/
public function getApiEndpoints(): array
{
$endpoints = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Response/Created.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Created implements ApiResponse
/** @var string|null */
private $resourceId;

public function __construct($id, string $resourceId = null)
public function __construct($id, ?string $resourceId = null)
{
$this->id = $id;
$this->resourceId = $resourceId;
Expand Down
4 changes: 0 additions & 4 deletions src/Response/OkContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class OkContent implements ApiResponse, SerializationContextAwareInterface
{
use SerializationContextAwareTrait;

/** @var mixed */
private $content;

public function __construct($content, $serializationGroups = [])
Expand All @@ -19,9 +18,6 @@ public function __construct($content, $serializationGroups = [])
$this->serializationContext = new SerializationContext($serializationGroups);
}

/**
* @return mixed
*/
public function getContent()
{
return $this->content;
Expand Down
4 changes: 2 additions & 2 deletions src/Serialization/Json/CreatedNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class CreatedNormalizer implements NormalizerInterface
{
public function normalize($object, string $format = null, array $context = []): array
public function normalize($object, ?string $format = null, array $context = []): array
{
$res = [];
$resource = $object->getResourceId();
Expand All @@ -22,7 +22,7 @@ public function normalize($object, string $format = null, array $context = []):
return $res;
}

public function supportsNormalization($data, string $format = null): bool
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
{
return is_object($data) && $data instanceof Created;
}
Expand Down
Loading

0 comments on commit a53dd8a

Please sign in to comment.