-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
3,276 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
name: "CI Tests" | ||
|
||
on: | ||
pull_request: | ||
push: | ||
|
||
jobs: | ||
php8: | ||
name: PHP 8 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v3" | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: "Install PHP 8" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: "8" | ||
|
||
- name: "Cache composer packages" | ||
uses: "actions/cache@v3" | ||
with: | ||
path: "~/.composer/cache" | ||
key: "php-composer-locked-${{ hashFiles('composer.lock') }}" | ||
restore-keys: "php-composer-locked-" | ||
|
||
- name: "Install dependencies with composer" | ||
run: "composer install --no-interaction --prefer-dist" | ||
|
||
- name: "Run PHPUnit Tests" | ||
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
composer test | ||
composer global require php-coveralls/php-coveralls | ||
php-coveralls --coverage_clover=build/output/tests/coverage.xml --json_path=build/output/tests/coveralls-upload.json -v | ||
- name: "Run PHP CS Check" | ||
run: "composer cs-check" | ||
|
||
- name: "Run Psalm" | ||
run: "composer psalm" | ||
|
||
- name: "PHP Lint" | ||
run: "composer lint" | ||
|
||
php81: | ||
name: PHP 8.1 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v3" | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: "Install PHP 8.1" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: "8.1" | ||
|
||
- name: "Cache composer packages" | ||
uses: "actions/cache@v3" | ||
with: | ||
path: "~/.composer/cache" | ||
key: "php-composer-locked-${{ hashFiles('composer.lock') }}" | ||
restore-keys: "php-composer-locked-" | ||
|
||
- name: "Install dependencies with composer" | ||
run: "composer install --no-interaction --prefer-dist" | ||
|
||
- name: "Run PHPUnit Tests" | ||
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
composer test | ||
composer global require php-coveralls/php-coveralls | ||
php-coveralls --coverage_clover=build/output/tests/coverage.xml --json_path=build/output/tests/coveralls-upload.json -v | ||
- name: "Run PHP CS Check" | ||
run: "composer cs-check" | ||
|
||
- name: "Run Psalm" | ||
run: "composer psalm" | ||
|
||
- name: "PHP Lint" | ||
run: "composer lint" | ||
|
||
php82: | ||
name: PHP 8.2 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v3" | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: "Install PHP 8.2" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: "8.2" | ||
|
||
- name: "Cache composer packages" | ||
uses: "actions/cache@v3" | ||
with: | ||
path: "~/.composer/cache" | ||
key: "php-composer-locked-${{ hashFiles('composer.lock') }}" | ||
restore-keys: "php-composer-locked-" | ||
|
||
- name: "Install dependencies with composer" | ||
run: "composer install --no-interaction --prefer-dist" | ||
|
||
- name: "Run PHPUnit Tests" | ||
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
composer test | ||
composer global require php-coveralls/php-coveralls | ||
php-coveralls --coverage_clover=build/output/tests/coverage.xml --json_path=build/output/tests/coveralls-upload.json -v | ||
- name: "Run PHP CS Check" | ||
run: "PHP_CS_FIXER_IGNORE_ENV=1 composer cs-check" | ||
|
||
- name: "Run Psalm" | ||
run: "composer psalm" | ||
|
||
- name: "PHP Lint" | ||
run: "composer lint" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.idea | ||
.phpunit.result.cache | ||
/vendor/ | ||
composer.lock | ||
/bin/ | ||
/tmp/ | ||
/html/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->exclude('vendor') | ||
->in(__DIR__) | ||
; | ||
|
||
$config = new PhpCsFixer\Config(); | ||
return $config | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
'@PSR2' => true, | ||
'braces' => false, | ||
'array_indentation' => true, | ||
'array_syntax' => [ | ||
'syntax' => 'short', | ||
], | ||
'blank_line_after_opening_tag' => false, | ||
'blank_line_before_statement' => true, | ||
'cast_spaces' => true, | ||
'concat_space' => [ | ||
'spacing' => 'one', | ||
], | ||
'declare_equal_normalize' => true, | ||
'include' => true, | ||
'function_typehint_space' => true, | ||
'linebreak_after_opening_tag' => true, | ||
'lowercase_cast' => true, | ||
'lowercase_static_reference' => true, | ||
'magic_constant_casing' => true, | ||
'modernize_types_casting' => true, | ||
'native_function_casing' => true, | ||
'new_with_braces' => true, | ||
'no_alternative_syntax' => true, | ||
'no_empty_comment' => true, | ||
'no_empty_statement' => true, | ||
'no_closing_tag' => true, | ||
'no_extra_blank_lines' => true, | ||
'no_leading_import_slash' => true, | ||
'no_leading_namespace_whitespace' => true, | ||
'no_multiline_whitespace_around_double_arrow' => true, | ||
'no_null_property_initialization' => true, | ||
'no_short_bool_cast' => true, | ||
'no_singleline_whitespace_before_semicolons' => true, | ||
'no_spaces_around_offset' => true, | ||
'no_superfluous_elseif' => true, | ||
'no_trailing_comma_in_singleline' => true, | ||
'no_unneeded_control_parentheses' => true, | ||
'no_unneeded_curly_braces' => true, | ||
'no_unneeded_final_method' => true, | ||
'no_unused_imports' => true, | ||
'no_useless_else' => true, | ||
'no_whitespace_before_comma_in_array' => true, | ||
'no_whitespace_in_blank_line' => true, | ||
'normalize_index_brace' => true, | ||
'object_operator_without_whitespace' => true, | ||
'ordered_imports' => true, | ||
'phpdoc_annotation_without_dot' => true, | ||
'phpdoc_indent' => true, | ||
'phpdoc_no_access' => true, | ||
'return_type_declaration' => true, | ||
'short_scalar_cast' => true, | ||
'simplified_null_return' => true, | ||
'single_blank_line_before_namespace' => true, | ||
'single_quote' => true, | ||
'standardize_not_equals' => true, | ||
'ternary_operator_spaces' => true, | ||
'ternary_to_null_coalescing' => true, | ||
'trim_array_spaces' => true, | ||
'unary_operator_spaces' => true, | ||
'visibility_required' => true, | ||
'trailing_comma_in_multiline' => true, | ||
'yoda_style' => false, | ||
|
||
/** @risky */ | ||
'strict_comparison' => true, | ||
'dir_constant' => true, | ||
])->setFinder($finder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
PHP DI Container | ||
---------------- | ||
|
||
A lightweight dependency injection container that is decoupled from any framework. | ||
This library can be used for production, but I recommend that it is better to use a di-container from a larger community like Symfony, Laravel or Laminas. | ||
|
||
This library was developed for fun, but is supported if someone uses it. | ||
|
||
This project can also be used as an example to show how a modern DI container works in a simplified way. | ||
|
||
--------------- | ||
|
||
How it works | ||
|
||
```bash | ||
composer require marcel-strahl/container | ||
``` | ||
|
||
Written for PHP >= 8.0 | ||
|
||
This library use the PSR container. | ||
|
||
-------------- | ||
|
||
Usage: | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "marcel-strahl/container", | ||
"description": "A simple and clean PHP container based on PSR-11", | ||
"keywords": ["psr-11", "11", "psr", "container", "PHP", "php", "DI", "di", "dependency injection", "dependency", "injection"], | ||
"minimum-stability": "stable", | ||
"license": "MIT", | ||
"type": "library", | ||
"authors": [ | ||
{ | ||
"name": "Marcel Strahl", | ||
"email": "info@marcel-strahl.de" | ||
} | ||
], | ||
"scripts": { | ||
"psalm": "psalm --no-cache", | ||
"lint": "parallel-lint --exclude .git --exclude vendor bin .", | ||
"cs-check": "php-cs-fixer -v --dry-run --using-cache=no fix", | ||
"cs-fix": "php-cs-fixer --using-cache=no fix", | ||
"test": "export XDEBUG_MODE=coverage && phpunit --configuration phpunit.xml.dist" | ||
}, | ||
"config":{ | ||
"bin-dir": "bin" | ||
}, | ||
"prefer-stable": true, | ||
"autoload": { | ||
"psr-4": { | ||
"MarcelStrahl\\Container\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"MarcelStrahl\\Tests\\": "tests/" | ||
} | ||
}, | ||
"require": { | ||
"php": "^8.0", | ||
"psr/container": "^2.0", | ||
"webmozart/assert": "^1.11" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^9.5", | ||
"roave/security-advisories": "dev-latest", | ||
"friendsofphp/php-cs-fixer": "^3.13", | ||
"php-parallel-lint/php-parallel-lint": "^1.3", | ||
"vimeo/psalm": "^5.6", | ||
"psalm/plugin-phpunit": "^0.18.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd" bootstrap="vendor/autoload.php" backupGlobals="false" beStrictAboutCoversAnnotation="true" beStrictAboutOutputDuringTests="true" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutTodoAnnotatedTests="true" verbose="true"> | ||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">src</directory> | ||
</include> | ||
<exclude> | ||
<directory>./bin</directory> | ||
<directory>./tests</directory> | ||
<directory>./vendor</directory> | ||
</exclude> | ||
<report> | ||
<clover outputFile="build/output/tests/coverage.xml"/> | ||
<text outputFile="php://stdout" showUncoveredFiles="false"/> | ||
</report> | ||
</coverage> | ||
<testsuite name="PriceCalculator"> | ||
<directory suffix="Test.php">tests</directory> | ||
</testsuite> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0"?> | ||
<psalm | ||
errorLevel="6" | ||
resolveFromConfigFile="true" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="https://getpsalm.org/schema/config" | ||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" | ||
findUnusedBaselineEntry="true" | ||
> | ||
<projectFiles> | ||
<directory name="src"/> | ||
<ignoreFiles> | ||
<directory name="vendor"/> | ||
</ignoreFiles> | ||
</projectFiles> | ||
<plugins> | ||
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/> | ||
</plugins> | ||
</psalm> |
Oops, something went wrong.