Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ Dotkernel component used to create services through [Laminas Service Manager](ht

This package can clean up your code, by getting rid of all the factories you write, sometimes just to inject a dependency or two.

## Documentation

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

## Badges

![OSS Lifecycle](https://img.shields.io/osslifecycle?file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fdot-annotated-services%2Fblob%2F4.0%2FOSSMETADATA)
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.2.1)
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.3.0)

[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/issues)
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/network)
Expand All @@ -14,6 +20,7 @@ This package can clean up your code, by getting rid of all the factories you wri

[![Build Static](https://github.com/dotkernel/dot-annotated-services/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/continuous-integration.yml)
[![codecov](https://codecov.io/gh/dotkernel/dot-annotated-services/graph/badge.svg?token=ZBZDEA3LY8)](https://codecov.io/gh/dotkernel/dot-annotated-services)
[![PHPStan](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml)

## Installation

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "dotkernel/dot-annotated-services",
"type": "library",
"description": "DotKernel service creation component through laminas-servicemanager and annotations",
"description": "Dotkernel service creation component through laminas-servicemanager and annotations",
"license": "MIT",
"homepage": "https://github.com/dotkernel/dot-annotated-services",
"authors": [
{
"name": "DotKernel Team",
"name": "Dotkernel Team",
"email": "team@dotkernel.com"
}
],
Expand All @@ -28,8 +28,9 @@
},
"require-dev": {
"laminas/laminas-coding-standard": "^3.0",
"phpunit/phpunit": "^10.5.9",
"vimeo/psalm": "^6.0"
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^10.5.9"
},
"autoload": {
"psr-4": {
Expand All @@ -49,8 +50,7 @@
"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"
},
"config": {
"sort-packages": true,
Expand Down
14 changes: 14 additions & 0 deletions docs/book/v4/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,17 @@
`dot-annotated-services` is Dotkernel's dependency injection service.

By providing reusable factories for service and repository injection, it reduces code complexity in projects.

## Badges

![OSS Lifecycle](https://img.shields.io/osslifecycle?file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fdot-annotated-services%2Fblob%2F4.0%2FOSSMETADATA)
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.3.0)

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

[![Build Static](https://github.com/dotkernel/dot-annotated-services/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/continuous-integration.yml)
[![codecov](https://codecov.io/gh/dotkernel/dot-annotated-services/graph/badge.svg?token=ZBZDEA3LY8)](https://codecov.io/gh/dotkernel/dot-annotated-services)
[![PHPStan](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml)
17 changes: 17 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
parameters:
level: 5
paths:
- src
- test
treatPhpDocTypesAsCertain: false
ignoreErrors:
- message: '#Call to an undefined method .*::method\(\)\.#'
path: test/AnnotatedRepositoryFactoryTest.php
- message: '~Parameter #1 \$className of method PHPUnit\\Framework\\TestCase::getMockBuilder\(\) expects class-string<TestRepository>, string given.~'
path: test/AnnotatedRepositoryFactoryTest.php
- message: '#Call to an undefined method .*::method\(\)\.#'
path: test/AnnotatedServiceFactoryTest.php
- message: '~Parameter #1 \$className of method PHPUnit\\Framework\\TestCase::getMockBuilder\(\) expects class-string<TestService>, string given.~'
path: test/AnnotatedServiceFactoryTest.php
17 changes: 0 additions & 17 deletions psalm.xml

This file was deleted.

2 changes: 1 addition & 1 deletion test/AnnotatedRepositoryFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ public function testCreateObjectReturnsEntityRepository()

$object = $this->subject->__invoke($this->container, $repository::class);

$this->assertInstanceOf(EntityRepository::class, $object);
$this->assertContainsOnlyInstancesOf(EntityRepository::class, [$object]);
}
}
4 changes: 2 additions & 2 deletions test/AnnotatedServiceFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testReturnServiceWithNoDependencies()

$object = $this->subject->__invoke($this->container, $requestedName);

$this->assertInstanceOf($requestedName, $object);
$this->assertSame($requestedName, $object::class);
}

public function testThrowsExceptionAnnotationNotFound()
Expand Down Expand Up @@ -108,6 +108,6 @@ public function testReturnService()

$service = $this->subject->__invoke($this->container, $requestedName);

$this->assertInstanceOf($requestedName, $service);
$this->assertSame($requestedName, $service::class);
}
}