Skip to content

Commit

Permalink
Update Laravel 8
Browse files Browse the repository at this point in the history
Summary:
Update to Laravel 8

Ref T1725

Reviewers: dereckson

Reviewed By: dereckson

Subscribers: dereckson

Tags: #user-dorianwinty

Maniphest Tasks: T1725

Differential Revision: https://devcentral.nasqueron.org/D2674
  • Loading branch information
DorianVL committed May 21, 2022
1 parent 6f15d83 commit 327396a
Show file tree
Hide file tree
Showing 114 changed files with 347 additions and 485 deletions.
8 changes: 6 additions & 2 deletions .arclint
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@
"phpcs": {
"type": "phpcs",
"bin": "vendor/bin/phpcs",
"phpcs.standard": "PSR1",
"include": "(^app/.*\\.php$)"
"phpcs.standard": "phpcs.xml",
"include": [
"(app/.*\\.php$)",
"(config/.*\\.php$)",
"(tests/.*\\.php$)"
]
},
"spelling": {
"type": "spelling"
Expand Down
9 changes: 4 additions & 5 deletions app/Analyzers/BasePayloadAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

namespace Nasqueron\Notifications\Analyzers;

use Config;
use Storage;

use BadMethodCallException;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Storage;

abstract class BasePayloadAnalyzer {

Expand Down Expand Up @@ -36,7 +35,7 @@ abstract class BasePayloadAnalyzer {

/**
* The configuration for the payload analyzer
* @var PayloadAnalyzerConfiguration;
* @var PayloadAnalyzerConfiguration
*/
protected $configuration;

Expand Down Expand Up @@ -80,7 +79,7 @@ public function getConfigurationFileName () : string {

$filename = $dir . '/' . $this->project . '.json';

if (!Storage::has($filename)) {
if (!Storage::exists($filename)) {
return $dir . '/' . static::CONFIG_DEFAULT_FILE;
}

Expand Down
2 changes: 1 addition & 1 deletion app/Analyzers/DockerHub/BuildFailureEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Nasqueron\Notifications\Analyzers\DockerHub;

use Mailgun;
use Nasqueron\Notifications\Facades\Mailgun;

class BuildFailureEvent extends BaseEvent {

Expand Down
20 changes: 14 additions & 6 deletions app/Analyzers/GitHub/Events/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ public function __construct ($payload) {
* @param string $eventName The event name (e.g. commit_comment)
* @return string The event class name (e.g. CommitCommentEvent)
*/
public static function getClass ($eventName) {
return __NAMESPACE__ . '\\' . studly_case($eventName) . 'Event';
public static function getClass (string $eventName) {
return __NAMESPACE__ . '\\' . self::toCamelCase($eventName) . 'Event';
}

private static function toCamelCase (string $string) : string {
return str_replace(" ", "", ucwords(str_replace("_", " ", $string)));
}

/**
Expand All @@ -43,7 +47,7 @@ public static function getClass ($eventName) {
* @param string $eventName The event name (e.g. commit_comment)
* @return Event
*/
public static function forPayload ($eventName, $payload) {
public static function forPayload (string $eventName, $payload) {
$class = self::getClass($eventName);
if (!class_exists($class)) {
throw new \InvalidArgumentException(
Expand All @@ -60,11 +64,15 @@ public static function forPayload ($eventName, $payload) {
/**
* Cuts a text
*
* @param string $text The text to cut
* @param int $strLen The amount of characters to allow [optional]
* @param string $text The text to cut
* @param int $strLen The amount of characters to allow [optional]
* @param string $symbol The symbol to append to a cut text [optional]
*/
public static function cut ($text, $strLen = 114, $symbol = '') {
public static function cut (
string $text,
int $strLen = 114,
string $symbol = ''
) {
$len = strlen($text);
if ($len <= $strLen) {
return $text;
Expand Down
3 changes: 1 addition & 2 deletions app/Analyzers/GitHub/Events/IssueCommentEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class IssueCommentEvent extends Event {
* @param string $action The action to check
* @return bool true if the action is valid; otherwise, false
*/
protected static function isValidAction ($action) {
protected static function isValidAction (string $action) {
$actions = ['created', 'edited', 'deleted'];
return in_array($action, $actions);
}
Expand Down Expand Up @@ -62,4 +62,3 @@ public function getLink () : string {
}

}

2 changes: 1 addition & 1 deletion app/Analyzers/GitHub/Events/PullRequestEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PullRequestEvent extends Event {
* @param string $action The action to check
* @return bool true if the action is valid; otherwise, false
*/
protected static function isValidAction ($action) {
protected static function isValidAction(string $action) {
$actions = [
'assigned', 'unassigned',
'labeled', 'unlabeled',
Expand Down
2 changes: 1 addition & 1 deletion app/Analyzers/GitHub/Events/PushEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PushEvent extends Event {
* @param int $count The count of commits
* @return string The l10n message key for description
*/
private static function getDescriptionMessageKey ($count) {
private static function getDescriptionMessageKey (int $count) {
$key = 'GitHub.EventsDescriptions.PushEvent';

if ($count === 0) {
Expand Down
4 changes: 2 additions & 2 deletions app/Analyzers/GitHub/Events/WithRef.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trait WithRef {
* @param string $type The ref type to check
* @return bool true if the ref type id valid; otherwise, false
*/
protected static function isValidRefType ($type) {
protected static function isValidRefType (string $type) {
$types = ['branch', 'tag'];
return in_array($type, $types);
}
Expand All @@ -30,7 +30,7 @@ protected static function isValidRefType ($type) {
* @param string $type The reference type
* @return string the part of the URL for this reference type (e.g. /tree/)
*/
protected function getLinkRefSegment ($type) {
protected function getLinkRefSegment (string $type) {
$segments = $this->getLinkRefSegments();

if (!array_key_exists($type, $segments)) {
Expand Down
2 changes: 1 addition & 1 deletion app/Analyzers/GitHub/Events/WithRepoAndBranch.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function getRepositoryAndBranch (
return "";
}

if (starts_with($branch, "refs/heads/")) {
if (str_starts_with($branch, "refs/heads/")) {
$branch = substr($branch, 11);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Analyzers/GitHub/GitHubPayloadAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class GitHubPayloadAnalyzer extends BasePayloadAnalyzer {
/**
* The payload analyzer event
*
* @var \Nasqueron\Notifications\Analyzers\GitHub\Events\Event;
* @var \Nasqueron\Notifications\Analyzers\GitHub\Events\Event
*/
private $analyzerEvent;

Expand Down
4 changes: 3 additions & 1 deletion app/Analyzers/ItemGroupMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Nasqueron\Notifications\Analyzers;

use Illuminate\Support\Str;

/**
* Map items (repositories, projects, items, etc.) names to groups
*/
Expand Down Expand Up @@ -42,7 +44,7 @@ public static function doesItemMatch (
string $pattern,
string $item
) : bool {
return str_is($pattern, $item);
return Str::is($pattern, $item);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getItemName () : string {
/**
* Tries to get build status.
*
* @param out string $status
* @param out string &$status
* @return bool indicates if the build status is defined in the payload
*/
private function tryGetBuildStatus (string &$status) : bool {
Expand Down
2 changes: 1 addition & 1 deletion app/Config/Features.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Nasqueron\Notifications\Config;

use Config;
use Illuminate\Support\Facades\Config;

/**
* The features class offers a sugar syntax to check if a feature is enabled
Expand Down
4 changes: 2 additions & 2 deletions app/Config/Reporting/ConfigReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Nasqueron\Notifications\Config\Features;

use Config;
use Services;
use Nasqueron\Notifications\Facades\Services;
use Illuminate\Support\Facades\Config;

class ConfigReport {

Expand Down
2 changes: 1 addition & 1 deletion app/Config/Reporting/ServiceReportEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Nasqueron\Notifications\Config\Services\Service;

use ProjectsMap;
use Nasqueron\Notifications\Facades\ProjectsMap;

final class ServiceReportEntry extends BaseReportEntry {

Expand Down
2 changes: 1 addition & 1 deletion app/Config/Services/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Nasqueron\Notifications\Config\Services;

use Storage;
use Illuminate\Support\Facades\Storage;

class Services {

Expand Down
3 changes: 1 addition & 2 deletions app/Console/Commands/ConfigValidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

use Illuminate\Console\Command;
use Illuminate\Filesystem\FilesystemAdapter;

use App;
use Illuminate\Support\Facades\App;

class ConfigValidate extends Command {

Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/PhabricatorProjectsMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Illuminate\Console\Command;

use ProjectsMap;
use Services;
use Nasqueron\Notifications\Facades\ProjectsMap;
use Nasqueron\Notifications\Facades\Services;

class PhabricatorProjectsMap extends Command {
/**
Expand Down
4 changes: 2 additions & 2 deletions app/Contracts/APIClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface APIClient {
* @param string $url The API end point URL
* @return void
*/
public function setEndPoint ($url);
public function setEndPoint (string $url);

/**
* Calls an API method
Expand All @@ -19,6 +19,6 @@ public function setEndPoint ($url);
* @param array $arguments The arguments to use
* @return mixed The API result
*/
public function call ($method, $arguments = []);
public function call (string $method, array $arguments = []);

}
2 changes: 1 addition & 1 deletion app/Contracts/APIFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ interface APIFactory {
* @param string $endPoint The API end point
* @return APIClient
*/
public function get ($endPoint);
public function get (string $endPoint);

}
1 change: 0 additions & 1 deletion app/Events/DockerHubPayloadEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Nasqueron\Notifications\Events;

use Nasqueron\Notifications\Events\Event;
use Illuminate\Queue\SerializesModels;

class DockerHubPayloadEvent extends Event {
Expand Down
1 change: 0 additions & 1 deletion app/Events/GitHubPayloadEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Nasqueron\Notifications\Events;

use Nasqueron\Notifications\Events\Event;
use Illuminate\Queue\SerializesModels;

class GitHubPayloadEvent extends Event {
Expand Down
1 change: 0 additions & 1 deletion app/Events/JenkinsPayloadEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Nasqueron\Notifications\Events;

use Nasqueron\Notifications\Events\Event;
use Illuminate\Queue\SerializesModels;

class JenkinsPayloadEvent extends Event {
Expand Down
1 change: 0 additions & 1 deletion app/Events/NotificationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Nasqueron\Notifications\Events;

use Nasqueron\Notifications\Events\Event;
use Nasqueron\Notifications\Notifications\Notification;

use Illuminate\Queue\SerializesModels;
Expand Down
2 changes: 1 addition & 1 deletion app/Events/PhabricatorPayloadEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Nasqueron\Notifications\Events;

use Nasqueron\Notifications\Events\Event;
use Nasqueron\Notifications\Phabricator\PhabricatorStory;

use Illuminate\Queue\SerializesModels;

class PhabricatorPayloadEvent extends Event {
Expand Down
2 changes: 1 addition & 1 deletion app/Events/ReportEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Nasqueron\Notifications\Events;

use Nasqueron\Notifications\Actions\Action;
use Nasqueron\Notifications\Events\Event;

use Illuminate\Queue\SerializesModels;

class ReportEvent extends Event {
Expand Down
15 changes: 8 additions & 7 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@

namespace Nasqueron\Notifications\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Nasqueron\Notifications\Facades\Raven;

use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Validation\ValidationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Validation\ValidationException;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Support\Facades\Config;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Exception\CommandNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;

use Config;
use Raven;

use Exception;

class Handler extends ExceptionHandler {
Expand All @@ -38,9 +37,11 @@ class Handler extends ExceptionHandler {
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @param \Exception|\Throwable $e
*
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function report(Exception $e) : void {
public function report(Exception|\Throwable $e) : void {
if (!$this->shouldReport($e)) {
return;
}
Expand Down
3 changes: 1 addition & 2 deletions app/Facades/Raven.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

namespace Nasqueron\Notifications\Facades;

use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Facade;

use Config;

/**
* @see \Raven_Client
*/
Expand Down
8 changes: 5 additions & 3 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace Nasqueron\Notifications\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Routing\Controller as BaseController;

abstract class Controller extends BaseController {

use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
use AuthorizesRequests;
use DispatchesJobs;
use ValidatesRequests;
}
Loading

0 comments on commit 327396a

Please sign in to comment.