Skip to content

Commit

Permalink
use phive setup for stan
Browse files Browse the repository at this point in the history
  • Loading branch information
LordSimal committed Oct 15, 2023
1 parent 1022e36 commit c8c779e
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 20 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:

cs-stan:
name: Coding Standard & Static Analysis
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
Expand All @@ -85,18 +85,21 @@ jobs:
php-version: '8.1'
extensions: mbstring, intl
coverage: none
tools: cs2pr, vimeo/psalm:4, phpstan:1
tools: phive, cs2pr

- name: Composer install
uses: ramsey/composer-install@v2

- name: Composer Install
run: composer install
- name: Install PHP tools with phive.
run: "phive install --trust-gpg-keys 'CF1A108D0E7AE720,51C67305FFC2E5C0,12CE0F1D262429A5'"

- name: Run phpcs
run: vendor/bin/phpcs --report=checkstyle src/ tests/ | cs2pr

- name: Run psalm
if: always()
run: psalm --output-format=github
run: tools/psalm --output-format=github

- name: Run psalm
- name: Run phpstan
if: always()
run: phpstan analyse
run: tools/phpstan analyse --error-format=github
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/.phpunit.cache
/.idea/
/config/Migrations/schema-dump-default.lock
/tools
5 changes: 5 additions & 0 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="1.10.38" installed="1.10.38" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.15.0" installed="5.15.0" location="./tools/psalm" copy="false"/>
</phive>
12 changes: 11 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,17 @@
"license": "MIT",
"scripts": {
"cs-check": "phpcs --colors -p ./src ./tests",
"cs-fix": "phpcbf --colors -p ./src ./tests"
"cs-fix": "phpcbf --colors -p ./src ./tests",
"test": "phpunit",
"phpstan": "tools/phpstan analyse",
"psalm": "tools/psalm --show-info=false",
"stan": [
"@phpstan",
"@psalm"
],
"phpstan-baseline": "tools/phpstan --generate-baseline",
"psalm-baseline": "tools/psalm --set-baseline=psalm-baseline.xml",
"stan-setup": "phive install"
},
"config": {
"allow-plugins": {
Expand Down
11 changes: 11 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$callback of function call_user_func expects callable\\(\\)\\: mixed, array\\{Cake\\\\ORM\\\\Table, mixed\\} given\\.$#"
count: 1
path: src/Middleware/SocialAuthMiddleware.php

-
message: "#^Method ADmad\\\\SocialAuth\\\\Plugin\\:\\:bootstrap\\(\\) has parameter \\$app with generic interface Cake\\\\Core\\\\PluginApplicationInterface but does not specify its types\\: TSubject$#"
count: 1
path: src/Plugin.php
8 changes: 3 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
includes:
- phpstan-baseline.neon

parameters:
level: 8
checkMissingIterableValueType: false
bootstrapFiles:
- tests/bootstrap.php
paths:
- src/
ignoreErrors:
-
message: "#^Parameter \\#1 \\$function of function call_user_func expects callable\\(\\)\\: mixed, array\\{Cake\\\\ORM\\\\Table, mixed\\} given\\.$#"
count: 1
path: src/Middleware/SocialAuthMiddleware.php
3 changes: 3 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0"?>
<psalm
findUnusedPsalmSuppress="true"
findUnusedBaselineEntry="true"
findUnusedCode="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand Down
8 changes: 6 additions & 2 deletions src/Middleware/SocialAuthMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@
use SocialConnect\Provider\Session\Session as SocialConnectSession;
use SocialConnect\Provider\Session\SessionInterface;

/**
* @implements \Cake\Event\EventDispatcherInterface<\ADmad\SocialAuth\Middleware\SocialAuthMiddleware>
*/
class SocialAuthMiddleware implements MiddlewareInterface, EventDispatcherInterface
{
/**
* @use \Cake\Event\EventDispatcherTrait<\ADmad\SocialAuth\Middleware\SocialAuthMiddleware>
*/
use EventDispatcherTrait;
use InstanceConfigTrait;
use LocatorAwareTrait;
Expand Down Expand Up @@ -562,7 +568,6 @@ protected function _getService(ServerRequest $request): Service
$serviceConfig = Configure::consume('SocialAuth');
}

/** @psalm-suppress PossiblyInvalidArrayOffset */
if (!isset($serviceConfig['redirectUri'])) {
$serviceConfig['redirectUri'] = Router::url([
'plugin' => 'ADmad/SocialAuth',
Expand All @@ -580,7 +585,6 @@ protected function _getService(ServerRequest $request): Service
new StreamFactory()
);

/** @psalm-suppress PossiblyNullArgument */
$this->_service = new Service(
$httpStack,
$this->_session ?: new SocialConnectSession(),
Expand Down
10 changes: 5 additions & 5 deletions src/Model/Table/SocialProfilesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile newEmptyEntity()
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile newEntity(array $data, array $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile[] newEntities(array $data, array $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile get($primaryKey, $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile findOrCreate($search, ?callable $callback = null, $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile[] patchEntities(iterable $entities, array $data, array $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile|false save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile saveOrFail(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile[]|\Cake\Datasource\ResultSetInterface|false saveMany(iterable $entities, $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile[]|\Cake\Datasource\ResultSetInterface saveManyOrFail(iterable $entities, $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile[]|\Cake\Datasource\ResultSetInterface|false deleteMany(iterable $entities, $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile[]|\Cake\Datasource\ResultSetInterface deleteManyOrFail(iterable $entities, $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile[]|false saveMany(iterable $entities, $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile[] saveManyOrFail(iterable $entities, $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile[]|false deleteMany(iterable $entities, $options = [])
* @method \ADmad\SocialAuth\Model\Entity\SocialProfile[] deleteManyOrFail(iterable $entities, $options = [])
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class SocialProfilesTable extends Table
Expand Down

0 comments on commit c8c779e

Please sign in to comment.