Skip to content

Commit

Permalink
PHPStan level max
Browse files Browse the repository at this point in the history
  • Loading branch information
othillo committed Mar 30, 2020
1 parent 075a6d3 commit ba632bf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 2 additions & 4 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$app['debug'] = getenv('TOGGLE__DEBUG');
$app['redis_dsn'] = getenv('TOGGLE__REDIS_DSN');
$app['toggle.manager.prefix'] = getenv('TOGGLE__PREFIX');
$app['allowed_origins'] = json_decode(getenv('TOGGLE__ALLOWED_ORIGINS'));
$app['allowed_origins'] = getenv('TOGGLE__ALLOWED_ORIGINS') ? json_decode((string) getenv('TOGGLE__ALLOWED_ORIGINS'), true) : [];

if (JSON_ERROR_NONE !== json_last_error()) {
throw new RuntimeException('Failed to json_decode TOGGLE__ALLOWED_ORIGINS');
Expand Down Expand Up @@ -79,9 +79,7 @@
});

$app['request_to_toggle'] = $app->protect(function (Request $request) use ($app) {
$serialized = $request->getContent();

$data = json_decode($serialized, true);
$data = json_decode((string) $request->getContent(), true);

if (JSON_ERROR_NONE != json_last_error()) {
return null;
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
],
"require": {
"php": ">=7.2",
"ext-json": "*",
"silex/silex": "^1.0",
"qandidate/toggle": "^0.2@dev",
"predis/service-provider": "^0.4@dev",
Expand All @@ -32,7 +33,8 @@
"require-dev": {
"symfony/browser-kit": "^3.4||^4.0||^5.0",
"phpunit/phpunit": "~4.8",
"broadway/coding-standard": "^1.0"
"broadway/coding-standard": "^1.0",
"phpstan/phpstan": "@stable"
},
"prefer-stable": true,
"autoload-dev": {
Expand Down
14 changes: 7 additions & 7 deletions test/Qandidate/Application/Toggle/TogglesEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class TogglesEndpointTest extends WebTestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand All @@ -30,7 +30,7 @@ public function setUp()
/**
* @test
*/
public function it_exposes_all_toggle_names()
public function it_exposes_all_toggle_names(): void
{
$client = $this->createClient();
$crawler = $client->request('GET', '/toggles');
Expand Down Expand Up @@ -59,7 +59,7 @@ public function it_exposes_all_toggle_names()
/**
* @test
*/
public function it_can_delete_a_toggle()
public function it_can_delete_a_toggle(): void
{
$client = $this->createClient();
$crawler = $client->request('DELETE', '/toggles/toggling');
Expand All @@ -76,7 +76,7 @@ public function it_can_delete_a_toggle()
/**
* @test
*/
public function it_returns_400_on_deleting_non_existing_toggle()
public function it_returns_400_on_deleting_non_existing_toggle(): void
{
$client = $this->createClient();
$crawler = $client->request('DELETE', '/toggles/nothere');
Expand All @@ -87,7 +87,7 @@ public function it_returns_400_on_deleting_non_existing_toggle()
/**
* @test
*/
public function it_updates_a_toggle_on_put()
public function it_updates_a_toggle_on_put(): void
{
$toggleData = [
'name' => 'toggling',
Expand Down Expand Up @@ -122,7 +122,7 @@ public function it_updates_a_toggle_on_put()
/**
* @test
*/
public function it_does_not_accept_a_new_name_on_put()
public function it_does_not_accept_a_new_name_on_put(): void
{
$toggleData = ['name' => 'new-name', 'conditions' => []];
$toggle = json_encode($toggleData);
Expand All @@ -144,7 +144,7 @@ public function tearDown()
}
}

private function loadToggleFixtures(ToggleManager $manager)
private function loadToggleFixtures(ToggleManager $manager): void
{
// A toggle that will be active is the user id is less than 42
$operator = new LessThan(42);
Expand Down

0 comments on commit ba632bf

Please sign in to comment.