This repository has been archived by the owner on Jun 23, 2024. It is now read-only.
forked from navitronic/psymf
-
-
Notifications
You must be signed in to change notification settings - Fork 29
chore: Migrate away from ContainerAwareInterface + Allow Symfony 7 #80
Open
aszenz
wants to merge
4
commits into
theofidry:master
Choose a base branch
from
aszenz:chore/fix-deprecation-on-symfony-6.4
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
chore: Migrate away from ContainerAwareInterface + Allow Symfony 7 #80
aszenz
wants to merge
4
commits into
theofidry:master
from
aszenz:chore/fix-deprecation-on-symfony-6.4
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lstrojny
reviewed
Jan 25, 2024
src/PsyshFacade.php
Outdated
} | ||
|
||
public static function debug(array $variables = [], $bind = null): void | ||
{ | ||
self::init(); | ||
if (!isset(self::$shell)) { | ||
throw new RuntimeException('Cannot initialize the facade without a container.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Message should mention the shell, not the container
aszenz
changed the title
chore: Migrate away from ContainerAwareInterface
chore: Migrate away from ContainerAwareInterface + Allow Symfony 7
Jan 26, 2024
+ Use psysh 0.12 + Use symfony/yaml component since symfony/symfony can'tinstalled on 7
aszenz
force-pushed
the
chore/fix-deprecation-on-symfony-6.4
branch
from
January 26, 2024 15:50
18a4e73
to
edbdf0a
Compare
@theofidry Could you check this pr |
I’ve been running this patch in the real world for some time and I noticed a performance regression of up to 40ms on every request in environments where the bundle is enabled. Because But: replacing it with a service closure works and makes it lazy again and removes the performance penalty. diff --git a/resources/config/services.xml b/resources/config/services.xml
index 12617b5..4191ba1 100644
--- a/resources/config/services.xml
+++ b/resources/config/services.xml
@@ -21,8 +21,8 @@
</service>
<service id="psysh.facade" class="Fidry\PsyshBundle\PsyshFacade" public="true">
- <call method="setShell">
- <argument type="service" id="psysh.shell" />
+ <call method="setShellInitializer">
+ <argument type="service_closure" id="psysh.shell" />
</call>
</service>
diff --git a/src/PsyshFacade.php b/src/PsyshFacade.php
index c39f9a3..1a9c933 100644
--- a/src/PsyshFacade.php
+++ b/src/PsyshFacade.php
@@ -11,6 +11,7 @@
namespace Fidry\PsyshBundle;
+use Closure;
use Psy\Shell;
use RuntimeException;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
@@ -23,10 +24,15 @@ use function array_merge;
final class PsyshFacade
{
private static Shell $shell;
+ private static Closure $shellInitializer;
public static function init(): void
{
- // noop ... keeping the method as is for backward compatibility
+ if (isset(self::$shell)) {
+ return;
+ }
+
+ self::$shell = (self::$shellInitializer)();
}
public static function debug(array $variables = [], $bind = null): void
@@ -40,8 +46,8 @@ final class PsyshFacade
self::$shell::debug($_variables, $bind);
}
- public function setShell(Shell $shell): void
+ public function setShellInitializer(Closure $shellInitializer): void
{
- self::$shell = $shell;
+ self::$shellInitializer = $shellInitializer;
}
} |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Partially fixes #79
#SymfonyHackday