Skip to content

Commit 669fc1c

Browse files
committed
work on fixing CI, fixes #66
1 parent 81d8daa commit 669fc1c

File tree

5 files changed

+42
-9
lines changed

5 files changed

+42
-9
lines changed

.github/workflows/tests.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: CI
22

33
on:
4-
pull_request: ~
4+
pull_request:
55
push:
66
branches:
77
- master
@@ -19,6 +19,7 @@ jobs:
1919
- "8.2"
2020
- "8.3"
2121
- "8.4"
22+
- "8.5"
2223
dependencies:
2324
- "highest"
2425
include:
@@ -29,14 +30,14 @@ jobs:
2930
name: PHP ${{ matrix.php }} ${{ matrix.description }}
3031
steps:
3132
- name: "Checkout"
32-
uses: actions/checkout@v4
33+
uses: actions/checkout@v6
3334
- name: "Install PHP"
3435
uses: shivammathur/setup-php@v2
3536
with:
3637
php-version: ${{ matrix.php }}
3738
coverage: xdebug
3839
- name: "Install dependencies"
39-
uses: ramsey/composer-install@v3
40+
uses: ramsey/composer-install@v4
4041
with:
4142
dependency-versions: ${{ matrix.dependencies }}
4243
- name: "Run PHPStan analysis"

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "https://getcomposer.org/schema.json",
23
"name": "thecodingmachine/phpstan-safe-rule",
34
"description": "A PHPStan rule to detect safety issues. Must be used in conjunction with thecodingmachine/safe",
45
"type": "phpstan-extension",
@@ -11,8 +12,8 @@
1112
],
1213
"require": {
1314
"php": "^8.1",
14-
"phpstan/phpstan": "^2.1.11",
15-
"thecodingmachine/safe": "^1.2 || ^2.0 || ^3.0",
15+
"phpstan/phpstan": "^2.1.30",
16+
"thecodingmachine/safe": "^3.1",
1617
"nikic/php-parser": "^5"
1718
},
1819
"require-dev": {
@@ -31,7 +32,7 @@
3132
}
3233
},
3334
"scripts": {
34-
"phpstan": "phpstan analyse -c phpstan.neon --no-progress -vvv",
35+
"phpstan": "phpstan analyse -c phpstan.neon --no-progress -vv",
3536
"test": "XDEBUG_MODE=coverage phpunit",
3637
"cs-fix": "phpcbf",
3738
"cs-check": "phpcs"

phpstan.neon

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ parameters:
77
- tests/Rules/UseSafeCallablesRule
88
- tests/Rules/UseSafeClassesRule
99
- tests/Rules/UseSafeFunctionsRule
10+
- tests/Type/Php/data
1011
ignoreErrors:
1112
-
1213
message: '#^Implementing PHPStan\\Rules\\IdentifierRuleError is not covered by backward compatibility promise\. The interface might change in a minor PHPStan version\.$#'
1314
identifier: phpstanApi.interface
1415
count: 1
1516
path: src/Rules/Error/SafeRuleError.php
16-
17+
1718
-
1819
message: '#^Implementing PHPStan\\Rules\\LineRuleError is not covered by backward compatibility promise\. The interface might change in a minor PHPStan version\.$#'
1920
identifier: phpstanApi.interface
2021
count: 1
2122
path: src/Rules/Error/SafeRuleError.php
22-
23+
2324
-
2425
message: '#^Implementing PHPStan\\Rules\\RuleError is not covered by backward compatibility promise\. The interface might change in a minor PHPStan version\.$#'
2526
identifier: phpstanApi.interface

tests/Type/Php/TypeAssertionsTest.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public static function dataFileAsserts(): iterable
1515
yield from self::gatherAssertTypes(__DIR__ . '/data/preg_match_checked.php');
1616
yield from self::gatherAssertTypes(__DIR__ . '/data/preg_replace_return.php');
1717
yield from self::gatherAssertTypes(__DIR__ . '/data/json_decode_return.php');
18-
yield from self::gatherAssertTypes(__DIR__ . '/data/preg_match_identity_check.php');
1918
}
2019

2120
/**
@@ -29,6 +28,34 @@ public function testFileAsserts(
2928
$this->assertFileAsserts($assertType, $file, ...$args);
3029
}
3130

31+
/**
32+
* @return iterable<mixed>
33+
*/
34+
public static function dataKnownProblems(): iterable
35+
{
36+
yield from self::gatherAssertTypes(__DIR__ . '/data/preg_match_identity_check.php');
37+
}
38+
39+
/**
40+
* @dataProvider dataKnownProblems
41+
*/
42+
public function testKnownProblems(
43+
string $assertType,
44+
string $file,
45+
mixed ...$args
46+
): void {
47+
try {
48+
$this->assertFileAsserts($assertType, $file, ...$args);
49+
$this->fail(
50+
"Expected an assertion failure in $file, but it passed. ".
51+
"This is a known issue that should be fixed, but the test ".
52+
"should not fail until then."
53+
);
54+
} catch (\PHPUnit\Framework\ExpectationFailedException $e) {
55+
$this->assertStringContainsString('Failed asserting that', $e->getMessage(), "Expected an assertion failure in $file, but got a different error: " . $e->getMessage());
56+
}
57+
}
58+
3259
public static function getAdditionalConfigFiles(): array
3360
{
3461
return [__DIR__ . '/../../../phpstan-safe-rule.neon'];

tests/Type/Php/data/json_decode_return.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
namespace TheCodingMachine\Safe\PHPStan\Type\Php\data;
4+
25
$value = \Safe\json_decode('null');
36
\PHPStan\Testing\assertType('null', $value);
47

0 commit comments

Comments
 (0)