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

chore: add phpstan static analysis minimum #4511

Merged
merged 71 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
4cebc38
Add base phpstan
lancepioch Oct 31, 2022
af593c8
Prevent issues with "new static"
lancepioch Oct 31, 2022
8f38740
Add missing import
lancepioch Oct 31, 2022
88847b3
Variable might not have been defined
lancepioch Oct 31, 2022
ecb6c50
Be explicit
lancepioch Oct 31, 2022
c05dba8
Already imported
lancepioch Oct 31, 2022
4ecc046
Easier to read and handle missing allocations
lancepioch Oct 31, 2022
ca9ab84
Use aggregate functions
lancepioch Oct 31, 2022
2d63516
Mark this as never returns, we can use the never return type in php 8.1
lancepioch Oct 31, 2022
c4fbbf0
This is probably correct
lancepioch Oct 31, 2022
da94f0d
This is also probably more correctl
lancepioch Oct 31, 2022
502e00f
php-cs-fixer
lancepioch Oct 31, 2022
fbb0d56
Increase memory
lancepioch Oct 31, 2022
ce0c497
Just run it normally please
lancepioch Oct 31, 2022
de67bc0
Simplify
lancepioch Oct 31, 2022
6239ef2
Ignore these as they're going to be replaced
lancepioch Nov 1, 2022
70dd61e
Replace this with an attribute... but is this even used anymore?
lancepioch Nov 1, 2022
8ce9e2c
This has to be a User model or it will fail
lancepioch Nov 1, 2022
07a005e
These will always be Nest instances
lancepioch Nov 1, 2022
0ab367c
Remove wildcard
lancepioch Nov 1, 2022
38a84f6
Be specific
lancepioch Nov 1, 2022
7bcdd68
Wrap this up in a neat method
lancepioch Nov 1, 2022
6d89219
This would be a good usage of an interface or abstract class
lancepioch Nov 1, 2022
40ab159
Use method to populate node with aggregate counts
lancepioch Nov 1, 2022
d87ab25
Replace these
lancepioch Nov 1, 2022
3baa452
This isn't used anywhere
lancepioch Nov 1, 2022
dccf52d
Not worth it
lancepioch Nov 1, 2022
be8845c
Be specific
lancepioch Nov 1, 2022
6c5d04f
Help analyzer out
lancepioch Nov 1, 2022
a678010
Simplify
lancepioch Nov 1, 2022
32daaa8
Use agg method
lancepioch Nov 1, 2022
ddc1d13
Be specific
lancepioch Nov 1, 2022
14aa1c5
Ignore the rest of these, they're getting removed
lancepioch Nov 1, 2022
bba2877
Use same name
lancepioch Nov 1, 2022
3a6856a
Simplify
lancepioch Nov 1, 2022
f36f9d4
This will fail either way
lancepioch Nov 1, 2022
7722e3e
Var doesn't exist
lancepioch Nov 1, 2022
7edf9ce
Specify types
lancepioch Nov 1, 2022
f8efbef
Add doc blocks
lancepioch Nov 1, 2022
d4656d8
php-cs-fixer
lancepioch Nov 1, 2022
7353bd4
Up the level!
lancepioch Nov 1, 2022
4341237
Return type is never used
lancepioch Nov 1, 2022
dcabf5c
Use view helper instead
lancepioch Nov 1, 2022
4efd72c
Get the actual array
lancepioch Nov 1, 2022
b65604a
Switch these over
lancepioch Nov 1, 2022
f13bdb1
Simplify
lancepioch Nov 1, 2022
14f59bf
Reset this back, it'd be much easier to do this one if it weren't a p…
lancepioch Nov 1, 2022
1cec6d9
Give up
lancepioch Nov 1, 2022
79887c2
Up it again!
lancepioch Nov 1, 2022
7c4f006
Better readability
lancepioch Nov 1, 2022
9ac2fae
Typing
lancepioch Nov 1, 2022
d6e20ef
Order of operations
lancepioch Nov 1, 2022
6f89c1e
Impossible for this to be null, isset is called in the library method
lancepioch Nov 1, 2022
85cb724
Ignoring our problems until they go away!
lancepioch Nov 1, 2022
e12af38
Remove unused repositories
lancepioch Nov 1, 2022
2d21a2f
No need to cast this
lancepioch Nov 1, 2022
0bb3e0a
Technically more correct
lancepioch Nov 1, 2022
e13dc99
php-cs-fixer
lancepioch Nov 1, 2022
2569c2a
Higher we go
lancepioch Nov 1, 2022
cd09164
Separate this out
lancepioch Nov 1, 2022
fa3e998
Put this back
lancepioch Nov 1, 2022
31b9ff8
Merge branch 'develop' into analysis
lancepioch Nov 28, 2022
44cf57d
Remove unnecessary service
lancepioch Nov 28, 2022
a98a761
php-cs-fixer
lancepioch Nov 28, 2022
6e6fea7
Remove cache
lancepioch Nov 28, 2022
532db10
This no longer exists
lancepioch Nov 28, 2022
18601cc
Remove extra space
lancepioch Nov 28, 2022
bd3bd76
Add some env vars in
lancepioch Nov 28, 2022
ea075bd
Add s'more
lancepioch Nov 28, 2022
9d125d5
Merge branch 'develop' into analysis
matthewpi Nov 28, 2022
bdfcff5
ci: organize workflows
matthewpi Nov 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Docker Image
name: Docker

on:
push:
Expand All @@ -8,16 +8,16 @@ on:

jobs:
push:
name: Push Image to GitHub Packages
name: Push
runs-on: ubuntu-20.04
# Always run against a tag, even if the commit into the tag has [docker skip]
# within the commit message.
if: "!contains(github.ref, 'develop') || (!contains(github.event.head_commit.message, 'skip docker') && !contains(github.event.head_commit.message, 'docker skip'))"
steps:
- name: Code Checkout
- name: Code checkout
uses: actions/checkout@v3

- name: Docker Metadata
- name: Docker metadata
uses: docker/metadata-action@v4
id: docker_meta
with:
Expand All @@ -26,10 +26,10 @@ jobs:
- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker Buildx
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

- name: Docker Login
- name: Docker login
uses: docker/login-action@v2
with:
registry: ghcr.io
Expand Down
96 changes: 69 additions & 27 deletions .github/workflows/ci.yaml → .github/workflows/laravel.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: Laravel

on:
push:
Expand All @@ -11,8 +11,58 @@ on:
- "1.0-develop"

jobs:
analysis:
name: Static Analysis
runs-on: ubuntu-20.04
env:
APP_ENV: testing
APP_DEBUG: "true"
APP_KEY: SomeRandomString3232RandomString
CACHE_DRIVER: array
MAIL_MAILER: array
SESSION_DRIVER: array
QUEUE_CONNECTION: sync
steps:
- name: Code checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: bcmath, cli, curl, gd, mbstring, mysql, openssl, pdo, tokenizer, xml, zip
tools: composer:v2
coverage: none

- name: Install dependencies
run: composer install --no-interaction --no-progress --no-suggest --prefer-dist

- name: Analyze
run: vendor/bin/phpstan analyse

lint:
name: Lint
runs-on: ubuntu-20.04
steps:
- name: Code checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: bcmath, curl, gd, mbstring, mysql, openssl, pdo, tokenizer, xml, zip
tools: composer:v2
coverage: none

- name: Install dependencies
run: composer install --no-interaction --no-progress --no-suggest --prefer-dist

- name: PHP CS Fixer
run: vendor/bin/php-cs-fixer fix --dry-run --diff

mysql:
name: MySQL
name: Tests (MySQL)
runs-on: ubuntu-20.04
strategy:
fail-fast: false
Expand All @@ -36,20 +86,17 @@ jobs:
APP_TIMEZONE: UTC
APP_URL: http://localhost/
APP_ENVIRONMENT_ONLY: "true"

DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_DATABASE: testing
DB_USERNAME: root

CACHE_DRIVER: array
MAIL_MAILER: array
SESSION_DRIVER: array
QUEUE_CONNECTION: sync

HASHIDS_SALT: test123
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_DATABASE: testing
DB_USERNAME: root
steps:
- name: Code Checkout
- name: Code checkout
uses: actions/checkout@v3

- name: Get cache directory
Expand Down Expand Up @@ -78,7 +125,6 @@ jobs:

- name: Unit tests
run: vendor/bin/phpunit --bootstrap vendor/autoload.php tests/Unit
if: ${{ always() }}
env:
DB_HOST: UNIT_NO_DB

Expand All @@ -88,7 +134,7 @@ jobs:
DB_PORT: ${{ job.services.database.ports[3306] }}

postgres:
name: PostgreSQL
name: Tests (PostgreSQL)
runs-on: ubuntu-20.04
if: "!contains(github.event.head_commit.message, 'skip ci') && !contains(github.event.head_commit.message, 'ci skip')"
strategy:
Expand All @@ -114,35 +160,32 @@ jobs:
APP_TIMEZONE: UTC
APP_URL: http://localhost/
APP_ENVIRONMENT_ONLY: "true"

DB_CONNECTION: pgsql
DB_HOST: 127.0.0.1
DB_DATABASE: testing
DB_USERNAME: postgres
DB_PASSWORD: postgres

CACHE_DRIVER: array
MAIL_MAILER: array
SESSION_DRIVER: array
QUEUE_CONNECTION: sync

HASHIDS_SALT: test123
DB_CONNECTION: pgsql
DB_HOST: 127.0.0.1
DB_DATABASE: testing
DB_USERNAME: postgres
DB_PASSWORD: postgres
steps:
- name: Code Checkout
- name: Code checkout
uses: actions/checkout@v3

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

- name: Cache
uses: actions/cache@v3
with:
path: |
~/.php_cs.cache
${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-cache-${{ matrix.php }}-${{ hashFiles('**.composer.lock') }}
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.php }}-

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -157,7 +200,6 @@ jobs:

- name: Unit tests
run: vendor/bin/phpunit --bootstrap vendor/autoload.php tests/Unit
if: ${{ always() }}
env:
DB_HOST: UNIT_NO_DB

Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/lint.yaml

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ jobs:
name: Release
runs-on: ubuntu-20.04
steps:
- name: Code Checkout
- name: Code checkout
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: "yarn"
node-version: 18
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn build:production
run: yarn build

- name: Create release branch and bump version
env:
Expand All @@ -41,7 +41,7 @@ jobs:

- name: Create release archive
run: |
rm -rf node_modules/ test/ codecov.yml CODE_OF_CONDUCT.md CONTRIBUTING.md phpunit.xml Vagrantfile
rm -rf node_modules/ tests/ CODE_OF_CONDUCT.md CONTRIBUTING.md phpstan.neon phpunit.xml
tar -czf panel.tar.gz * .env.example .eslintignore .eslintrc.js

- name: Extract changelog
Expand All @@ -58,7 +58,7 @@ jobs:
echo -e "\n#### SHA256 Checksum\n\n\`\`\`\n$SUM\n\`\`\`\n" >> ./RELEASE_CHANGELOG
echo $SUM > checksum.txt

- name: Create Release
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
Expand Down
35 changes: 27 additions & 8 deletions .github/workflows/ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,47 @@ on:
- "1.0-develop"

jobs:
build-and-test:
name: Build and Test
lint:
name: Lint
runs-on: ubuntu-20.04
steps:
- name: Code checkout
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Lint
run: yarn run lint

tests:
name: Tests
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
node-version: [16, 18]
node: [16, 18]
steps:
- name: Code Checkout
- name: Code checkout
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
node-version: ${{ matrix.node }}
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn build
run: yarn run build

- name: Tests
run: yarn test
run: yarn run test
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;

class Handler extends ExceptionHandler
final class Handler extends ExceptionHandler
{
/**
* The validation parser in Laravel formats custom rules using the class name
Expand Down
8 changes: 3 additions & 5 deletions app/Http/Controllers/Admin/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Illuminate\Http\RedirectResponse;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Services\Acl\Api\AdminAcl;
use Illuminate\View\Factory as ViewFactory;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Api\KeyCreationService;
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
Expand All @@ -23,8 +22,7 @@ class ApiController extends Controller
public function __construct(
private AlertsMessageBag $alert,
private ApiKeyRepositoryInterface $repository,
private KeyCreationService $keyCreationService,
private ViewFactory $view,
private KeyCreationService $keyCreationService
) {
}

Expand All @@ -33,7 +31,7 @@ public function __construct(
*/
public function index(Request $request): View
{
return $this->view->make('admin.api.index', [
return view('admin.api.index', [
'keys' => $this->repository->getApplicationKeys($request->user()),
]);
}
Expand All @@ -48,7 +46,7 @@ public function create(): View
$resources = AdminAcl::getResourceList();
sort($resources);

return $this->view->make('admin.api.new', [
return view('admin.api.new', [
'resources' => $resources,
'permissions' => [
'r' => AdminAcl::READ,
Expand Down
Loading