Skip to content

Commit

Permalink
Move TwigMethod traits out of PSR-4 namespace and instead do the requ…
Browse files Browse the repository at this point in the history
…ire in symfony-version-compatibility.php
  • Loading branch information
asgrim committed Jul 12, 2021
1 parent 2fbcab4 commit a59be64
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ All notable changes to this project will be documented in this file, in reverse
### Fixed

- [#227](https://github.com/scoutapp/scout-apm-php/pull/227) Fixed "double logging" of SQL queries with new "leafNode" flag on spans
- [#231](https://github.com/scoutapp/scout-apm-php/pull/231) Fixed how TwigMethods traits are included to work with Composer optimised autoloader properly

## 6.3.0 - 2021-06-17

Expand Down
4 changes: 2 additions & 2 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<directory name="tests" />
<ignoreFiles>
<directory name="vendor" />
<file name="src/ScoutApmBundle/Twig/TwigMethods-Twig2.php" />
<file name="src/ScoutApmBundle/Twig/TwigMethods-Twig3.php" />
<file name="stub/TwigMethods-Twig2.php" />
<file name="stub/TwigMethods-Twig3.php" />
<file name="tests/psalm-stubs.php" />
</ignoreFiles>
</projectFiles>
Expand Down
16 changes: 1 addition & 15 deletions src/ScoutApmBundle/Twig/TwigDecorator.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<?php // phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
/**
* @noinspection PhpInternalEntityUsedInspection
* @noinspection TransitiveDependenciesUsageInspection
*/
<?php

declare(strict_types=1);

Expand All @@ -13,16 +9,6 @@
use Twig\Environment as Twig;
use Twig\TemplateWrapper;

/**
* @psalm-suppress RedundantCondition
* @psalm-suppress TypeDoesNotContainType
*/
if (Twig::MAJOR_VERSION === 2) {
require_once __DIR__ . '/TwigMethods-Twig2.php';
} else {
require_once __DIR__ . '/TwigMethods-Twig3.php';
}

class TwigDecorator extends Twig
{
use TwigMethods;
Expand Down
17 changes: 17 additions & 0 deletions src/ScoutApmBundle/symfony-version-compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,20 @@ class ControllerEvent extends FilterControllerEvent {
}
}
}

namespace Scoutapm\ScoutApmBundle\Twig
{
use Twig\Environment as Twig;

if (class_exists(Twig::class)) {
/**
* @psalm-suppress RedundantCondition
* @psalm-suppress TypeDoesNotContainType
*/
if (Twig::MAJOR_VERSION === 2) {
require_once __DIR__ . '/../../stub/TwigMethods-Twig2.php';
} else {
require_once __DIR__ . '/../../stub/TwigMethods-Twig3.php';
}
}
}
File renamed without changes.
File renamed without changes.

0 comments on commit a59be64

Please sign in to comment.