Skip to content

Commit

Permalink
Add Static Analysis config (#436)
Browse files Browse the repository at this point in the history
* Add phpstan config with baseline

Co-authored-by: Alexander M. Turek <me@derrabus.de>

* Add psalm config with baseline

* Add psalm, phpstan dev requirement

* Add workflow config

---------

Co-authored-by: Alexander M. Turek <me@derrabus.de>
  • Loading branch information
connorhu and derrabus authored Feb 28, 2024
1 parent 908efd3 commit a1b3574
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Static Analysis"

on:
pull_request:
branches:
- "master"
paths:
- .github/workflows/static-analysis.yml
- composer.*
- src/**
- phpstan*
- psalm*
push:
branches:
- "master"
paths:
- .github/workflows/static-analysis.yml
- composer.*
- src/**
- phpstan*
- psalm*

jobs:
static-analysis:
uses: "doctrine/.github/.github/workflows/static-analysis.yml@4.0.0"
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
"doctrine/annotations": "^1.14 || ^2",
"doctrine/coding-standard": "^9.0.2 || ^12.0",
"nesbot/carbon": "^2.72 || ^3",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^8.5 || ^9.6",
"squizlabs/php_codesniffer": "^3.8",
"symfony/cache": "^5.4 || ^6.4 || ^7.0",
"symfony/yaml": "^5.4 || ^6.4 || ^7.0",
"vimeo/psalm": "^3.18 || ^5.22",
"zf1/zend-date": "^1.12",
"zf1/zend-registry": "^1.12"
},
Expand Down
41 changes: 41 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
parameters:
ignoreErrors:
-
message: "#^Property DoctrineExtensions\\\\Query\\\\Mysql\\\\Collate\\:\\:\\$collation \\(null\\) does not accept string\\.$#"
count: 1
path: src/Query/Mysql/Collate.php

-
message: "#^Property DoctrineExtensions\\\\Query\\\\Mysql\\\\Collate\\:\\:\\$stringPrimary \\(null\\) does not accept Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node\\.$#"
count: 1
path: src/Query/Mysql/Collate.php

-
message: "#^Property DoctrineExtensions\\\\Query\\\\Mysql\\\\Lag\\:\\:\\$aggregateExpression \\(Doctrine\\\\ORM\\\\Query\\\\AST\\\\AggregateExpression\\) does not accept Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node\\|string\\.$#"
count: 1
path: src/Query/Mysql/Lag.php

-
message: "#^Property DoctrineExtensions\\\\Query\\\\Mysql\\\\Lag\\:\\:\\$offset \\(Doctrine\\\\ORM\\\\Query\\\\AST\\\\ArithmeticExpression\\) does not accept Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node\\|string\\.$#"
count: 1
path: src/Query/Mysql/Lag.php

-
message: "#^Property DoctrineExtensions\\\\Query\\\\Mysql\\\\Lead\\:\\:\\$aggregateExpression \\(Doctrine\\\\ORM\\\\Query\\\\AST\\\\AggregateExpression\\) does not accept Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node\\|string\\.$#"
count: 1
path: src/Query/Mysql/Lead.php

-
message: "#^Property DoctrineExtensions\\\\Query\\\\Mysql\\\\Lead\\:\\:\\$offset \\(Doctrine\\\\ORM\\\\Query\\\\AST\\\\ArithmeticExpression\\) does not accept Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node\\|string\\.$#"
count: 1
path: src/Query/Mysql/Lead.php

-
message: "#^Property DoctrineExtensions\\\\Query\\\\Sqlite\\\\Week\\:\\:\\$mode \\(int\\) does not accept Doctrine\\\\ORM\\\\Query\\\\AST\\\\Literal\\.$#"
count: 1
path: src/Query/Sqlite/Week.php

-
message: "#^Method DoctrineExtensions\\\\Types\\\\ZendDateType\\:\\:convertToPHPValue\\(\\) should return Zend_Date but returns null\\.$#"
count: 1
path: src/Types/ZendDateType.php
8 changes: 8 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
level: 3
paths:
- src
phpVersion: 80300

includes:
- phpstan-baseline.neon
13 changes: 13 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.22.2@d768d914152dbbf3486c36398802f74e80cfde48">
<file src="src/Query/Sqlite/DateFormat.php">
<NoValue>
<code><![CDATA[$format]]></code>
</NoValue>
</file>
<file src="src/Types/ZendDateType.php">
<MissingFile>
<code><![CDATA[require_once 'Zend/Date.php']]></code>
</MissingFile>
</file>
</files>
16 changes: 16 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<psalm
errorLevel="8"
phpVersion="8.3"
resolveFromConfigFile="true"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
<directory name="src" />
</projectFiles>
</psalm>

0 comments on commit a1b3574

Please sign in to comment.