From 27cd8b23f6aa0d6c1aa81a2e5133b09b7c4a62d4 Mon Sep 17 00:00:00 2001 From: Michal Kruczek Date: Wed, 10 Jan 2024 11:38:07 +0100 Subject: [PATCH 1/2] feat: php-cs-fixer - removing deprecations 1. Detected deprecations in use: - Rule "braces" is deprecated. Use "single_space_around_construct", "control_structure_braces", "control_structure_continuation_position", "declare_parentheses", "no_multiple_statements_per_line", "curly_braces_position", "statement_indentation" and "no_extra_blank_lines" instead. 2. Detected deprecations in use: - Rule "curly_braces_position" is deprecated. Use "braces_position" instead. --- .php-cs-fixer.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 29ef69ef..33f4467d 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -15,9 +15,14 @@ '@Symfony' => true, '@Symfony:risky' => true, 'array_syntax' => ['syntax' => 'short'], - 'braces' => [ - 'allow_single_line_closure' => true, - ], + 'single_space_around_construct' => true, + 'control_structure_braces' => true, + 'control_structure_continuation_position' => true, + 'declare_parentheses' => true, + 'no_multiple_statements_per_line' => true, + 'braces_position' => true, + 'statement_indentation' => true, + 'no_extra_blank_lines' => true, 'concat_space' => [ 'spacing' => 'one', ], From 25acbd229ffb723cfb5691f310589e4d9dad30f3 Mon Sep 17 00:00:00 2001 From: Maciej <14310995+falkenhawk@users.noreply.github.com> Date: Thu, 25 Apr 2019 12:32:00 +0200 Subject: [PATCH 2/2] Use sourceCache if isSupported check passes, otherwise proceed without cache and do not throw an exception - so that php-di does not break if there is any problem with apcu - instead of having to wrap ContainerBuilder::build() with try...catch block --- src/ContainerBuilder.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ContainerBuilder.php b/src/ContainerBuilder.php index 7a7285c7..6615d0b6 100644 --- a/src/ContainerBuilder.php +++ b/src/ContainerBuilder.php @@ -125,10 +125,8 @@ public function build() // Mutable definition source $source->setMutableDefinitionSource(new DefinitionArray([], $autowiring)); - if ($this->sourceCache) { - if (!SourceCache::isSupported()) { - throw new \Exception('APCu is not enabled, PHP-DI cannot use it as a cache'); - } + // use cache if isSupported check passes, otherwise proceed without cache and do not throw an exception + if ($this->sourceCache && SourceCache::isSupported()) { // Wrap the source with the cache decorator $source = new SourceCache($source, $this->sourceCacheNamespace); }