Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions .github/workflows/test-phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ on:
- composer.json
- phpstan.dist.neon
- phpstan-baseline.php
- 'docs/**'
- 'admin/lint-docs-samples.php'
- 'admin/docs-phpstan-baseline.php'
- '.github/workflows/test-phpstan.yml'

push:
Expand All @@ -29,6 +32,9 @@ on:
- composer.json
- phpstan.dist.neon
- phpstan-baseline.php
- 'docs/**'
- 'admin/lint-docs-samples.php'
- 'admin/docs-phpstan-baseline.php'
- '.github/workflows/test-phpstan.yml'

concurrency:
Expand Down Expand Up @@ -89,3 +95,8 @@ jobs:

- name: Run static analysis
run: composer phpstan:check

- name: Check that the baseline of the user guide samples is up to date
run: |
composer phpstan:docs-baseline
git diff --exit-code admin/docs-phpstan-baseline.php
210 changes: 210 additions & 0 deletions admin/docs-phpstan-baseline.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
<?php

declare(strict_types=1);

/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

/**
* PHPStan exceptions for the PHP samples of the user guide.
*
* An entry is a page relative to the project root, for all of its samples, or `page:line`, for the sample
* whose opening ```php fence is on that line.
*
* - `ignoreErrors`: an error identifier, optionally narrowed by a `message` pattern, ignored in the samples of the
* listed `paths` or, without them, in all samples. This list is written by hand.
* - `baseline`: the samples that are skipped, for errors that PHPStan does not allow to be ignored, and the errors
* that are ignored in a sample. It is written by `php admin/lint-docs-samples.php --phpstan --generate-baseline`.
*
* @return array{
* ignoreErrors: list<array{identifier: string, message?: string, paths?: list<string>}>,
* baseline: array{
* excludePaths: list<string>,
* ignoreErrors: list<array{identifier: string, paths: list<string>}>
* }
* }
*/
return [
'ignoreErrors' => [
// Samples are fragments: they leave out code, and the classes and functions that they refer to.
['identifier' => 'class.notFound'],
['identifier' => 'codeigniter.configArgumentInstanceof'],
['identifier' => 'codeigniter.configArgumentType'],
['identifier' => 'codeigniter.modelArgumentType'],
['identifier' => 'codeigniter.unknownServiceMethod'],
['identifier' => 'expr.resultUnused'],
['identifier' => 'function.notFound'],
['identifier' => 'method.unused'],
['identifier' => 'variable.undefined'],

// A class that a sample declares, and that several samples declare differently, is resolved to one of them.
[
'identifier' => 'method.notFound',
'message' => '#^Call to an undefined method (App\\\\|Tests\\\\|SampleCommand::|MyRules::|MyTestClass::)#',
],
[
'identifier' => 'property.notFound',
'message' => '#^Access to an undefined property (App\\\\|Config\\\\|SampleCommand::)#',
],
],

// Everything below is @autogenerated by --generate-baseline.
'baseline' => [
'excludePaths' => [
'docs/cli/cli_signals.md:201',
'docs/cli/cli_signals.md:417',
'docs/concepts/services.md:147',
'docs/dbmgmt/migration.md:78',
'docs/extending/core_classes.md:64',
'docs/guides/api/controller.md:21',
'docs/guides/first-app/static_pages.md:55',
'docs/incoming/filters.md:59',
'docs/installation/upgrade_412.md:37',
'docs/models/model.md:75',
],
'ignoreErrors' => [
[
'identifier' => 'argument.type',
'paths' => [
'docs/cli/cli_commands.md:78',
'docs/cli/cli_library.md:240',
'docs/extending/events.md:25',
'docs/extending/events.md:51',
'docs/extending/events.md:92',
'docs/outgoing/api_responses.md:512',
'docs/outgoing/api_transformers.md:118',
'docs/outgoing/api_transformers.md:415',
],
],

[
'identifier' => 'catch.neverThrown',
'paths' => [
'docs/cli/cli_commands.md:145',
'docs/general/logging.md:125',
],
],

[
'identifier' => 'deadCode.unreachable',
'paths' => [
'docs/installation/upgrade_localization.md:61',
'docs/outgoing/localization.md:271',
'docs/outgoing/localization.md:310',
'docs/outgoing/localization.md:377',
'docs/outgoing/response.md:31',
'docs/outgoing/view_parser.md:275',
],
],

[
'identifier' => 'if.alwaysFalse',
'paths' => [
'docs/cli/cli_signals.md:531',
],
],

[
'identifier' => 'method.nonObject',
'paths' => [
'docs/outgoing/api_transformers.md:235',
'docs/outgoing/api_transformers.md:309',
'docs/outgoing/api_transformers.md:684',
'docs/outgoing/view_cells.md:324',
'docs/outgoing/view_cells.md:347',
],
],

[
'identifier' => 'new.noConstructor',
'paths' => [
'docs/concepts/services.md:162',
'docs/concepts/services.md:221',
'docs/extending/core_classes.md:81',
'docs/testing/fabricator.md:50',
],
],

[
'identifier' => 'outOfClass.self',
'paths' => [
'docs/testing/overview.md:293',
],
],

[
'identifier' => 'paramOut.type',
'paths' => [
'docs/libraries/validation.md:1045',
],
],

[
'identifier' => 'property.defaultValue',
'paths' => [
'docs/outgoing/view_parser.md:520',
'docs/testing/database.md:73',
],
],

[
'identifier' => 'property.nonObject',
'paths' => [
'docs/testing/fabricator.md:87',
],
],

[
'identifier' => 'property.notFound',
'paths' => [
'docs/installation/upgrade_sessions.md:39',
],
],

[
'identifier' => 'property.onlyWritten',
'paths' => [
'docs/installation/deployment.md:78',
],
],

[
'identifier' => 'property.protected',
'paths' => [
'docs/libraries/time.md:417',
],
],

[
'identifier' => 'return.missing',
'paths' => [
'docs/incoming/filters.md:18',
'docs/testing/fabricator.md:9',
],
],

[
'identifier' => 'return.type',
'paths' => [
'docs/concepts/services.md:162',
'docs/concepts/services.md:221',
'docs/extending/core_classes.md:81',
],
],

[
'identifier' => 'variable.implicitArray',
'paths' => [
'docs/incoming/routing.md:625',
'docs/installation/upgrade_localization.md:45',
],
],
],
],
];
Loading
Loading