Skip to content

Commit

Permalink
Mark controllers as "final" (#1587)
Browse files Browse the repository at this point in the history
Our controller inheritance hierarchy currently has two types of
controllers: "abstract" controllers which provide useful helper
functions, and "business" controllers which contain functions which are
called by Laravel's routing system. We should never inherit from a
"business" controller, since there should never be a need to inherit the
business logic contained within. At the same time, an easy mistake to
make is to inherit from `BuildController` rather than
`AbstractBuildController` for example. To help enforce this, we can mark
each "business" controller with the `final` keyword and use PHPStan to
ensure that no controllers inherit from a "business" controller.

Co-authored-by: Joseph Snyder <joe.snyder@kitware.com>
  • Loading branch information
williamjallen and josephsnyder authored Aug 2, 2023
1 parent 623c08d commit 412430c
Show file tree
Hide file tree
Showing 28 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require_once 'include/version.php';
require_once 'include/upgrade_functions.php';

class AdminController extends AbstractController
final class AdminController extends AbstractController
{
public function import(): View
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/AuthTokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Http\Request;

class AuthTokenController extends AbstractController
final class AuthTokenController extends AbstractController
{
public function manage(): View
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/BuildController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

require_once('include/repository.php');

class BuildController extends AbstractBuildController
final class BuildController extends AbstractBuildController
{
// Render the build configure page.
public function configure($build_id = null)
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/BuildPropertiesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

require_once 'include/filterdataFunctions.php';

class BuildPropertiesController extends AbstractBuildController
final class BuildPropertiesController extends AbstractBuildController
{
public function buildProperties(): View
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/CDash.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Class CDash
* @package App\Http\Controllers
*/
class CDash extends AbstractController
final class CDash extends AbstractController
{
/** @var Request $request */
private $request;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/CTestConfigurationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use CDash\Model\SubProject;
use Illuminate\Http\Response;

class CTestConfigurationController extends AbstractProjectController
final class CTestConfigurationController extends AbstractProjectController
{
public function get(int $id): Response
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/CoverageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

require_once 'include/filterdataFunctions.php';

class CoverageController extends AbstractBuildController
final class CoverageController extends AbstractBuildController
{
public function compareCoverage(): Response|RedirectResponse
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/EditProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Illuminate\Support\Facades\Gate;

class EditProjectController extends AbstractProjectController
final class EditProjectController extends AbstractProjectController
{
// Render the create project form.
public function create()
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Exception\HttpException;

class ImageController extends AbstractController
final class ImageController extends AbstractController
{
/**
* @throws HttpException
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Response;

class IndexController extends AbstractController
final class IndexController extends AbstractController
{
public function showIndexPage(): Response|RedirectResponse
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ManageBannerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Illuminate\Support\Facades\Gate;
use Illuminate\View\View;

class ManageBannerController extends AbstractController
final class ManageBannerController extends AbstractController
{
/**
* TODO: (williamjallen) this function contains legacy XSL templating and should be converted
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ManageMeasurementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Support\Facades\Gate;

class ManageMeasurementsController extends AbstractProjectController
final class ManageMeasurementsController extends AbstractProjectController
{
// Render the 'manage measurements' page.
public function show($project_id)
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ManageProjectRolesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Illuminate\View\View;
use RuntimeException;

class ManageProjectRolesController extends AbstractProjectController
final class ManageProjectRolesController extends AbstractProjectController
{
/**
* TODO: (williamjallen) this function contains legacy XSL templating and should be converted
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ManageUsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Support\Facades\DB;
use Illuminate\View\View;

class ManageUsersController extends AbstractController
final class ManageUsersController extends AbstractController
{
/**
* TODO: (williamjallen) this function contains legacy XSL templating and should be converted
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/MapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Http\RedirectResponse;
use Illuminate\View\View;

class MapController extends AbstractProjectController
final class MapController extends AbstractProjectController
{
public function viewMap(): View|RedirectResponse
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/MonitorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Illuminate\Support\Facades\DB;
use Illuminate\View\View;

class MonitorController extends AbstractController
final class MonitorController extends AbstractController
{
public function monitor(): View
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/OAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Class OAuthController
* @package App\Http\Controllers
*/
class OAuthController extends AbstractController
final class OAuthController extends AbstractController
{
/**
* @param Request $request
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;

class ProjectController extends AbstractProjectController
final class ProjectController extends AbstractProjectController
{
public function apiCreateProject(): JsonResponse
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Illuminate\Support\Facades\Gate;
use Illuminate\View\View;

class SiteController extends AbstractController
final class SiteController extends AbstractController
{
public function siteStatistics(): View|RedirectResponse
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/SubProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Illuminate\Http\Response;
use Illuminate\View\View;

class SubProjectController extends AbstractProjectController
final class SubProjectController extends AbstractProjectController
{
public function viewSubProjects(): Response
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/SubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Illuminate\Support\Str;
use Symfony\Component\HttpKernel\Exception\HttpException;

class SubmissionController extends AbstractProjectController
final class SubmissionController extends AbstractProjectController
{
public function submit(): Response|JsonResponse
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/SubscribeProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;

class SubscribeProjectController extends AbstractProjectController
final class SubscribeProjectController extends AbstractProjectController
{
/**
* TODO: (williamjallen) this function contains legacy XSL templating and should be converted
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

include_once 'include/repository.php';

class TestController extends AbstractProjectController
final class TestController extends AbstractProjectController
{
// Render the test details page.
public function details($buildtest_id = null)
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require_once 'include/cdashmail.php';

class UserController extends AbstractController
final class UserController extends AbstractController
{
public function userPage(): View
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/UserNoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;

class UserNoteController extends AbstractBuildController
final class UserNoteController extends AbstractBuildController
{
public function apiAddUserNote(): JsonResponse
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/UserStatisticsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use App\Services\PageTimer;
use Illuminate\Http\JsonResponse;

class UserStatisticsController extends AbstractProjectController
final class UserStatisticsController extends AbstractProjectController
{
public function api(): JsonResponse
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ViewProjectsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Support\Facades\DB;
use Illuminate\View\View;

class ViewProjectsController extends AbstractController
final class ViewProjectsController extends AbstractController
{
public function viewAllProjects(): View|RedirectResponse
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ViewTestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

require_once 'include/api_common.php';

class ViewTestController extends AbstractController
final class ViewTestController extends AbstractController
{
public function viewTest(): View
{
Expand Down

0 comments on commit 412430c

Please sign in to comment.