Skip to content

Commit

Permalink
phpstan v1 + workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
slawkens committed Jan 30, 2024
1 parent a2c8e2b commit c08f099
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 1 deletion.
47 changes: 47 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "PHPStan"

on:
pull_request:
branches: [develop]
push:
branches: [develop]

jobs:
tests:
name: PhpStan on PHP ${{ matrix.php-versions }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-versions: [ '8.1', '8.2', '8.3' ]
steps:
- name: "Checkout"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "intl, zip"
ini-values: "memory_limit=-1"
php-version: "${{ matrix.php-version }}"

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
#key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}

- name: "Install composer dependencies"
run: "composer install"

- name: "Run PHPStan"
run: "/usr/bin/php vendor/bin/phpstan analyse"
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
},
"require-dev": {
"filp/whoops": "^2.15",
"maximebf/debugbar": "dev-master"
"maximebf/debugbar": "dev-master",
"phpstan/phpstan": "^1.10"
},
"autoload": {
"psr-4": {
Expand Down
12 changes: 12 additions & 0 deletions phpstan-bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

require __DIR__ . '/system/libs/pot/OTS.php';
$ots = POT::getInstance();

require __DIR__ . '/system/libs/pot/InvitesDriver.php';
require __DIR__ . '/system/libs/rfc6238.php';

require __DIR__ . '/common.php';

const ACTION = '';
define('SELF_NAME', basename(__FILE__));
32 changes: 32 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
parameters:
level: 1
paths:
- .
- templates/tibiacom
- templates/kathrine
excludePaths:
- system/cache/*
- vendor/*
- plugins/*
- templates/*
- system/libs
bootstrapFiles:
- phpstan-bootstrap.php
ignoreErrors:
- '#Variable \$db might not be defined#'
- '#Variable \$twig might not be defined#'
- '#Variable \$hooks might not be defined#'
- '#Variable \$account_logged might not be defined#'
- '#Variable \$logged might not be defined#'
- '#Variable \$config might not be defined#'
- '#Variable \$action might not be defined#'
- '#Variable \$errors might not be defined#'
- '#Variable \$cache might not be defined#'
- '#Variable \$status might not be defined#'
- '#Variable \$player might not be defined#'
- '#Variable \$guild might not be defined#'
- '#Variable \$[a-zA-Z0-9\\_]+ might not be defined#'
# Eloquent models
- '#Call to an undefined static method [a-zA-Z0-9\\_]+::[a-zA-Z0-9\\_]+()#'
- '#Variable \$tmp in empty\(\) always exists and is always falsy#'

0 comments on commit c08f099

Please sign in to comment.