Skip to content

Commit fd5bf69

Browse files
committed
Removed check for misconfigured Voter with constructor argument
This check was inconsequent (no other form of voter description had a similar check) and not very helpful (due to the general error message). For now, the removal simplifies the code. If necessary, one could add other checks and improve the error messages later on, if the instructions in the readme do not suffice.
1 parent f5b18ff commit fd5bf69

2 files changed

Lines changed: 2 additions & 17 deletions

File tree

NotModified/Annotation/ReplaceWithNotModifiedResponse.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @Annotation
2222
*/
23-
class ReplaceWithNotModifiedResponse
23+
final class ReplaceWithNotModifiedResponse
2424
{
2525
/** @var array */
2626
private $parameters;
@@ -74,7 +74,6 @@ private function initialiseVoters()
7474
throw new \RuntimeException('The annotation ' . get_class($this) . ' has to be parametrised with voters.');
7575
}
7676

77-
$runningIndex = 1;
7877
foreach ($this->parameters['voters'] as $voterDescription) {
7978
$voter = null;
8079

@@ -87,10 +86,6 @@ private function initialiseVoters()
8786
}
8887

8988
if (is_array($voterDescription)) {
90-
if (count($voterDescription) !== 1) {
91-
throw new \RuntimeException('Voter #' . $runningIndex . ' (starting with 1) is misconfigured.');
92-
}
93-
9489
$voterClass = key($voterDescription);
9590
$voterParameter = current($voterDescription);
9691
$voter = new $voterClass($voterParameter);

Tests/NotModified/Annotation/ReplaceWithNotModifiedResponseTest.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,7 @@ public function serviceNameAsVoterParameter()
7474
/**
7575
* @test
7676
*/
77-
public function invalidArrayAsVoterParameter()
78-
{
79-
$this->setExpectedException(\RuntimeException::class);
80-
$annotation = new ReplaceWithNotModifiedResponse(['voters' => [['invalid', 'array', 'structure']]]);
81-
$annotation->determineLastModified(new Request());
82-
}
83-
84-
/**
85-
* @test
86-
*/
87-
public function validArrayAsVoterParameterWithConstructorArguments()
77+
public function arrayAsVoterParameterWithConstructorArguments()
8878
{
8979
$this->setExpectedException(null);
9080
$annotation = new ReplaceWithNotModifiedResponse(['voters' => [[Voter::class => new \DateTime('2000-01-01')]]]);

0 commit comments

Comments
 (0)