Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on:
- push

name: Run PHPStan checks

jobs:
mutation:
name: PHPStan ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest

php:
- "8.2"
- "8.3"
- "8.4"

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
coverage: pcov
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
tools: composer:v2, cs2pr

- name: Determine composer cache directory
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-

- name: Install dependencies with composer
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run static analysis with PHPStan
run: vendor/bin/phpstan analyse
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# dot-cli

> [!IMPORTANT]
Dotkernel component to build console applications based on [laminas-cli](https://github.com/laminas/laminas-cli).

> dot-cli is a wrapper on top of [laminas-cli](https://github.com/laminas/laminas-cli)

## Documentation

Documentation is available at: https://docs.dotkernel.org/dot-cli/.

## Badges

![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-cli)
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-cli/3.8.1)
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-cli/3.9.0)

[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-cli)](https://github.com/dotkernel/dot-cli/issues)
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-cli)](https://github.com/dotkernel/dot-cli/network)
Expand All @@ -13,8 +20,7 @@

[![Build Static](https://github.com/dotkernel/dot-cli/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-cli/actions/workflows/continuous-integration.yml)
[![codecov](https://codecov.io/gh/dotkernel/dot-cli/graph/badge.svg?token=0DFCK2GUBT)](https://codecov.io/gh/dotkernel/dot-cli)

Dotkernel component to build console applications based on [laminas-cli](https://github.com/laminas/laminas-cli).
[![PHPStan](https://github.com/dotkernel/dot-cli/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-cli/actions/workflows/static-analysis.yml)

## Requirements

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
"require-dev": {
"laminas/laminas-coding-standard": "^3.0",
"mikey179/vfsstream": "^1.6.7",
"phpunit/phpunit": "^10.2",
"vimeo/psalm": "^6.0"
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^10.2"
},
"autoload-dev": {
"psr-4": {
Expand All @@ -52,7 +53,6 @@
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"static-analysis": "psalm --shepherd --stats"
"static-analysis": "phpstan analyse --memory-limit 1G"
}
}
16 changes: 16 additions & 0 deletions docs/book/v3/overview.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Overview

Dotkernel component to build console applications based on [laminas-cli](https://github.com/laminas/laminas-cli).

> dot-cli is a wrapper on top of [laminas-cli](https://github.com/laminas/laminas-cli)

## Badges

![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-cli)
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-cli/3.9.0)

[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-cli)](https://github.com/dotkernel/dot-cli/issues)
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-cli)](https://github.com/dotkernel/dot-cli/network)
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-cli)](https://github.com/dotkernel/dot-cli/stargazers)
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-cli)](https://github.com/dotkernel/dot-cli/blob/3.0/LICENSE)

[![Build Static](https://github.com/dotkernel/dot-cli/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-cli/actions/workflows/continuous-integration.yml)
[![codecov](https://codecov.io/gh/dotkernel/dot-cli/graph/badge.svg?token=0DFCK2GUBT)](https://codecov.io/gh/dotkernel/dot-cli)
[![PHPStan](https://github.com/dotkernel/dot-cli/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-cli/actions/workflows/static-analysis.yml)
8 changes: 8 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
parameters:
level: 5
paths:
- src
- test
treatPhpDocTypesAsCertain: false
13 changes: 0 additions & 13 deletions psalm-baseline.xml

This file was deleted.

18 changes: 0 additions & 18 deletions psalm.xml

This file was deleted.

2 changes: 1 addition & 1 deletion test/Command/DemoCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DemoCommandTest extends TestCase
public function testWillCreateCommand(): void
{
$command = new DemoCommand();
$this->assertInstanceOf(DemoCommand::class, $command);
$this->assertSame(DemoCommand::class, $command::class);
}

/**
Expand Down
32 changes: 16 additions & 16 deletions test/FileLockerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ public function testAccessors(): void
$fileLocker = new FileLocker();
$this->assertFalse($fileLocker->isEnabled());
$fileLocker->enable();
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertTrue($fileLocker->isEnabled());
$fileLocker->disable();
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertFalse($fileLocker->isEnabled());
$fileLocker->setEnabled(true);
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertTrue($fileLocker->isEnabled());
$fileLocker->setEnabled(false);
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertFalse($fileLocker->isEnabled());
$this->assertNull($fileLocker->getDirPath());
$fileLocker->setDirPath('test');
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertSame('test', $fileLocker->getDirPath());
$this->assertNull($fileLocker->getCommandName());
$fileLocker->setCommandName('test');
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertSame('test', $fileLocker->getCommandName());
$this->assertNull($fileLocker->getLockFile());
$fileLocker->setLockFile('test');
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertSame('test', $fileLocker->getLockFile());
$this->assertSame('test/command-test.lock', $fileLocker->getLockFilePath());
}
Expand All @@ -65,7 +65,7 @@ public function testWillInitLockFile(): void
$fileLocker = new FileLocker(true, $config['dirPath'], 'test');
$this->assertNull($fileLocker->getLockFile());
$fileLocker->initLockFile();
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertIsResource($fileLocker->getLockFile());
}

Expand All @@ -79,7 +79,7 @@ public function testWillNotLockWhenDisabled(): void
$fileLocker = new FileLocker(false, $config['dirPath'], 'test');
$this->assertNull($fileLocker->getLockFile());
$fileLocker->lock();
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertNull($fileLocker->getLockFile());
}

Expand All @@ -93,7 +93,7 @@ public function testWillNotLockWithoutValidCommandName(): void
$fileLocker = new FileLocker(true, $config['dirPath']);
$this->assertNull($fileLocker->getLockFile());
$fileLocker->lock();
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertNull($fileLocker->getLockFile());
}

Expand All @@ -107,7 +107,7 @@ public function testWillLockWhenLockedAndEnabledAndHasValidCommandName(): void
$fileLocker = new FileLocker(true, $config['dirPath'], 'test');
$this->assertNull($fileLocker->getLockFile());
$fileLocker->lock();
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertIsResource($fileLocker->getLockFile());
$this->assertFileExists($fileLocker->getLockFilePath());
}
Expand All @@ -119,7 +119,7 @@ public function testWillNotUnlockWhenDisabled(): void
$fileLocker = new FileLocker(false, $config['dirPath'], 'test');
$this->assertNull($fileLocker->getLockFile());
$fileLocker->unlock();
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertNull($fileLocker->getLockFile());
}

Expand All @@ -130,7 +130,7 @@ public function testWillNotUnlockWithoutValidCommandName(): void
$fileLocker = new FileLocker(false, $config['dirPath']);
$this->assertNull($fileLocker->getLockFile());
$fileLocker->unlock();
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertNull($fileLocker->getLockFile());
}

Expand All @@ -141,7 +141,7 @@ public function testWillNotUnlockWhenEnabledAndWithoutValidCommandName(): void
$fileLocker = new FileLocker(true, $config['dirPath']);
$this->assertNull($fileLocker->getLockFile());
$fileLocker->unlock();
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertNull($fileLocker->getLockFile());
}

Expand All @@ -154,11 +154,11 @@ public function testWillUnlockWhenLockedAndEnabledAndHasValidCommandName(): void

$fileLocker = new FileLocker(true, $config['dirPath'], 'test');
$fileLocker->lock();
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertIsResource($fileLocker->getLockFile());
$this->assertFileExists($fileLocker->getLockFilePath());
$fileLocker->unlock();
$this->assertInstanceOf(FileLocker::class, $fileLocker);
$this->assertSame(FileLocker::class, $fileLocker::class);
$this->assertFileIsReadable($fileLocker->getLockFilePath());
$this->assertFileIsWritable($fileLocker->getLockFilePath());
}
Expand Down