Skip to content

Commit

Permalink
Update for the latest version of the runtime component (#6)
Browse files Browse the repository at this point in the history
* Update for the latest version of the runtime component

* CS fix

* Remove "Root" tests

* We still need composer.json
  • Loading branch information
Nyholm authored Mar 19, 2021
1 parent 00c2542 commit 6364816
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 68 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/root.yml

This file was deleted.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
},
"autoload": {
"psr-4": {
"Runtime\\PsrNyholmLaminas\\": "src/psr-nyholm-laminas/src"
"Runtime\\PsrNyholmLaminas\\": "src/psr-nyholm-laminas/src",
"Runtime\\React\\": "src/react/src"
}
},
"minimum-stability": "dev",
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ parameters:

excludes_analyse:
- src/*/tests/*
- src/*/vendor/*
20 changes: 0 additions & 20 deletions phpunit.xml.dist

This file was deleted.

3 changes: 2 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<ignoreFiles allowMissingFiles="true">
<directory name="vendor" />
<directory name="src/*/tests" />
<directory name="src/*/runtime" />
<directory name="src/*/vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
7 changes: 6 additions & 1 deletion src/psr-nyholm-laminas/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
"autoload": {
"psr-4": {
"Runtime\\PsrNyholmLaminas\\": "src/",
"Symfony\\Runtime\\Psr\\": "runtime/"
"Symfony\\Runtime\\Psr\\Http\\": "runtime/"
}
},
"autoload-dev": {
"psr-4": {
"Runtime\\PsrNyholmLaminas\\Tests\\": "tests/"
}
},
"minimum-stability": "dev",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Runtime\Psr\Message;
namespace Symfony\Runtime\Psr\Http\Message;

use Runtime\PsrNyholmLaminas\Runtime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Runtime\Psr\Message;
namespace Symfony\Runtime\Psr\Http\Message;

use Runtime\PsrNyholmLaminas\Runtime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Runtime\Psr\Server;
namespace Symfony\Runtime\Psr\Http\Server;

use Runtime\PsrNyholmLaminas\Runtime;

Expand Down
17 changes: 13 additions & 4 deletions src/psr-nyholm-laminas/src/Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class Runtime extends GenericRuntime
*/
private $requestCreator;

private $options = [];

/**
* @param array{
* debug?: ?bool,
Expand All @@ -37,8 +35,6 @@ class Runtime extends GenericRuntime
*/
public function __construct(array $options = [])
{
$this->options = $options;

parent::__construct($options);
}

Expand Down Expand Up @@ -67,6 +63,19 @@ protected function getArgument(\ReflectionParameter $parameter, ?string $type)
return parent::getArgument($parameter, $type);
}

protected static function register(parent $runtime): parent
{
$self = new self($runtime->options + ['runtimes' => []]);
$self->options['runtimes'] += [
ServerRequestInterface::class => $self,
ResponseInterface::class => $self,
RequestHandlerInterface::class => $self,
];
$runtime->options = $self->options;

return $self;
}

/**
* @return ServerRequestInterface
*/
Expand Down
23 changes: 23 additions & 0 deletions src/psr-nyholm-laminas/tests/AutoDiscoverTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Runtime\PsrNyholmLaminas\Tests;

use PHPUnit\Framework\TestCase;
use Runtime\PsrNyholmLaminas\Runtime;

class AutoDiscoverTest extends TestCase
{
public function testAutoDiscoverClasses()
{
$classes = [
'Symfony\Runtime\Psr\Http\Message\ResponseInterfaceRuntime',
'Symfony\Runtime\Psr\Http\Message\ServerRequestInterfaceRuntime',
'Symfony\Runtime\Psr\Http\Server\RequestHandlerInterfaceRuntime',
];

foreach ($classes as $class) {
$this->assertTrue(class_exists($class));
$this->assertTrue(is_subclass_of($class, Runtime::class));
}
}
}
2 changes: 0 additions & 2 deletions src/psr-nyholm-laminas/tests/phpt/psr15.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;

$_SERVER['APP_RUNTIME'] = \Runtime\PsrNyholmLaminas\Runtime::class;

require __DIR__.'/autoload.php';

return function (array $context) {
Expand Down
2 changes: 0 additions & 2 deletions src/psr-nyholm-laminas/tests/phpt/psr7.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

use Psr\Http\Message\ServerRequestInterface;

$_SERVER['APP_RUNTIME'] = \Runtime\PsrNyholmLaminas\Runtime::class;

require __DIR__.'/autoload.php';

return function (ServerRequestInterface $request) {
Expand Down
7 changes: 6 additions & 1 deletion src/reactphp/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
"autoload": {
"psr-4": {
"Runtime\\React\\": "src/",
"Symfony\\Runtime\\Psr\\": "runtime/"
"Symfony\\Runtime\\Psr\\Http\\": "runtime/"
}
},
"autoload-dev": {
"psr-4": {
"Runtime\\React\\Tests\\": "tests/"
}
},
"minimum-stability": "dev",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symfony\Runtime\Psr\Server;
namespace Symfony\Runtime\Psr\Http\Server;

use Runtime\React\Runtime;

Expand Down
21 changes: 21 additions & 0 deletions src/reactphp/tests/AutoDiscoverTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Runtime\React\Tests;

use PHPUnit\Framework\TestCase;
use Runtime\React\Runtime;

class AutoDiscoverTest extends TestCase
{
public function testAutoDiscoverClasses()
{
$classes = [
'Symfony\Runtime\Psr\Http\Server\RequestHandlerInterfaceRuntime',
];

foreach ($classes as $class) {
$this->assertTrue(class_exists($class));
$this->assertTrue(is_subclass_of($class, Runtime::class));
}
}
}

0 comments on commit 6364816

Please sign in to comment.