Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

chore: Migrate away from ContainerAwareInterface + Allow Symfony 7 #80

Open
wants to merge 4 commits 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
16 changes: 14 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ jobs:
symfony-version:
- '^5.4'
- '^6.0'
- '^7.0'
php-version:
- '8.0'
- '8.1'
- '8.2'
exclude:
- symfony-version: '^5.4'
php-version: '8.2'
- symfony-version: '^7.0'
php-version: '8.0'
- symfony-version: '^7.0'
php-version: '8.1'
steps:
- name: 'Checkout code'
uses: actions/[email protected]
Expand All @@ -22,13 +34,13 @@ jobs:
uses: shivammathur/[email protected]
with:
coverage: none
php-version: '8.0'
php-version: ${{ matrix.php-version }}
tools: composer:v2
extensions: mbstring
ini-values: date.timezone=UTC

- name: 'Configure Symfony version'
run: composer require --dev --no-update "symfony/symfony:${{ matrix.symfony-version }}"
run: composer require --dev --no-update "symfony/yaml:${{ matrix.symfony-version }}"

- name: 'Install project dependencies'
run: composer update --prefer-dist --prefer-stable
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

"require": {
"php": ">=8.0",
"psy/psysh": "^0.11",
"symfony/error-handler": "^5.4|^6.0",
"symfony/expression-language": "^5.4|^6.0",
"symfony/framework-bundle": "^5.4|^6.0"
"psy/psysh": "^0.12",
"symfony/error-handler": "^5.4|^6.0|^7.0",
"symfony/expression-language": "^5.4|^6.0|^7.0",
"symfony/framework-bundle": "^5.4|^6.0|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"symfony/symfony": "^5.4|^6.0"
"symfony/yaml": "^5.4|^6.0|^7.0"
},

"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
</service>

<service id="psysh.facade" class="Fidry\PsyshBundle\PsyshFacade" public="true">
<call method="setContainer">
<argument type="service" id="test.service_container" />
<call method="setShell">
<argument type="service" id="psysh.shell" />
</call>
</service>

Expand Down
24 changes: 8 additions & 16 deletions src/PsyshFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,28 @@
/**
* @author Théo FIDRY <[email protected]>
*/
final class PsyshFacade implements ContainerAwareInterface
final class PsyshFacade
{
private static Shell $shell;

private static ContainerInterface $container;

public static function init(): void
{
if (isset(self::$shell)) {
return;
}

if (!isset(self::$container)) {
throw new RuntimeException('Cannot initialize the facade without a container.');
}

self::$shell = self::$container->get('psysh.shell');
// noop ... keeping the method as is for backward compatibility
}

public static function debug(array $variables = [], $bind = null): void
{
self::init();
if (!isset(self::$shell)) {
throw new RuntimeException('Cannot initialize the facade without shell.');
}

$_variables = array_merge(self::$shell->getScopeVariables(), $variables);

self::$shell::debug($_variables, $bind);
\Psy\debug($_variables, $bind);
}

public function setContainer(ContainerInterface $container = null): void
public function setShell(Shell $shell): void
{
self::$container = $container;
self::$shell = $shell;
}
}