Skip to content

Commit

Permalink
Make PHPStan happy
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurk committed Oct 17, 2021
1 parent 7529048 commit 1d9a077
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
3 changes: 0 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ parameters:
paths:
- src
- tests/KdybyTests

ignoreErrors:
- '#Kdyby\\FakeSession\\Session::__construct\(\) does not call parent constructor from Nette\\Http\\Session#' # intended behavior
5 changes: 3 additions & 2 deletions src/DI/FakeSessionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use Kdyby;
use Kdyby\FakeSession\Session;
use Nette\DI\Definitions\ServiceDefinition;
use Nette\Http\Session as NetteSession;

class FakeSessionExtension extends \Nette\DI\CompilerExtension
Expand Down Expand Up @@ -42,8 +43,8 @@ public function beforeCompile(): void
$builder->addDefinition($this->prefix('original'), clone $original)
->setAutowired(FALSE);

$session = $builder->addDefinition($originalServiceName)
->setClass(NetteSession::class)
$session = $builder->addDefinition($originalServiceName, new ServiceDefinition())
->setType(NetteSession::class)
->setFactory(Session::class, [$this->prefix('@original')]);

if ($config['enabled']) {
Expand Down
9 changes: 9 additions & 0 deletions src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ public function setFakeId(string $id): void
$this->id = $id;
}


/**
* @param string $section
* @param string $class
* @return NetteSessionSection<mixed>
*/
public function getSection(string $section, string $class = NetteSessionSection::class): NetteSessionSection
{
if (!$this->fakeMode) {
Expand All @@ -168,6 +174,9 @@ public function hasSection(string $section): bool
return isset($this->sections[$section]);
}

/**
* @return Iterator<mixed>
*/
public function getIterator(): Iterator
{
if (!$this->fakeMode) {
Expand Down
4 changes: 4 additions & 0 deletions src/SessionSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public function __construct(NetteSession $session, string $name)
parent::__construct($session, $name);
}


/**
* @return Iterator<mixed>
*/
public function getIterator(): Iterator
{
return new ArrayIterator($this->data);
Expand Down

0 comments on commit 1d9a077

Please sign in to comment.