Skip to content

Commit c4bf6b2

Browse files
authored
Add composer-require-checker to static analysis checks (#1)
1 parent 037266f commit c4bf6b2

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

.github/workflows/static-analysis.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ env:
1212

1313
jobs:
1414
phpstan:
15+
name: PHPStan
1516
runs-on: ubuntu-latest
1617
steps:
1718
- name: Check out code
@@ -45,3 +46,37 @@ jobs:
4546
run: vendor/bin/phpstan
4647
analyse
4748
--error-format=github
49+
50+
require-checker:
51+
name: Require checker
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Check out code
55+
uses: actions/checkout@v2
56+
57+
- name: Setup PHP
58+
uses: shivammathur/setup-php@v2
59+
60+
- name: Get Composer Cache Directory
61+
id: composer-cache
62+
run: |
63+
echo "::set-output name=dir::$(composer config cache-files-dir)"
64+
65+
- name: Cache Composer packages
66+
uses: actions/cache@v3
67+
with:
68+
path: ${{ steps.composer-cache.outputs.dir }}
69+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
70+
restore-keys: |
71+
${{ runner.os }}-composer-
72+
73+
- name: Install dependencies
74+
run: composer update
75+
--no-ansi
76+
--no-interaction
77+
--no-progress
78+
--no-suggest
79+
--prefer-dist
80+
81+
- name: Composer require-checker
82+
run: vendor/bin/composer-require-checker check

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"php": "^7.3 || ^8.0"
2929
},
3030
"require-dev": {
31+
"maglnet/composer-require-checker": "^2.0 || ^3.0 || ^4.0",
3132
"mheap/phpunit-github-actions-printer": "^1.5",
3233
"phpstan/phpstan": "^1.0",
3334
"phpstan/phpstan-phpunit": "^1.0",

src/Example.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Your\Library;
6+
7+
/**
8+
* This file exists to:
9+
* a) Demonstrate the default namespace setup
10+
* b) Provide something for composer-require-checker to find when CI runs
11+
* against the actual template repository.
12+
*
13+
* You won't want to keep it!
14+
*/
15+
class Example
16+
{
17+
public string $message;
18+
19+
public function __construct(string $message)
20+
{
21+
$this->message = $message;
22+
}
23+
}

0 commit comments

Comments
 (0)