Skip to content

Add support for Symfony 7 #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ ${SOURCE_DIR}/vendor/composer/installed.json:
$(COMPOSER) --no-interaction install --ansi --no-progress --prefer-dist

.PHONY: atoum
atoum: export XDEBUG_MODE=coverage
atoum:
$(call printSection,TEST atoum)
${BIN_DIR}/atoum
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
"prefer-stable": true,
"require": {
"php": ">=8.0",
"symfony/config": "^4.4|^5.0|^6.0",
"symfony/yaml": "^4.4|^5.0|^6.0",
"symfony/routing": "^4.4|^5.0|^6.0",
"symfony/expression-language": "^4.4|^5.0|^6.0",
"symfony/security-core": "^4.4|^5.0|^6.0",
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
"symfony/http-kernel": "^4.4|^5.0|^6.0"
"symfony/config": "^4.4|^5.0|^6.0|^7.0",
"symfony/yaml": "^4.4|^5.0|^6.0|^7.0",
"symfony/routing": "^4.4|^5.0|^6.0|^7.0",
"symfony/expression-language": "^4.4|^5.0|^6.0|^7.0",
"symfony/security-core": "^4.4|^5.0|^6.0|^7.0",
"symfony/dependency-injection": "^4.4|^5.0|^6.0|^7.0",
"symfony/http-kernel": "^4.4|^5.0|^6.0|^7.0"
},
"require-dev": {
"atoum/atoum": "^3.4|^4.0",
"m6web/php-cs-fixer-config": "^2.1",
"symfony/http-foundation": "^4.4|^5.0|^6.0",
"m6web/php-cs-fixer-config": "^3.0",
"symfony/http-foundation": "^4.4|^5.0|^6.0|^7.0",
"phpstan/phpstan": "^1.7",
"rector/rector": "^0.13.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(array $items = [])

public function add(Filter $item): FilterCollection
{
if (!in_array($item->getName(), $this->keys, true)) {
if (!\in_array($item->getName(), $this->keys, true)) {
$this->keys[] = $item->getName();
}

Expand Down Expand Up @@ -106,6 +106,6 @@ public function valid(): bool

public function count(): int
{
return count($this->values);
return \count($this->values);
}
}
16 changes: 8 additions & 8 deletions src/M6Web/Bundle/LogBridgeBundle/Config/FilterParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,30 @@ protected function getAllRoutes(): array
public function parse(string $name, array $config): Filter
{
if (
(!array_key_exists('route', $config) && !array_key_exists('routes', $config))
|| !array_key_exists('method', $config)
|| !array_key_exists('status', $config)
(!\array_key_exists('route', $config) && !\array_key_exists('routes', $config))
|| !\array_key_exists('method', $config)
|| !\array_key_exists('status', $config)
) {
throw new ParseException(sprintf('Undefined "route(s)", "method" or "status" parameter from filter "%s"', $name));
}

if ((array_key_exists('route', $config) && $config['route'] !== null) && (array_key_exists('routes', $config) && !empty($config['routes']))) {
if ((\array_key_exists('route', $config) && $config['route'] !== null) && (\array_key_exists('routes', $config) && !empty($config['routes']))) {
throw new ParseException(sprintf('You can\'t use both "route" and "routes" parameter from filter "%s"', $name));
}

if (!array_key_exists('level', $config)) {
if (!\array_key_exists('level', $config)) {
$config['level'] = self::DEFAULT_LEVEL;
}

$filter = $this->createFilter($name)
->setMethod($config['method'])
->setStatus($config['status']);

if (array_key_exists('route', $config)) {
if (\array_key_exists('route', $config)) {
$this->parseRoute($filter, $config['route']);
}

if (array_key_exists('routes', $config)) {
if (\array_key_exists('routes', $config)) {
$this->parseRoutes($filter, $config['routes'] ?? []);
}

Expand Down Expand Up @@ -146,7 +146,7 @@ protected function parseRoutes(Filter $filter, ?array $routes): void

protected function parseLevel(Filter $filter, ?string $level): void
{
if (!in_array($level, $this->allowedLevels, true)) {
if (!\in_array($level, $this->allowedLevels, true)) {
throw new ParseException(sprintf('Invalid value "%s" from level parameter, allowed %s', $level, implode(', ', $this->allowedLevels)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function process(ContainerBuilder $container): void
$loggerClass = $container->getParameter($loggerClassParameter);
}

if (!in_array(\Psr\Log\LoggerInterface::class, class_implements($loggerClass), true)) {
if (!\in_array(\Psr\Log\LoggerInterface::class, class_implements($loggerClass), true)) {
throw new \InvalidArgumentException(sprintf('Class "%s" must be implement "Psr\Log\LoggerInterface"', $loggerClass));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getLogContent(Request $request, Response $response, array $optio
$requestContent = "Request\n------------------------\n";

foreach ($requestHeaders as $name => $headerValue) {
$value = is_array($headerValue) ? $headerValue[0] : $headerValue;
$value = \is_array($headerValue) ? $headerValue[0] : $headerValue;
$requestContent .= str_pad((string) $name, 20, ' ', STR_PAD_RIGHT).': '.$value."\n";
}

Expand All @@ -76,9 +76,9 @@ public function getLogContent(Request $request, Response $response, array $optio
$responseContent .= $response->headers->__toString();

// Render post parameters
if (array_key_exists('post_parameters', $options)
if (\array_key_exists('post_parameters', $options)
&& $options['post_parameters'] == true
&& in_array($request->getMethod(), ['POST', 'PUT', 'PATCH'])) {
&& \in_array($request->getMethod(), ['POST', 'PUT', 'PATCH'])) {
$responseContent .= "Post parameters\n";
$responseContent .= $this->formatParameters($request->request->all());
}
Expand Down
4 changes: 2 additions & 2 deletions src/M6Web/Bundle/LogBridgeBundle/Matcher/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public function getAbsoluteCachePath(): string
return sprintf('%s/%s.php', $this->getCacheDir(), $this->getMatcherClassName());
}

public function isDebug(bool $debug = null): bool
public function isDebug(?bool $debug = null): bool
{
if (is_bool($debug)) {
if (\is_bool($debug)) {
$this->debug = $debug;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ private function generateMatchList(Configuration $configuration): string
$code .= sprintf(" '%s' => [\n", $filterKey);

foreach ($filter as $key => $config) {
if (is_array($config)) {
if (\is_array($config)) {
$code .= sprintf(" '%s' => [", $key);

if (count($config) > 0) {
if (\count($config) > 0) {
$code .= "\n";

foreach ($config as $name => $value) {
if (is_bool($value)) {
if (\is_bool($value)) {
$value = $value == true ? 'true' : 'false';
} else {
$value = "'".$value."'";
Expand Down Expand Up @@ -261,7 +261,7 @@ private function compileFilter(Filter $filter): array
/** @var array $routesPrefix */
$routesPrefix = $filter->getRoutes();
/** @var string $prefix */
$prefix = is_null($filter->getRoute()) ? 'all' : $filter->getRoute();
$prefix = \is_null($filter->getRoute()) ? 'all' : $filter->getRoute();

$compiledKeys = isset($routesPrefix) ?
$this->compileFilterRoutes($filter, $routesPrefix, $compiledKeys) :
Expand Down Expand Up @@ -320,7 +320,7 @@ private function compileFilterStatus(?string $prefix, Filter $filter): array
/** @var string[]|null $filterStatusList */
$filterStatusList = $filter->getStatus();

if (is_null($filterStatusList)) {
if (\is_null($filterStatusList)) {
$compiled[] = sprintf('%s.all', $prefix);
} else {
foreach ($this->parseStatus($filterStatusList) as $status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ protected function getPattern(): string
*/
protected function transform(string $config): array
{
$refStatus = substr($config, 0, strlen((string) ((int) $config - 2)));
$refStatus = substr($config, 0, \strlen((string) ((int) $config - 2)));

$rangeInterval = 100;
if (strlen($refStatus) === 2) {
if (\strlen($refStatus) === 2) {
$rangeInterval = 10;
}

Expand Down