Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/verify-stability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '8.0', '8.1', '8.2' ]
php-versions: [ '8.2', '8.3' ]
env:
extensions: dom, fileinfo, intl, json, pcre, simplexml
key: cache-v1 # can be any string, change to clear the extension cache.
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '8.0', '8.1', '8.2' ]
php-versions: [ '8.2', '8.3' ]
env:
extensions: dom, fileinfo, intl, json, pcre, simplexml
key: cache-v1 # can be any string, change to clear the extension cache.
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '8.0', '8.1', '8.2' ]
php-versions: [ '8.2', '8.3' ]
env:
extensions: dom, fileinfo, intl, json, pcre, simplexml
key: cache-v1 # can be any string, change to clear the extension cache.
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ Common & useful classes, resources, extensions. Based on Symfony framework.
translations [using the ICU MessageFormat](https://symfony.com/doc/current/reference/formats/message_format.html#pluralization)
3. Update the `meritoo/common-library` package to `^1.3`
4. Fix PHPStan errors
5. Bump minimum PHP version: `8.0` -> `8.2`
1. All the `*Type` classes, that extend `Meritoo\Common\Type\Base\BaseType` class, have been replaced by enumerations

| Before | After |
|-----------------------------------------------------------------------|---------------------------------------------------------|
| `Meritoo\CommonBundle\Type\DependencyInjection\ConfigurationFileType` | `Meritoo\CommonBundle\Enums\Date\ConfigurationFileType` |
| `Meritoo\CommonBundle\Type\Date\DateLength` | `Meritoo\CommonBundle\Enums\Date\DateLength` |
| `Meritoo\Common\Type\OopVisibilityType` | `Meritoo\Common\Enums\OopVisibility` |

2. Other than that:
- The following classes have been removed as not needed anymore:
- `Meritoo\CommonBundle\Exception\Type\Date\UnknownDateLengthException`
- `Meritoo\CommonBundle\Exception\Type\DependencyInjection\UnknownConfigurationFileTypeException`
- `Meritoo\Test\CommonBundle\DependencyInjection\Base\BaseExtension\UnknownServicesFileType\Extension`

# 0.3.1

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.2",
"ext-intl": "*",
"doctrine/annotations": "^2.0",
"meritoo/common-library": "^1.3",
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
# Required to run project
#
php:
image: meritoo/php:8.0
image: meritoo/php:8.2
container_name: ${DOCKER_CONTAINER_OWNER}-${DOCKER_CONTAINER_PROJECT}-php
entrypoint: php
command: -S 0.0.0.0:9999
Expand All @@ -12,7 +12,7 @@ services:
volumes:
- .:/var/www/application:cached
composer:
image: meritoo/php:8.0
image: meritoo/php:8.2
container_name: ${DOCKER_CONTAINER_OWNER}-${DOCKER_CONTAINER_PROJECT}-composer
entrypoint: php -d memory_limit=-1 /usr/local/bin/composer
volumes:
Expand All @@ -21,7 +21,7 @@ services:
# Required to run PHPUnit's tests
#
phpunit:
image: meritoo/php:8.0
image: meritoo/php:8.2
container_name: ${DOCKER_CONTAINER_OWNER}-${DOCKER_CONTAINER_PROJECT}-phpunit
entrypoint: ./vendor/bin/simple-phpunit
command: --version
Expand Down
5 changes: 1 addition & 4 deletions src/Bundle/Descriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,7 @@ public function getDataFixturesDirectoryPath(): ?string
return null;
}

return Miscellaneous::concatenatePaths([
$path,
static::PATH_DATA_FIXTURES,
]);
return Miscellaneous::concatenatePaths($path, static::PATH_DATA_FIXTURES);
}

/**
Expand Down
30 changes: 13 additions & 17 deletions src/DependencyInjection/Base/BaseExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Meritoo\Common\Utilities\Arrays;
use Meritoo\Common\Utilities\Miscellaneous;
use Meritoo\CommonBundle\DependencyInjection\ConfigurationFile\FileLoaderFactory;
use Meritoo\CommonBundle\Type\DependencyInjection\ConfigurationFileType;
use Meritoo\CommonBundle\Enums\Date\ConfigurationFileType;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -31,7 +31,7 @@ abstract class BaseExtension extends ConfigurableExtension
/**
* Default extension of configuration files
*
* @var string
* @var ConfigurationFileType
*/
protected const CONFIGURATION_DEFAULT_EXTENSION = ConfigurationFileType::YAML;

Expand Down Expand Up @@ -123,7 +123,7 @@ protected function getKeysToStopLoadingParametersOn(): array
*/
protected function getServicesFileName(): string
{
return sprintf('%s.%s', static::CONFIGURATION_SERVICES_NAME, static::CONFIGURATION_DEFAULT_EXTENSION);
return sprintf('%s.%s', static::CONFIGURATION_SERVICES_NAME, static::CONFIGURATION_DEFAULT_EXTENSION->value);
}

/**
Expand Down Expand Up @@ -151,7 +151,7 @@ private function getConfigurationFileWithExtension(string $fileName): string

// Use the default extension, if extension of configuration file is unknown
if (empty($fileExtension)) {
return Miscellaneous::includeFileExtension($fileName, static::CONFIGURATION_DEFAULT_EXTENSION);
return Miscellaneous::includeFileExtension($fileName, static::CONFIGURATION_DEFAULT_EXTENSION->value);
}

return $fileName;
Expand All @@ -162,12 +162,15 @@ private function getConfigurationFileWithExtension(string $fileName): string
*
* @param ContainerBuilder $container Container for the Dependency Injection (DI)
* @param FileLocator $locator Locator used to find files
* @param string $fileType Type of configuration file
* @param ConfigurationFileType $fileType Type of configuration file
*
* @return null|FileLoader
*/
private function getFileLoader(ContainerBuilder $container, FileLocator $locator, string $fileType): ?FileLoader
{
private function getFileLoader(
ContainerBuilder $container,
FileLocator $locator,
ConfigurationFileType $fileType,
): ?FileLoader {
$loaderFactory = new FileLoaderFactory($container, $locator);

if (ConfigurationFileType::YAML === $fileType) {
Expand Down Expand Up @@ -236,22 +239,15 @@ private function loadConfigurationFile(ContainerBuilder $container, string $file
return;
}

$resourcesPath = Miscellaneous::concatenatePaths([
$bundlePath,
static::CONFIGURATION_PATH,
]);

$filePath = Miscellaneous::concatenatePaths([
$resourcesPath,
$fileName,
]);
$resourcesPath = Miscellaneous::concatenatePaths($bundlePath, static::CONFIGURATION_PATH);
$filePath = Miscellaneous::concatenatePaths($resourcesPath, $fileName);

// Configuration file doesn't exist or is not readable? Nothing to do
if (!is_readable($filePath)) {
return;
}

$fileType = (new ConfigurationFileType())->getTypeFromFileName($fileName);
$fileType = ConfigurationFileType::getTypeFromFileName($fileName);
$locator = new FileLocator($resourcesPath);

// Let's load the configuration file
Expand Down
8 changes: 4 additions & 4 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

namespace Meritoo\CommonBundle\DependencyInjection;

use Meritoo\CommonBundle\Enums\Date\DateLength;
use Meritoo\CommonBundle\Service\ApplicationService;
use Meritoo\CommonBundle\Type\Date\DateLength;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
Expand Down Expand Up @@ -120,15 +120,15 @@ private function getDateNode(): NodeDefinition
->arrayNode('format')
->addDefaultsIfNotSet()
->children()
->scalarNode(DateLength::DATE)
->scalarNode(DateLength::Date->value)
->info('Format of date without time')
->defaultValue('d.m.Y')
->end()
->scalarNode(DateLength::DATETIME)
->scalarNode(DateLength::DateTime->value)
->info('Format of date with time')
->defaultValue('d.m.Y H:i')
->end()
->scalarNode(DateLength::TIME)
->scalarNode(DateLength::Time->value)
->info('Format of time without date')
->defaultValue('H:i')
->end()
Expand Down
5 changes: 1 addition & 4 deletions src/DependencyInjection/MeritooCommonExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ class MeritooCommonExtension extends BaseExtension
*/
protected function getBundleDirectoryPath(): string
{
return Miscellaneous::concatenatePaths([
__DIR__,
'..',
]);
return Miscellaneous::concatenatePaths(__DIR__, '..');
}
}
34 changes: 34 additions & 0 deletions src/Enums/Date/ConfigurationFileType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* (c) Meritoo.pl, http://www.meritoo.pl
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Meritoo\CommonBundle\Enums\Date;

use Meritoo\Common\Utilities\Miscellaneous;

enum ConfigurationFileType: string
{
case PHP = 'php';
case XML = 'xml';
case YAML = 'yaml';

/**
* Returns type of configuration file based on name of the file
*
* @param string $fileName Name of configuration file
*
* @return ConfigurationFileType
*/
public static function getTypeFromFileName(string $fileName): self
{
$fileExtension = strtolower(Miscellaneous::getFileExtension($fileName));

return self::tryFrom($fileExtension);
}
}
18 changes: 18 additions & 0 deletions src/Enums/Date/DateLength.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/**
* (c) Meritoo.pl, http://www.meritoo.pl
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Meritoo\CommonBundle\Enums\Date;

enum DateLength: string
{
case Date = 'date';
case DateTime = 'datetime';
case Time = 'time';
}
37 changes: 0 additions & 37 deletions src/Exception/Type/Date/UnknownDateLengthException.php

This file was deleted.

This file was deleted.

Loading
Loading