Skip to content

Commit

Permalink
PHPStan 2.0 (#269)
Browse files Browse the repository at this point in the history
* Rename to phpstan.dist.neon

* PHPStan 2.0
And update to PHP 8.1+

* Update CI

* Minor analyseAndScan
  • Loading branch information
Alkarex authored Jan 12, 2025
1 parent fecfe37 commit 15d66ca
Show file tree
Hide file tree
Showing 15 changed files with 356 additions and 346 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ indent_style = tab
indent_size = 4
indent_style = tab

[*.neon]
indent_style = tab

[*.xml]
indent_style = tab

Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

tests:
# https://github.com/actions/virtual-environments
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
defaults:
run:
working-directory: ./Extensions
Expand Down Expand Up @@ -54,16 +54,13 @@ jobs:
- name: PHPStan
run: composer run-script phpstan

- name: PHPStan Next Level
run: composer run-script phpstan-next

# NPM tests

- name: Uses Node.js
uses: actions/setup-node@v3
with:
# https://nodejs.org/en/about/releases/
node-version: '18'
node-version: '22'
cache: 'npm'
cache-dependency-path: 'Extensions/package-lock.json'

Expand Down
18 changes: 8 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"WebSub"
],
"require": {
"php": ">=7.4",
"php": ">=8.1",
"ext-ctype": "*",
"ext-curl": "*",
"ext-dom": "*",
Expand Down Expand Up @@ -45,28 +45,26 @@
"ext-pdo_pgsql": "*"
},
"require-dev": {
"php": ">=7.4",
"php": ">=8.1",
"ext-phar": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-strict-rules": "^1.6",
"squizlabs/php_codesniffer": "^3.9"
"phpstan/phpstan": "^2",
"phpstan/phpstan-strict-rules": "^2",
"squizlabs/php_codesniffer": "^3"
},
"scripts": {
"php-lint": "find . -type d -name 'vendor' -prune -o -name '*.php' -print0 | xargs -0 -n1 -P4 php -l 1>/dev/null",
"phtml-lint": "find . -type d -name 'vendor' -prune -o -name '*.phtml' -print0 | xargs -0 -n1 -P4 php -l 1>/dev/null",
"phpcs": "phpcs . -s",
"phpcbf": "phpcbf . -p -s",
"phpstan": "phpstan analyse --memory-limit 512M .",
"phpstan-next": "phpstan analyse --memory-limit 512M -c phpstan-next.neon .",
"phpstan-third-party": "phpstan analyse --memory-limit 512M -c phpstan-third-party.neon .",
"phpstan": "phpstan analyse .",
"phpstan-third-party": "phpstan analyse -c phpstan-third-party.neon .",
"test": [
"@php-lint",
"@phtml-lint",
"@phpcs",
"@phpstan",
"@phpstan-next"
"@phpstan"
],
"fix": [
"@phpcbf"
Expand Down
51 changes: 25 additions & 26 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}

foreach ($repositories as $repository) {
if (null === $url = ($repository['url'] ?? null)) {
if (!is_array($repository) || !is_string($url = ($repository['url'] ?? null))) {
continue;
}
if (TYPE_GIT === ($repository['type'] ?? null)) {
Expand All @@ -54,7 +54,7 @@
}
$directory = basename(dirname($metadataFile));
$metadata['url'] = $gitRepository;
$metadata['version'] = strval($metadata['version']);
$metadata['version'] = is_scalar($metadata['version'] ?? null) ? strval($metadata['version']) : '';
$metadata['method'] = TYPE_GIT;
$metadata['directory'] = ($directory === sha1($gitRepository)) ? '.' : $directory;
$extensions[] = $metadata;
Expand Down
9 changes: 0 additions & 9 deletions phpstan-next.neon

This file was deleted.

17 changes: 10 additions & 7 deletions phpstan-third-party.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
parameters:
level: 0
phpVersion:
min: 80100 # PHP 8.1
max: 80499 # PHP 8.4
level: 0 # https://phpstan.org/user-guide/rule-levels
fileExtensions:
- php
- phtml
Expand All @@ -9,13 +12,13 @@ parameters:
excludePaths:
analyse:
- ../FreshRSS
- third-party/*/vendor/*
- third-party/*/vendor/*?
analyseAndScan:
- .git/
- node_modules/
- symbolic/
- third-party/*/tests/*
- tmp/
- .git/*?
- node_modules/*?
- symbolic/*?
- third-party/*/tests/*?
- tmp/*?
- vendor/
- xExtension-*
dynamicConstantNames:
Expand Down
43 changes: 43 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
parameters:
phpVersion:
min: 80100 # PHP 8.1
max: 80499 # PHP 8.4
level: 10 # https://phpstan.org/user-guide/rule-levels
fileExtensions:
- php
- phtml
paths:
- ../FreshRSS
- .
excludePaths:
analyse:
- ../FreshRSS
- xExtension-ImageProxy/configure.phtml # TODO pass
- xExtension-ImageProxy/extension.php # TODO pass
analyseAndScan:
- .git/*?
- node_modules/*?
- symbolic/*?
- third-party/*?
- tmp/*?
- vendor/
dynamicConstantNames:
- TYPE_GIT
checkBenevolentUnionTypes: true
checkMissingOverrideMethodAttribute: true
checkTooWideReturnTypesInProtectedAndPublicMethods: true
reportAnyTypeWideningInVarTag: true
treatPhpDocTypesAsCertain: false
strictRules:
disallowedEmpty: false
disallowedLooseComparison: false
disallowedShortTernary: false
exceptions:
check:
missingCheckedExceptionInThrows: true
tooWideThrowType: true
implicitThrows: false
checkedExceptionClasses:
- 'Minz_Exception'
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
48 changes: 0 additions & 48 deletions phpstan.neon

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

final class FreshExtension_quickCollapse_Controller extends Minz_ActionController {

/** @var QuickCollapse\View */
/**
* @var QuickCollapse\View
* @phpstan-ignore property.phpDocType
*/
protected $view;

public function __construct() {
Expand Down
Loading

0 comments on commit 15d66ca

Please sign in to comment.