Add Larastan configuration and dependencies for static analysis #9

Merged
jothi merged 8 commits from ranjith-dev into master 2025-11-26 09:11:37 +00:00
8 changed files with 267 additions and 32 deletions

View File

@@ -21,7 +21,7 @@ LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=sqlite
DB_CONNECTION=pgsql
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel

32
.github/workflows/larastan.yaml vendored Normal file
View File

@@ -0,0 +1,32 @@
# Filenme: .github/workflows/larastan.yaml
name: Laravel Larastan
on:
pull_request:
workflow_dispatch:
jobs:
larastan:
runs-on: ubuntu-latest
steps:
# Reinstall system libraries to ensure compatibility
- name: Ensure system libraries are up-to-date
run: |
sudo apt-get update
sudo apt-get install --reinstall --yes git libc6
- uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
- name: Install dependencies
run: composer install
# Run larastan code quality checks
- name: Run Larastan
run: vendor/bin/phpstan analyse --no-progress --memory-limit=2G

View File

@@ -22,10 +22,10 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
php-version: "8.4"
- name: Install dependencies
run: composer install --prefer-dist --no-interaction --quiet
run: composer install --prefer-dist --no-interaction
# Run pint in test mode, check only files different from master branch
- name: Run Laravel Pint in test mode

View File

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Models\Plant;
use App\Models\User;
//use Carbon\Carbon;
use Hash;
use Illuminate\Http\Request;
@@ -83,10 +84,11 @@ class UserController extends Controller
//$user = User::where('email', $email)->first();
if (Hash::check($header_pass, $existUser->password)) {
return response()->json([
'created_at' => $existUser->created_at->format('Y-m-d H:i:s'),
'updated_at' => $existUser->updated_at->format('Y-m-d H:i:s'),
'plant' => (String)$existPlant,
'email' => $existUser->email,
'created_at' => $existUser->created_at->format('Y-m-d H:i:s') ?? "",
'updated_at' => $existUser->updated_at->format('Y-m-d H:i:s') ?? "",
'requested_at' => now()->format('Y-m-d H:i:s') ?? "", //Carbon::now(config('app.timezone'))->format('Y-m-d H:i:s') ?? "",
'plant' => (String)$existPlant ?? "",
'email' => $existUser->email ?? "",
'roles' => $existUser->roles()->pluck('name')->toArray()
], 200);
} else {

View File

@@ -36,6 +36,7 @@
"barryvdh/laravel-ide-helper": "^3.5",
"beyondcode/laravel-dump-server": "^2.1",
"fakerphp/faker": "^1.23",
"larastan/larastan": "^3.0",
"laravel/pail": "^1.1",
"laravel/pint": "^1.13",
"laravel/sail": "^1.26",

186
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "2c6681f17532120adc216f4e70b8d18d",
"content-hash": "70aec54c03a23cfc92e7f22d912a2e21",
"packages": [
{
"name": "alperenersoy/filament-export",
@@ -10981,6 +10981,137 @@
},
"time": "2025-04-30T06:54:44+00:00"
},
{
"name": "iamcal/sql-parser",
"version": "v0.6",
"source": {
"type": "git",
"url": "https://github.com/iamcal/SQLParser.git",
"reference": "947083e2dca211a6f12fb1beb67a01e387de9b62"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/iamcal/SQLParser/zipball/947083e2dca211a6f12fb1beb67a01e387de9b62",
"reference": "947083e2dca211a6f12fb1beb67a01e387de9b62",
"shasum": ""
},
"require-dev": {
"php-coveralls/php-coveralls": "^1.0",
"phpunit/phpunit": "^5|^6|^7|^8|^9"
},
"type": "library",
"autoload": {
"psr-4": {
"iamcal\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Cal Henderson",
"email": "cal@iamcal.com"
}
],
"description": "MySQL schema parser",
"support": {
"issues": "https://github.com/iamcal/SQLParser/issues",
"source": "https://github.com/iamcal/SQLParser/tree/v0.6"
},
"time": "2025-03-17T16:59:46+00:00"
},
{
"name": "larastan/larastan",
"version": "v3.8.0",
"source": {
"type": "git",
"url": "https://github.com/larastan/larastan.git",
"reference": "d13ef96d652d1b2a8f34f1760ba6bf5b9c98112e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/larastan/larastan/zipball/d13ef96d652d1b2a8f34f1760ba6bf5b9c98112e",
"reference": "d13ef96d652d1b2a8f34f1760ba6bf5b9c98112e",
"shasum": ""
},
"require": {
"ext-json": "*",
"iamcal/sql-parser": "^0.6.0",
"illuminate/console": "^11.44.2 || ^12.4.1",
"illuminate/container": "^11.44.2 || ^12.4.1",
"illuminate/contracts": "^11.44.2 || ^12.4.1",
"illuminate/database": "^11.44.2 || ^12.4.1",
"illuminate/http": "^11.44.2 || ^12.4.1",
"illuminate/pipeline": "^11.44.2 || ^12.4.1",
"illuminate/support": "^11.44.2 || ^12.4.1",
"php": "^8.2",
"phpstan/phpstan": "^2.1.29"
},
"require-dev": {
"doctrine/coding-standard": "^13",
"laravel/framework": "^11.44.2 || ^12.7.2",
"mockery/mockery": "^1.6.12",
"nikic/php-parser": "^5.4",
"orchestra/canvas": "^v9.2.2 || ^10.0.1",
"orchestra/testbench-core": "^9.12.0 || ^10.1",
"phpstan/phpstan-deprecation-rules": "^2.0.1",
"phpunit/phpunit": "^10.5.35 || ^11.5.15"
},
"suggest": {
"orchestra/testbench": "Using Larastan for analysing a package needs Testbench",
"phpmyadmin/sql-parser": "Install to enable Larastan's optional phpMyAdmin-based SQL parser automatically"
},
"type": "phpstan-extension",
"extra": {
"phpstan": {
"includes": [
"extension.neon"
]
},
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"Larastan\\Larastan\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Can Vural",
"email": "can9119@gmail.com"
}
],
"description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel",
"keywords": [
"PHPStan",
"code analyse",
"code analysis",
"larastan",
"laravel",
"package",
"php",
"static analysis"
],
"support": {
"issues": "https://github.com/larastan/larastan/issues",
"source": "https://github.com/larastan/larastan/tree/v3.8.0"
},
"funding": [
{
"url": "https://github.com/canvural",
"type": "github"
}
],
"time": "2025-10-27T23:09:14+00:00"
},
{
"name": "laravel/pail",
"version": "v1.2.3",
@@ -11496,6 +11627,59 @@
},
"time": "2025-07-22T14:01:30+00:00"
},
{
"name": "phpstan/phpstan",
"version": "2.1.32",
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e126cad1e30a99b137b8ed75a85a676450ebb227",
"reference": "e126cad1e30a99b137b8ed75a85a676450ebb227",
"shasum": ""
},
"require": {
"php": "^7.4|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
},
"bin": [
"phpstan",
"phpstan.phar"
],
"type": "library",
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan - PHP Static Analysis Tool",
"keywords": [
"dev",
"static analysis"
],
"support": {
"docs": "https://phpstan.org/user-guide/getting-started",
"forum": "https://github.com/phpstan/phpstan/discussions",
"issues": "https://github.com/phpstan/phpstan/issues",
"security": "https://github.com/phpstan/phpstan/security/policy",
"source": "https://github.com/phpstan/phpstan-src"
},
"funding": [
{
"url": "https://github.com/ondrejmirtes",
"type": "github"
},
{
"url": "https://github.com/phpstan",
"type": "github"
}
],
"time": "2025-11-11T15:18:17+00:00"
},
{
"name": "phpunit/php-code-coverage",
"version": "11.0.11",

17
phpstan.neon Normal file
View File

@@ -0,0 +1,17 @@
includes:
- vendor/larastan/larastan/extension.neon
- vendor/nesbot/carbon/extension.neon
parameters:
paths:
- app/
# Level 10 is the highest level
level: 3
# ignoreErrors:
# - '#PHPDoc tag @var#'
#
# excludePaths:
# - ./*/*/FileToBeExcluded.php

View File

@@ -1,26 +1,26 @@
<?php
use App\Models\AlertMailRule;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Support\Facades\Schema;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');
// Schedule::command('send:invoice-report');
// Schedule::command('send:production-report');
// Schedule::command('send:production-report');
app()->booted(function () {
app()->booted(function () {
$schedule = app(Schedule::class);
//$schedule->command('report:send-daily-production')->dailyAt('07:59');
// $schedule->command('report:send-daily-production')->dailyAt('07:59');
//Production report scheduling
if (Schema::hasTable('alert_mail_rules')) {
// Production report scheduling
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
->where('rule_name', 'ProductionMail')
->select('plant', 'schedule_type')
@@ -31,8 +31,8 @@ Artisan::command('inspire', function () {
$type = $rule->schedule_type;
$plantId = $rule->plant;
$command = $schedule->command('send:production-report', [$type, $plantId])
->appendOutputTo(storage_path('logs/scheduler.log'));
$command = $schedule->command('send:production-report', [$type, $plantId]);
// ->appendOutputTo(storage_path('logs/scheduler.log'));
switch ($type) {
case 'Live':
@@ -47,7 +47,7 @@ Artisan::command('inspire', function () {
}
}
//Invoice report scheduling
// Invoice report scheduling
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
->select('plant', 'schedule_type')
->distinct()
@@ -72,7 +72,7 @@ Artisan::command('inspire', function () {
}
}
//Invoice Data report scheduling
// Invoice Data Report Scheduling
$invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport')
->select('plant', 'schedule_type')
->distinct()
@@ -96,6 +96,5 @@ Artisan::command('inspire', function () {
break;
}
}
});
}
});