diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e1c9005e..b96384fb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,17 +6,21 @@ ], "service": "laravel.test", "workspaceFolder": "/var/www/html", - "settings": {}, - "extensions": [ - // "mikestead.dotenv", - // "amiralizadeh9480.laravel-extra-intellisense", - // "ryannaddy.laravel-artisan", - // "onecentlin.laravel5-snippets", - // "onecentlin.laravel-blade" - ], + "customizations": { + "vscode": { + "extensions": [ + // "mikestead.dotenv", + // "amiralizadeh9480.laravel-extra-intellisense", + // "ryannaddy.laravel-artisan", + // "onecentlin.laravel5-snippets", + // "onecentlin.laravel-blade" + ], + "settings": {} + } + }, "remoteUser": "sail", + "postCreateCommand": "chown -R 1000:1000 /var/www/html 2>/dev/null || true" // "forwardPorts": [], // "runServices": [], - // "postCreateCommand": "apt-get update && apt-get install -y curl", // "shutdownAction": "none", } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fbf79e50..940c76a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,12 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, fileinfo, mysql coverage: xdebug - tools: phpcs, phpcpd + + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + - name: Start mysql service run: sudo systemctl start mysql.service @@ -63,7 +68,7 @@ jobs: run: php artisan config:clear - name: Setup NPM - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} cache: "npm" @@ -85,12 +90,6 @@ jobs: DB_PORT: ${{ job.services.mysql.ports['3306'] }} # REDIS_PORT: ${{ job.services.redis.ports['6379'] }} - - name: PHP_CodeSniffer - run: phpcs --extensions=php app - - - name: Copy/Paste Detector - run: phpcpd app/ --min-lines=50 - test-php-postgresql: name: Test PHP ${{ matrix.php-versions }} (${{ matrix.stability }}) + Node ${{ matrix.node }} + ${{ matrix.os }} with PostgreSQL runs-on: ubuntu-latest @@ -136,7 +135,11 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, fileinfo, pgsql coverage: xdebug - tools: phpcs, phpcpd + + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - uses: ramsey/composer-install@v2 @@ -146,7 +149,7 @@ jobs: php artisan key:generate - name: Setup NPM - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} cache: "npm" @@ -170,9 +173,3 @@ jobs: env: DB_PORT: ${{ job.services.postgres.ports[5432] }} # REDIS_PORT: ${{ job.services.redis.ports['6379'] }} - - - name: PHP_CodeSniffer - run: phpcs --extensions=php app - - - name: Copy/Paste Detector - run: phpcpd app/ --min-lines=50 diff --git a/.github/workflows/code-analysis.yml b/.github/workflows/code-analysis.yml new file mode 100644 index 00000000..c840cff8 --- /dev/null +++ b/.github/workflows/code-analysis.yml @@ -0,0 +1,44 @@ +name: Code analysis + +on: + push: + paths: + - "**.php" +jobs: + phpcs: + name: PHP_CodeSniffer + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php + with: + php-version: "8.3" + extensions: mbstring, dom, fileinfo + tools: phpcs + + - uses: ramsey/composer-install@v2 + + - name: Run PHP_CodeSniffer + run: phpcs --extensions=php app + + phpstan: + name: PHPStan + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php + with: + php-version: "8.3" + extensions: mbstring, dom, fileinfo + tools: phpstan + + - uses: ramsey/composer-install@v2 + + - name: Run PHPStan + run: phpstan analyse diff --git a/.github/workflows/pint.yml b/.github/workflows/pint.yml index 5966844d..e0a3bbcc 100644 --- a/.github/workflows/pint.yml +++ b/.github/workflows/pint.yml @@ -6,7 +6,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: "laravel-pint" - uses: aglipanci/laravel-pint-action@2.3.0 + uses: aglipanci/laravel-pint-action@2.3.1 with: verboseMode: true testMode: true diff --git a/composer.json b/composer.json index 03eab373..bdd7ca70 100644 --- a/composer.json +++ b/composer.json @@ -34,11 +34,11 @@ "barryvdh/laravel-ide-helper": "^2.13", "beyondcode/laravel-query-detector": "^1.7", "fakerphp/faker": "^1.18", + "larastan/larastan": "^2.0", "laravel/pint": "^1.10", - "laravel/sail": "^1.13", + "laravel/sail": "^1.27", "mockery/mockery": "^1.5", "nunomaduro/collision": "^7.0", - "nunomaduro/larastan": "^2.0", "pestphp/pest": "^2.0", "pestphp/pest-plugin-laravel": "^2.0", "pestphp/pest-plugin-livewire": "^2.0", diff --git a/composer.lock b/composer.lock index 821e4bd6..8795b98d 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "7ca62ea1a40aee5b2d6115cc2e285848", + "content-hash": "97faa44b39abeeaf3d8510641b88c4ec", "packages": [ { "name": "aws/aws-crt-php", @@ -10290,6 +10290,107 @@ }, "time": "2020-07-09T08:09:16+00:00" }, + { + "name": "larastan/larastan", + "version": "v2.8.1", + "source": { + "type": "git", + "url": "https://github.com/larastan/larastan.git", + "reference": "b7cc6a29c457a7d4f3de90466392ae9ad3e17022" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/larastan/larastan/zipball/b7cc6a29c457a7d4f3de90466392ae9ad3e17022", + "reference": "b7cc6a29c457a7d4f3de90466392ae9ad3e17022", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/console": "^9.52.16 || ^10.28.0 || ^11.0", + "illuminate/container": "^9.52.16 || ^10.28.0 || ^11.0", + "illuminate/contracts": "^9.52.16 || ^10.28.0 || ^11.0", + "illuminate/database": "^9.52.16 || ^10.28.0 || ^11.0", + "illuminate/http": "^9.52.16 || ^10.28.0 || ^11.0", + "illuminate/pipeline": "^9.52.16 || ^10.28.0 || ^11.0", + "illuminate/support": "^9.52.16 || ^10.28.0 || ^11.0", + "php": "^8.0.2", + "phpmyadmin/sql-parser": "^5.8.2", + "phpstan/phpstan": "^1.10.50" + }, + "require-dev": { + "nikic/php-parser": "^4.17.1", + "orchestra/canvas": "^7.11.1 || ^8.11.0 || ^9.0.0", + "orchestra/testbench": "^7.33.0 || ^8.13.0 || ^9.0.0", + "phpunit/phpunit": "^9.6.13 || ^10.5" + }, + "suggest": { + "orchestra/testbench": "Using Larastan for analysing a package needs Testbench" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "Larastan\\Larastan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Can Vural", + "email": "can9119@gmail.com" + }, + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan wrapper 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/v2.8.1" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/canvural", + "type": "github" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://www.patreon.com/nunomaduro", + "type": "patreon" + } + ], + "time": "2024-01-08T09:11:17+00:00" + }, { "name": "laravel/pint", "version": "v1.13.10", @@ -10725,108 +10826,6 @@ ], "time": "2023-10-11T15:45:01+00:00" }, - { - "name": "nunomaduro/larastan", - "version": "v2.8.1", - "source": { - "type": "git", - "url": "https://github.com/larastan/larastan.git", - "reference": "b7cc6a29c457a7d4f3de90466392ae9ad3e17022" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/larastan/larastan/zipball/b7cc6a29c457a7d4f3de90466392ae9ad3e17022", - "reference": "b7cc6a29c457a7d4f3de90466392ae9ad3e17022", - "shasum": "" - }, - "require": { - "ext-json": "*", - "illuminate/console": "^9.52.16 || ^10.28.0 || ^11.0", - "illuminate/container": "^9.52.16 || ^10.28.0 || ^11.0", - "illuminate/contracts": "^9.52.16 || ^10.28.0 || ^11.0", - "illuminate/database": "^9.52.16 || ^10.28.0 || ^11.0", - "illuminate/http": "^9.52.16 || ^10.28.0 || ^11.0", - "illuminate/pipeline": "^9.52.16 || ^10.28.0 || ^11.0", - "illuminate/support": "^9.52.16 || ^10.28.0 || ^11.0", - "php": "^8.0.2", - "phpmyadmin/sql-parser": "^5.8.2", - "phpstan/phpstan": "^1.10.50" - }, - "require-dev": { - "nikic/php-parser": "^4.17.1", - "orchestra/canvas": "^7.11.1 || ^8.11.0 || ^9.0.0", - "orchestra/testbench": "^7.33.0 || ^8.13.0 || ^9.0.0", - "phpunit/phpunit": "^9.6.13 || ^10.5" - }, - "suggest": { - "orchestra/testbench": "Using Larastan for analysing a package needs Testbench" - }, - "type": "phpstan-extension", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - }, - "phpstan": { - "includes": [ - "extension.neon" - ] - } - }, - "autoload": { - "psr-4": { - "Larastan\\Larastan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Can Vural", - "email": "can9119@gmail.com" - }, - { - "name": "Nuno Maduro", - "email": "enunomaduro@gmail.com" - } - ], - "description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan wrapper 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/v2.8.1" - }, - "funding": [ - { - "url": "https://www.paypal.com/paypalme/enunomaduro", - "type": "custom" - }, - { - "url": "https://github.com/canvural", - "type": "github" - }, - { - "url": "https://github.com/nunomaduro", - "type": "github" - }, - { - "url": "https://www.patreon.com/nunomaduro", - "type": "patreon" - } - ], - "abandoned": "larastan/larastan", - "time": "2024-01-08T09:11:17+00:00" - }, { "name": "pestphp/pest", "version": "v2.33.4", @@ -13214,5 +13213,5 @@ "php": "^8.1" }, "platform-dev": [], - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/docker-compose.yml b/docker-compose.yml index 3a0a68fb..8b420371 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,71 +1,81 @@ -# For more information: https://laravel.com/docs/sail -version: '3' services: laravel.test: build: - context: ./vendor/laravel/sail/runtimes/8.1 + context: ./vendor/laravel/sail/runtimes/8.3 dockerfile: Dockerfile args: WWWGROUP: '${WWWGROUP}' - image: sail-8.1/app + image: sail-8.3/app extra_hosts: - 'host.docker.internal:host-gateway' ports: - '${APP_PORT:-80}:80' + - '${VITE_PORT:-5173}:${VITE_PORT:-5173}' environment: WWWUSER: '${WWWUSER}' LARAVEL_SAIL: 1 XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' + IGNITION_LOCAL_SITES_PATH: '${PWD}' volumes: - '.:/var/www/html' networks: - sail depends_on: - - mariadb + - mailpit - redis - mariadb: - image: 'mariadb:10' + - mariadb + mailpit: + image: 'axllent/mailpit:latest' ports: - - '${FORWARD_DB_PORT:-3306}:3306' - environment: - MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' - MYSQL_DATABASE: '${DB_DATABASE}' - MYSQL_USER: '${DB_USERNAME}' - MYSQL_PASSWORD: '${DB_PASSWORD}' - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' - volumes: - - 'sailmariadb:/var/lib/mysql' + - '${FORWARD_MAILPIT_PORT:-1025}:1025' + - '${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025' networks: - sail - healthcheck: - test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"] - retries: 3 - timeout: 5s redis: image: 'redis:alpine' ports: - '${FORWARD_REDIS_PORT:-6379}:6379' volumes: - - 'sailredis:/data' + - 'sail-redis:/data' networks: - sail healthcheck: - test: ["CMD", "redis-cli", "ping"] + test: + - CMD + - redis-cli + - ping retries: 3 timeout: 5s - mailhog: - image: 'mailhog/mailhog:latest' + mariadb: + image: 'mariadb:10' ports: - - '${FORWARD_MAILHOG_PORT:-1025}:1025' - - '${FORWARD_MAILHOG_DASHBOARD_PORT:-8025}:8025' + - '${FORWARD_DB_PORT:-3306}:3306' + environment: + MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' + MYSQL_ROOT_HOST: '%' + MYSQL_DATABASE: '${DB_DATABASE}' + MYSQL_USER: '${DB_USERNAME}' + MYSQL_PASSWORD: '${DB_PASSWORD}' + MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' + volumes: + - 'sail-mariadb:/var/lib/mysql' + - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh' networks: - sail + healthcheck: + test: + - CMD + - mysqladmin + - ping + - '-p${DB_PASSWORD}' + retries: 3 + timeout: 5s networks: sail: driver: bridge volumes: - sailmariadb: + sail-redis: driver: local - sailredis: + sail-mariadb: driver: local diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e0cb2b1a..1cc681a2 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -5,8 +5,57 @@ parameters: count: 1 path: app/Http/Controllers/OAuthController.php + - + message: "#^PHPDoc type array of property App\\\\Http\\\\Kernel\\:\\:\\$middleware is not covariant with PHPDoc type array\\ of overridden property Illuminate\\\\Foundation\\\\Http\\\\Kernel\\:\\:\\$middleware\\.$#" + count: 1 + path: app/Http/Kernel.php + + - + message: "#^PHPDoc type array of property App\\\\Http\\\\Kernel\\:\\:\\$middlewareGroups is not covariant with PHPDoc type array\\\\> of overridden property Illuminate\\\\Foundation\\\\Http\\\\Kernel\\:\\:\\$middlewareGroups\\.$#" + count: 1 + path: app/Http/Kernel.php + + - + message: "#^PHPDoc type array of property App\\\\Http\\\\Kernel\\:\\:\\$routeMiddleware is not covariant with PHPDoc type array\\ of overridden property Illuminate\\\\Foundation\\\\Http\\\\Kernel\\:\\:\\$routeMiddleware\\.$#" + count: 1 + path: app/Http/Kernel.php + + - + message: "#^PHPDoc type array of property App\\\\Http\\\\Middleware\\\\EncryptCookies\\:\\:\\$except is not covariant with PHPDoc type array\\ of overridden property Illuminate\\\\Cookie\\\\Middleware\\\\EncryptCookies\\:\\:\\$except\\.$#" + count: 1 + path: app/Http/Middleware/EncryptCookies.php + + - + message: "#^PHPDoc type array of property App\\\\Http\\\\Middleware\\\\TrimStrings\\:\\:\\$except is not covariant with PHPDoc type array\\ of overridden property Illuminate\\\\Foundation\\\\Http\\\\Middleware\\\\TrimStrings\\:\\:\\$except\\.$#" + count: 1 + path: app/Http/Middleware/TrimStrings.php + + - + message: "#^PHPDoc type array of property App\\\\Http\\\\Middleware\\\\TrustProxies\\:\\:\\$proxies is not covariant with PHPDoc type array\\\\|string\\|null of overridden property Illuminate\\\\Http\\\\Middleware\\\\TrustProxies\\:\\:\\$proxies\\.$#" + count: 1 + path: app/Http/Middleware/TrustProxies.php + + - + message: "#^PHPDoc type array of property App\\\\Http\\\\Middleware\\\\VerifyCsrfToken\\:\\:\\$except is not covariant with PHPDoc type array\\ of overridden property Illuminate\\\\Foundation\\\\Http\\\\Middleware\\\\VerifyCsrfToken\\:\\:\\$except\\.$#" + count: 1 + path: app/Http/Middleware/VerifyCsrfToken.php + - message: "#^Cannot access property \\$event on object\\|string\\.$#" count: 1 path: app/Http/Requests/Booking/UpdateBooking.php + - + message: "#^PHPDoc tag @return with type Illuminate\\\\Database\\\\Eloquent\\\\Model\\|null is incompatible with native type void\\.$#" + count: 1 + path: app/Imports/BookingsImport.php + + - + message: "#^Return type \\(void\\) of method App\\\\Imports\\\\BookingsImport\\:\\:model\\(\\) should be compatible with return type \\(array\\\\|Illuminate\\\\Database\\\\Eloquent\\\\Model\\|null\\) of method Maatwebsite\\\\Excel\\\\Concerns\\\\ToModel\\:\\:model\\(\\)$#" + count: 1 + path: app/Imports/BookingsImport.php + + - + message: "#^PHPDoc type array of property App\\\\Providers\\\\EventServiceProvider\\:\\:\\$listen is not covariant with PHPDoc type array\\\\> of overridden property Illuminate\\\\Foundation\\\\Support\\\\Providers\\\\EventServiceProvider\\:\\:\\$listen\\.$#" + count: 1 + path: app/Providers/EventServiceProvider.php diff --git a/phpstan.neon b/phpstan.neon index c7b904ca..27af532a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,11 +1,10 @@ includes: - - ./vendor/nunomaduro/larastan/extension.neon + - vendor/larastan/larastan/extension.neon - phpstan-baseline.neon parameters: - paths: - - app + - app/ # The level 9 is the highest level level: 5