Skip to content

Commit

Permalink
Use ::class
Browse files Browse the repository at this point in the history
  • Loading branch information
enumag committed Feb 9, 2017
1 parent 2c31f48 commit dad60d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/DI/HttpExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

namespace Arachne\Codeception\DI;

use Arachne\Codeception\Http\Request;
use Arachne\Codeception\Http\Response;
use Nette\DI\CompilerExtension;
use Nette\Http\IRequest;
use Nette\Http\IResponse;

/**
* @author Jáchym Toušek <enumag@gmail.com>
Expand All @@ -15,18 +19,18 @@ public function beforeCompile()
{
$builder = $this->getContainerBuilder();

$request = $builder->getByType('Nette\Http\IRequest') ?: 'httpRequest';
$request = $builder->getByType(IRequest::class) ?: 'httpRequest';
if ($builder->hasDefinition($request)) {
$builder->getDefinition($request)
->setClass('Nette\Http\Request')
->setFactory('Arachne\Codeception\Http\Request');
->setClass(IRequest::class)
->setFactory(Request::class);
}

$response = $builder->getByType('Nette\Http\IResponse') ?: 'httpResponse';
$response = $builder->getByType(IResponse::class) ?: 'httpResponse';
if ($builder->hasDefinition($response)) {
$builder->getDefinition($response)
->setClass('Nette\Http\IResponse')
->setFactory('Arachne\Codeception\Http\Response');
->setClass(IResponse::class)
->setFactory(Response::class);
}
}
}
3 changes: 2 additions & 1 deletion src/Module/NetteDIModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Nette\Caching\Storages\SQLiteJournal;
use Nette\Configurator;
use Nette\DI\Container;
use Nette\DI\Extensions\ExtensionsExtension;
use Nette\DI\MissingServiceException;
use Nette\Http\Session;
use Nette\Utils\FileSystem;
Expand Down Expand Up @@ -120,7 +121,7 @@ private function createContainer(): void
$configurator = new Configurator();
if ($this->config['removeDefaultExtensions']) {
$configurator->defaultExtensions = [
'extensions' => 'Nette\DI\Extensions\ExtensionsExtension',
'extensions' => ExtensionsExtension::class,
];
}

Expand Down

0 comments on commit dad60d6

Please sign in to comment.