Skip to content

Commit

Permalink
Fix code style and rules
Browse files Browse the repository at this point in the history
  • Loading branch information
pdavide committed Oct 24, 2023
1 parent e945e3f commit bf0663e
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 66 deletions.
3 changes: 2 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
'phpdoc_align' => ['align' => 'left'],
'phpdoc_no_empty_return' => false,
'phpdoc_order' => true,
'global_namespace_import' => ['import_classes' => true]
'global_namespace_import' => ['import_classes' => true],
'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true]
];

$finder = Finder::create()
Expand Down
2 changes: 1 addition & 1 deletion app/Contracts/AnalyticsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function getUsersLogin(): array;
*
* @return RedirectResponse the Analytics service dashboard
*/
public function loginAndRedirectUser(string $userLogin, string $hashedPassword, string $idSite = null): RedirectResponse;
public function loginAndRedirectUser(string $userLogin, string $hashedPassword, ?string $idSite = null): RedirectResponse;

/**
* Set permissions for a specified user and specified websites
Expand Down
6 changes: 3 additions & 3 deletions app/Extensions/AppUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class AppUserProvider extends EloquentUserProvider
*/
public function retrieveByCredentials(array $credentials): ?Authenticatable
{
if (empty($credentials) ||
(1 === count($credentials) &&
array_key_exists('password', $credentials))) {
if (empty($credentials)
|| (1 === count($credentials)
&& array_key_exists('password', $credentials))) {
return null;
}
// First we will add each credential element to the query as a where clause.
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/AnalyticsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AnalyticsController extends Controller
*
* @return \Illuminate\View\View|\Illuminate\Http\RedirectResponse
*/
public function index(Request $request, PublicAdministration $publicAdministration = null)
public function index(Request $request, ?PublicAdministration $publicAdministration = null)
{
$user = $request->user();

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/AnalyticsServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AnalyticsServiceController extends Controller
*
* @return RedirectResponse the server redirect response
*/
public function login(string $websiteAnalyticsId = null): RedirectResponse
public function login(?string $websiteAnalyticsId = null): RedirectResponse
{
$user = auth()->user();
if (!$user->hasAnalyticsServiceAccount()) {
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/UserEmailNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class UserEmailNotification extends EmailNotification
* @param PublicAdministration $publicAdministration the public administration
* @param string $recipientEmail the email address to use for thins notification
*/
public function __construct(PublicAdministration $publicAdministration = null, string $recipientEmail = null)
public function __construct(?PublicAdministration $publicAdministration = null, ?string $recipientEmail = null)
{
$this->publicAdministration = $publicAdministration;
$this->recipientEmail = $recipientEmail;
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/UserPublicAdministrationChangedEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class UserPublicAdministrationChangedEmail extends UserEmailNotification
* @param string $recipientEmail the email address to use for thins notification
* @param string $updatedEmail the updated email address
*/
public function __construct(PublicAdministration $publicAdministration = null, string $recipientEmail = null, string $updatedEmail)
public function __construct(?PublicAdministration $publicAdministration = null, ?string $recipientEmail = null, string $updatedEmail)
{
parent::__construct($publicAdministration, $recipientEmail);
$this->updatedEmail = $updatedEmail;
Expand Down
2 changes: 1 addition & 1 deletion app/Services/MatomoService.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public function getUsersLogin(): array
*
* @return RedirectResponse the Analytics service dashboard
*/
public function loginAndRedirectUser(string $userLogin, string $hashedPassword, string $idSite = null): RedirectResponse
public function loginAndRedirectUser(string $userLogin, string $hashedPassword, ?string $idSite = null): RedirectResponse
{
return redirect($this->servicePublicUrl . '/index.php?module=Login&action=logme&login=' . $userLogin . '&password=' . $hashedPassword . '&idSite=' . $idSite);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Services/SingleDigitalGatewayService.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function validatePayload($dataset): void
*
* @throws SDGServiceException
*/
protected function apiCall(string $path, string $method = 'GET', array $params = [], array $body = null)
protected function apiCall(string $path, string $method = 'GET', array $params = [], ?array $body = null)
{
$apiLogger = Log::channel('sdg_api');
$stack = HandlerStack::create();
Expand Down
108 changes: 54 additions & 54 deletions tests/Feature/ArchiveWebsiteJsonRoutesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,33 +203,33 @@ public function testArchiveWebsiteFailedWrongStatusRoute(): void
Event::assertNotDispatched(WebsiteUnarchived::class);
}

// to be uncommented after the resolution of https://github.com/matomo-org/matomo/issues/8697
// /**
// * Test website archive failed due to error in Analytics Service call.
// */
// public function testArchiveWebsiteFailedRoute(): void
// {
// $website = factory(Website::class)->create([
// 'public_administration_id' => $this->publicAdministration->id,
// 'type' => WebsiteType::INFORMATIONAL,
// 'status' => WebsiteStatus::ACTIVE,
// ]);
//
// $response = $this->actingAs($this->user)
// ->withSession([
// 'spid_sessionId' => 'fake-session-index',
// 'tenant_id' => $this->publicAdministration->id,
// ])
// ->json('patch', route('websites.archive', ['website' => $website->slug]));
//
// $response->assertJson([
// 'result' => 'error',
// 'message' => 'Bad Request',
// ]);
//
// Event::assertNotDispatched(WebsiteArchived::class);
// Event::assertNotDispatched(WebsiteUnarchived::class);
// }
// to be uncommented after the resolution of https://github.com/matomo-org/matomo/issues/8697
// /**
// * Test website archive failed due to error in Analytics Service call.
// */
// public function testArchiveWebsiteFailedRoute(): void
// {
// $website = factory(Website::class)->create([
// 'public_administration_id' => $this->publicAdministration->id,
// 'type' => WebsiteType::INFORMATIONAL,
// 'status' => WebsiteStatus::ACTIVE,
// ]);
//
// $response = $this->actingAs($this->user)
// ->withSession([
// 'spid_sessionId' => 'fake-session-index',
// 'tenant_id' => $this->publicAdministration->id,
// ])
// ->json('patch', route('websites.archive', ['website' => $website->slug]));
//
// $response->assertJson([
// 'result' => 'error',
// 'message' => 'Bad Request',
// ]);
//
// Event::assertNotDispatched(WebsiteArchived::class);
// Event::assertNotDispatched(WebsiteUnarchived::class);
// }

/**
* Test website re-enable status not modified response.
Expand Down Expand Up @@ -336,31 +336,31 @@ public function testUnarchiveWebsiteFailedWrongStatusRoute(): void
Event::assertNotDispatched(WebsiteUnarchived::class);
}

// to be uncommented after the resolution of https://github.com/matomo-org/matomo/issues/8697
// /**
// * Test website archive failed due to error in Analytics Service call.
// */
// public function testUnarchiveWebsiteFailedRoute(): void
// {
// $website = factory(Website::class)->create([
// 'public_administration_id' => $this->publicAdministration->id,
// 'status' => WebsiteStatus::ARCHIVED,
// 'type' => WebsiteType::INFORMATIONAL,
// ]);
//
// $response = $this->actingAs($this->user)
// ->withSession([
// 'spid_sessionId' => 'fake-session-index',
// 'tenant_id' => $this->publicAdministration->id,
// ])
// ->json('patch', route('websites.unarchive', ['website' => $website->slug]));
//
// $response->assertJson([
// 'result' => 'error',
// 'message' => 'Bad Request',
// ]);
//
// Event::assertNotDispatched(WebsiteArchived::class);
// Event::assertNotDispatched(WebsiteUnarchived::class);
// }
// to be uncommented after the resolution of https://github.com/matomo-org/matomo/issues/8697
// /**
// * Test website archive failed due to error in Analytics Service call.
// */
// public function testUnarchiveWebsiteFailedRoute(): void
// {
// $website = factory(Website::class)->create([
// 'public_administration_id' => $this->publicAdministration->id,
// 'status' => WebsiteStatus::ARCHIVED,
// 'type' => WebsiteType::INFORMATIONAL,
// ]);
//
// $response = $this->actingAs($this->user)
// ->withSession([
// 'spid_sessionId' => 'fake-session-index',
// 'tenant_id' => $this->publicAdministration->id,
// ])
// ->json('patch', route('websites.unarchive', ['website' => $website->slug]));
//
// $response->assertJson([
// 'result' => 'error',
// 'message' => 'Bad Request',
// ]);
//
// Event::assertNotDispatched(WebsiteArchived::class);
// Event::assertNotDispatched(WebsiteUnarchived::class);
// }
}
2 changes: 1 addition & 1 deletion tests/SqliteForeignKeyHotfix.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function getSchemaBuilder()
}

return new class($this) extends SQLiteBuilder {
protected function createBlueprint($table, Closure $callback = null)
protected function createBlueprint($table, ?Closure $callback = null)
{
return new class($table, $callback) extends Blueprint {
public function dropForeign($index)
Expand Down

0 comments on commit bf0663e

Please sign in to comment.