Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel Linter #2230

Open
wants to merge 1 commit into
base: 2214-php-laravel-upgrade
Choose a base branch
from
Open

Laravel Linter #2230

wants to merge 1 commit into from

Conversation

Wotuu
Copy link
Contributor

@Wotuu Wotuu commented Feb 27, 2024

This pull request includes changes and recommendations for crafting your application "The Laravel Way". Feel free to commit any additional changes to the shift-110970 branch.

Before merging, you need to:

  • Checkout the shift-110970 branch
  • Review all pull request comments for additional changes
  • Thoroughly test your application (no tests?, no CI?)

Much of the lint detected may be automatically fixed by running the Laravel Fixer or tasks within the Shift Workbench.

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

⚠️ Shift found uses of the old array() syntax. Laravel adopted the short array syntax [] since it became available in PHP 5.4.

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

❌ The following configuration files differ from the Laravel defaults. If you are modifying configuration values directly, consider using an environment variable instead to keep these files maintainable. You should compare your configuration files against the latest version and merge any updates.

  • config/app.php
  • config/auth.php
  • config/cache.php
  • config/database.php
  • config/filesystems.php
  • config/logging.php
  • config/mail.php
  • config/queue.php
  • config/services.php
  • config/view.php

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

⚠️ The dates property was deprecated in Laravel 8.0 and removed in Laravel 10. Instead, you should use the casts property with a datetime type. Shift found the dates property in the following files:

  • app/Models/Expansion.php

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

ℹ️ Starting with Laravel 8, the model property within factories may be removed when your models are stored within a conventional location such as app/Models. Unless your factory is for a model outside of this location, you may remove this property.

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

⚠️ The following files reference Laravel facades through the global namespace. For example, you're referencing \DB or importing use DB. Instead import Illuminate\Support\Facades\DB and reference DB.

While global references are allowed through aliases, you should import the facade explicitly. This can improve clarity not only for developers, but static analysis used by your IDE.

  • app/Console/Commands/Scheduler/Telemetry/Measurement/MySqlStats.php
  • app/Http/Controllers/AdminToolsController.php
  • app/Http/Controllers/Ajax/AjaxEnemyController.php
  • app/Http/Controllers/Ajax/AjaxEnemyPackController.php
  • app/Http/Controllers/Ajax/AjaxMappingModelBaseController.php
  • app/Http/Controllers/Ajax/AjaxMountableAreaController.php
  • app/Http/Controllers/Ajax/AjaxUserController.php
  • app/Http/Controllers/Ajax/Floor/AjaxFloorUnionAreaController.php
  • app/Http/Controllers/Ajax/Floor/AjaxFloorUnionController.php
  • app/Http/Controllers/Api/V1/APIDungeonController.php
  • app/Http/Controllers/Api/V1/APIDungeonRouteController.php
  • app/Http/Controllers/Auth/OAuthLoginController.php
  • app/Http/Controllers/Auth/RegisterController.php
  • app/Http/Controllers/Dungeon/MappingVersionController.php
  • app/Http/Controllers/DungeonController.php
  • app/Http/Controllers/DungeonRouteController.php
  • app/Http/Controllers/ExpansionController.php
  • app/Http/Controllers/Floor/FloorController.php
  • app/Http/Controllers/GameVersionController.php
  • app/Http/Controllers/LiveSessionController.php
  • app/Http/Controllers/NpcController.php
  • app/Http/Controllers/NpcEnemyForcesController.php
  • app/Http/Controllers/PatreonController.php
  • app/Http/Controllers/ProfileController.php
  • app/Http/Controllers/ReleaseController.php
  • app/Http/Controllers/Speedrun/DungeonSpeedrunRequiredNpcsController.php
  • app/Http/Controllers/SpellController.php
  • app/Http/Controllers/TeamController.php
  • app/Http/Controllers/UserController.php
  • app/Http/Middleware/DebugInfoContextLogger.php
  • app/Http/Requests/DungeonFormRequest.php
  • app/Http/Requests/ExpansionFormRequest.php
  • app/Http/Requests/Floor/FloorFormRequest.php
  • app/Http/Requests/Npc/NpcEnemyForcesFormRequest.php
  • app/Http/Requests/NpcFormRequest.php
  • app/Http/Requests/ProfileFormRequest.php
  • app/Http/Requests/ReleaseFormRequest.php
  • app/Http/Requests/Speedrun/DungeonSpeedrunRequiredNpcsFormRequest.php
  • app/Http/Requests/SpellFormRequest.php
  • app/Http/Requests/Tag/APITagFormRequest.php
  • app/Http/Requests/Tag/APITagUpdateFormRequest.php
  • app/Http/Requests/TeamFormRequest.php
  • app/Http/Requests/User/UserFormRequest.php
  • app/Http/Requests/UserReportFormRequest.php
  • app/Jobs/RefreshDiscoverCache.php
  • app/Logic/Scheduler/ChecksForDuplicateJobs.php
  • app/Models/SimulationCraft/SimulationCraftRaidEventsOptions.php
  • app/Service/CombatLog/Builders/CreateRouteBodyDungeonRouteBuilder.php
  • app/Service/CombatLog/Builders/DungeonRouteBuilder.php
  • app/Service/CombatLog/Builders/ResultEventDungeonRouteBuilder.php
  • app/Service/CombatLog/CombatLogService.php
  • app/Service/EchoServer/EchoServerHttpApiService.php
  • app/Service/Metric/MetricService.php
  • database/seeders/MappingVersionSeeder.php

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

⚠️ The following classes do not extend the standard Laravel Model and Controller class. This may add complexity which makes your application harder to upgrade. Often a trait may be used instead of inheritance. You should review the following classes:

  • app/Models/Affix.php
  • app/Models/AffixGroup/AffixGroup.php
  • app/Models/AffixGroup/AffixGroupBase.php
  • app/Models/AffixGroup/AffixGroupCoupling.php
  • app/Models/AffixGroup/AffixGroupEaseTier.php
  • app/Models/AffixGroup/AffixGroupEaseTierPull.php
  • app/Models/CharacterClass.php
  • app/Models/CharacterClassSpecialization.php
  • app/Models/CharacterRace.php
  • app/Models/CharacterRaceClassCoupling.php
  • app/Models/Dungeon.php
  • app/Models/DungeonFloorSwitchMarker.php
  • app/Models/Enemy.php
  • app/Models/EnemyActiveAura.php
  • app/Models/EnemyPack.php
  • app/Models/EnemyPatrol.php
  • app/Models/Expansion.php
  • app/Models/Faction.php
  • app/Models/Floor/Floor.php
  • app/Models/Floor/FloorCoupling.php
  • app/Models/Floor/FloorUnion.php
  • app/Models/Floor/FloorUnionArea.php
  • app/Models/GameServerRegion.php
  • app/Models/GameVersion/GameVersion.php
  • app/Models/MapIconType.php
  • app/Models/Metrics/MetricAggregation.php
  • app/Models/MountableArea.php
  • app/Models/Npc.php
  • app/Models/Npc/NpcEnemyForces.php
  • app/Models/NpcBolsteringWhitelist.php
  • app/Models/NpcClass.php
  • app/Models/NpcClassification.php
  • app/Models/NpcSpell.php
  • app/Models/NpcType.php
  • app/Models/PublishedState.php
  • app/Models/RaidMarker.php
  • app/Models/Release.php
  • app/Models/ReleaseChangelog.php
  • app/Models/ReleaseChangelogCategory.php
  • app/Models/ReleaseChangelogChange.php
  • app/Models/ReleaseReportLog.php
  • app/Models/Season.php
  • app/Models/SeasonDungeon.php
  • app/Models/Speedrun/DungeonSpeedrunRequiredNpc.php
  • app/Models/Spell.php
  • app/Models/Timewalking/TimewalkingEvent.php

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

⚠️ Shift detected Eloquent calls in the following views. You should keep views from interacting directly with your models by passing the necessary data from the controller.

  • resources/views/admin/dungeon/edit.blade.php
  • resources/views/common/maps/map.blade.php
  • resources/views/misc/health.blade.php
  • resources/views/profile/edittabs/patreon.blade.php

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

⚠️ The following classes do not contain any public methods. These may be better served as a helper or service rather than a controller:

  • app/Http/Controllers/Ajax/AjaxMappingModelBaseController.php
  • app/Http/Controllers/Api/OpenApiSpec.php
  • app/Http/Controllers/Auth/DiscordLoginController.php
  • app/Http/Controllers/Auth/GoogleLoginController.php

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

⚠️ The following controllers contain actions outside of the 7 resource actions (index, create, store, show, edit, update, destroy). For more details, review the docs or watch Cruddy by Design to see if you may rework these into resource controllers.

  • app/Http/Controllers/AdminToolsController.php
  • app/Http/Controllers/Ajax/AjaxBrushlineController.php
  • app/Http/Controllers/Ajax/AjaxDungeonFloorSwitchMarkerController.php
  • app/Http/Controllers/Ajax/AjaxDungeonRouteController.php
  • app/Http/Controllers/Ajax/AjaxEchoController.php
  • app/Http/Controllers/Ajax/AjaxEnemyController.php
  • app/Http/Controllers/Ajax/AjaxEnemyPackController.php
  • app/Http/Controllers/Ajax/AjaxEnemyPatrolController.php
  • app/Http/Controllers/Ajax/AjaxKillZoneController.php
  • app/Http/Controllers/Ajax/AjaxLiveSessionController.php
  • app/Http/Controllers/Ajax/AjaxMapIconController.php
  • app/Http/Controllers/Ajax/AjaxMetricController.php
  • app/Http/Controllers/Ajax/AjaxMountableAreaController.php
  • app/Http/Controllers/Ajax/AjaxNpcController.php
  • app/Http/Controllers/Ajax/AjaxOverpulledEnemyController.php
  • app/Http/Controllers/Ajax/AjaxPathController.php
  • app/Http/Controllers/Ajax/AjaxPridefulEnemyController.php
  • app/Http/Controllers/Ajax/AjaxProfileController.php
  • app/Http/Controllers/Ajax/AjaxSiteController.php
  • app/Http/Controllers/Ajax/AjaxTagController.php
  • app/Http/Controllers/Ajax/AjaxTeamController.php
  • app/Http/Controllers/Ajax/AjaxUserController.php
  • app/Http/Controllers/Ajax/AjaxUserReportController.php
  • app/Http/Controllers/Ajax/Floor/AjaxFloorUnionAreaController.php
  • app/Http/Controllers/Ajax/Floor/AjaxFloorUnionController.php
  • app/Http/Controllers/Api/V1/APICombatLogController.php
  • app/Http/Controllers/Api/V1/APIDungeonController.php
  • app/Http/Controllers/Api/V1/APIDungeonRouteController.php
  • app/Http/Controllers/Api/V1/APIDungeonRouteThumbnailJobController.php
  • app/Http/Controllers/Auth/BattleNetLoginController.php
  • app/Http/Controllers/Auth/OAuthLoginController.php
  • app/Http/Controllers/Dungeon/DungeonExploreController.php
  • app/Http/Controllers/Dungeon/MappingVersionController.php
  • app/Http/Controllers/DungeonController.php
  • app/Http/Controllers/DungeonRouteController.php
  • app/Http/Controllers/DungeonRouteDiscoverController.php
  • app/Http/Controllers/DungeonRouteLegacyController.php
  • app/Http/Controllers/ExpansionController.php
  • app/Http/Controllers/Floor/FloorController.php
  • app/Http/Controllers/LiveSessionController.php
  • app/Http/Controllers/LiveSessionLegacyController.php
  • app/Http/Controllers/MDTImportController.php
  • app/Http/Controllers/NpcController.php
  • app/Http/Controllers/PatreonController.php
  • app/Http/Controllers/ProfileController.php
  • app/Http/Controllers/ReleaseController.php
  • app/Http/Controllers/SiteController.php
  • app/Http/Controllers/Speedrun/DungeonSpeedrunRequiredNpcsController.php
  • app/Http/Controllers/SpellController.php
  • app/Http/Controllers/TeamController.php
  • app/Http/Controllers/UserController.php
  • app/Http/Controllers/UserReportController.php
  • app/Http/Controllers/WebhookController.php

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

⚠️ Shift detected the following HTTP components accessing the authenticated user through Auth::user(). Within these components, you may access the authenticated user through the request object as well. Doing so limits your dependencies by leveraging objects already available.

  • app/Http/Controllers/Ajax/AjaxBrushlineController.php
  • app/Http/Controllers/Ajax/AjaxDungeonRouteController.php
  • app/Http/Controllers/Ajax/AjaxKillZoneController.php
  • app/Http/Controllers/Ajax/AjaxLiveSessionController.php
  • app/Http/Controllers/Ajax/AjaxMapIconController.php
  • app/Http/Controllers/Ajax/AjaxNpcController.php
  • app/Http/Controllers/Ajax/AjaxPathController.php
  • app/Http/Controllers/Ajax/AjaxProfileController.php
  • app/Http/Controllers/Ajax/AjaxTeamController.php
  • app/Http/Controllers/Ajax/AjaxUserController.php
  • app/Http/Controllers/DungeonRouteController.php
  • app/Http/Controllers/GameVersionController.php
  • app/Http/Controllers/LiveSessionController.php
  • app/Http/Controllers/MDTImportController.php
  • app/Http/Controllers/NpcController.php
  • app/Http/Controllers/PatreonController.php
  • app/Http/Controllers/SiteController.php
  • app/Http/Controllers/TeamController.php
  • app/Http/Controllers/Traits/PublicKeyDungeonRoute.php
  • app/Http/Controllers/Traits/SavesPolylines.php
  • app/Http/Controllers/UserController.php
  • app/Http/Middleware/LegalAgreed.php

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

⚠️ Shift found opportunities to use the built-in Blade directives like @auth, @csrf in the following views:

  • resources/views/auth/passwords/email.blade.php
  • resources/views/auth/passwords/reset.blade.php
  • resources/views/common/dungeonroute/table.blade.php
  • resources/views/common/forms/createroute.blade.php
  • resources/views/common/forms/login.blade.php
  • resources/views/common/forms/register.blade.php
  • resources/views/common/general/sitescripts.blade.php
  • resources/views/common/layout/navuser.blade.php
  • resources/views/common/maps/map.blade.php
  • resources/views/common/modal/createroute.blade.php
  • resources/views/common/modal/simulateoptions/advanced.blade.php
  • resources/views/layouts/sitepage.blade.php
  • resources/views/vendor/language/flags.blade.php

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

ℹ️ Shift detected legacy model factories. Laravel 8 introduced class based model factories. You may automate the conversion to class based model factories using the Shift Workbench.

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

❌ Laravel 10 added PHP type hints to all user-land code included in a new Laravel application. Shift detected these files are missing type hints. Shift recommends adding them to align with the latest Laravel conventions. You may automate this process by running the Laravel Type Hints task within Shift Workbench.

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

⚠️ Laravel uses PSR-4 autoloading for the app/ folder. While you may configure your application to load these files within composer.json, all files under the app folder should be classes with a PSR-4 compliant namespace.

The following PHP files are missing a namespace:

  • app/Helpers/ColorHelper.php
  • app/Helpers/CustomHelper.php

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

⚠️ Laravel 8 began PSR-4 autoloading for factories and seeders. Shift detected the following files are missing a namespace:

  • database/factories/MappingVersion/MappingVersionFactory.php
  • database/factories/ModelFactory.php

@Wotuu
Copy link
Contributor Author

Wotuu commented Feb 27, 2024

ℹ️ As noted, much of the lint detected above can be automatically fixed using the Laravel Fixer. Save yourself time and clean up your codebase quickly with this new Shift.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants