Skip to content

Commit 1794878

Browse files
committed
chore: Add psalm and cs-checker
1 parent c5c523c commit 1794878

File tree

5 files changed

+60
-2
lines changed

5 files changed

+60
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ docs/build
77
docs/.phpdoc
88
phpunit/
99
.phpunit.result.cache
10+
.php-cs-fixer.cache

.php-cs-fixer.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()->in(__DIR__);
4+
5+
$config = new PhpCsFixer\Config();
6+
return $config
7+
->setFinder($finder)
8+
->setUsingCache(true)
9+
->setRules([
10+
'@PSR2' => true,
11+
'blank_line_after_opening_tag' => true,
12+
'ordered_imports' => true,
13+
'no_unused_imports' => true,
14+
'array_syntax' => ['syntax' => 'short'],
15+
]);

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.PHONY: help
2+
help: #! Show this help message
3+
@echo 'Usage: make [target] ... '
4+
@echo ''
5+
@echo 'Targets:'
6+
@grep -h -F '#!' $(MAKEFILE_LIST) | grep -v grep | sed 's/:.*#!/:/' | column -t -s":"
7+
8+
.PHONY: test
9+
test: #! Run unit tests
10+
php -d xdebug.mode=coverage vendor/bin/phpunit
11+
12+
.PHONY: coverage
13+
coverage: #! Run unit tests with test coverage
14+
php -d xdebug.mode=coverage vendor/bin/phpunit
15+
16+
.PHONY: lint
17+
lint: #! Run quality control tools (e.g. psalm)
18+
./vendor/bin/psalm --no-cache
19+
composer cs-check

composer.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@
2222
"require": {
2323
"php": ">=8.1",
2424
"predis/predis": ">=2.3.0 <3.0.0",
25-
"launchdarkly/server-sdk": ">=6.4.0 <7.0.0"
25+
"launchdarkly/server-sdk": ">=6.3.0 <7.0.0"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "^11"
28+
"friendsofphp/php-cs-fixer": "^3.68",
29+
"phpunit/php-code-coverage": "^9",
30+
"phpunit/phpunit": "^9",
31+
"vimeo/psalm": "^5.26"
2932
},
3033
"autoload": {
3134
"psr-4": {
@@ -39,5 +42,10 @@
3942
},
4043
"config": {
4144
"sort-packages": true
45+
},
46+
"scripts": {
47+
"cs-check": "vendor/bin/php-cs-fixer fix --diff --dry-run --verbose --config=.php-cs-fixer.php",
48+
"cs-fix": "vendor/bin/php-cs-fixer fix --diff --verbose --config=.php-cs-fixer.php"
4249
}
50+
4351
}

psalm.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="2"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
>
9+
<projectFiles>
10+
<directory name="src" />
11+
<ignoreFiles>
12+
<directory name="vendor" />
13+
</ignoreFiles>
14+
</projectFiles>
15+
</psalm>

0 commit comments

Comments
 (0)