Skip to content

Commit c817f0c

Browse files
committedAug 21, 2022
Initialize project with jeromegamez/cookiecutter-php
0 parents  commit c817f0c

12 files changed

+286
-0
lines changed
 

‎.editorconfig

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
charset = utf-8
9+
indent_size = 4
10+
indent_style = space
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
[**.{neon,neon.dist}]
18+
indent_style = tab
19+
20+
[**.{yml,yaml}]
21+
indent_size = 2

‎.gitattributes

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.php diff=php
2+
3+
/tests/ export-ignore
4+
/.editorconfig export-ignore
5+
/.gitattributes export-ignore
6+
/.gitignore export-ignore
7+
/.php-cs-fixer.php export-ignore
8+
/phpstan.neon.dist export-ignore

‎.github/workflows/tests.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- 'main'
8+
9+
jobs:
10+
tests:
11+
name: PHP ${{ matrix.php }}
12+
runs-on: ubuntu-20.04
13+
14+
strategy:
15+
matrix:
16+
php:
17+
- "8.0"
18+
- "8.1"
19+
dependencies:
20+
- "lowest"
21+
- "highest"
22+
23+
env:
24+
extensions: ctype, dom, intl, json, mbstring, openssl, xml, zip, zlib
25+
key: cache-v1 # can be any string, change to clear the extension cache.
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v2
30+
31+
- name: Setup cache environment
32+
id: extcache
33+
uses: shivammathur/cache-extensions@v1
34+
with:
35+
php-version: ${{ matrix.php }}
36+
extensions: ${{ env.extensions }}
37+
key: ${{ env.key }}
38+
39+
- name: Cache extensions
40+
uses: actions/cache@v2
41+
with:
42+
path: ${{ steps.extcache.outputs.dir }}
43+
key: ${{ steps.extcache.outputs.key }}
44+
restore-keys: ${{ steps.extcache.outputs.key }}
45+
46+
- name: Setup PHP
47+
uses: shivammathur/setup-php@v2
48+
with:
49+
php-version: ${{ matrix.php }}
50+
extensions: ${{ env.extensions }}
51+
tools: composer, pecl
52+
coverage: xdebug
53+
env:
54+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- uses: "ramsey/composer-install@v1"
57+
with:
58+
dependency-versions: "${{ matrix.dependencies }}"
59+
composer-options: "${{ matrix.composer-options }}"
60+
61+
- name: Setup problem matchers for PHP
62+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
63+
64+
- name: Run PHPStan
65+
run: vendor/bin/phpstan analyse
66+
67+
- name: Setup Problem Matchers for PHPUnit
68+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
69+
70+
- name: Run PHPUnit
71+
run: vendor/bin/phpunit --testdox --coverage-text

‎.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/vendor/
2+
3+
/.php-cs-fixer.cache
4+
/.phpunit.result.cache
5+
6+
/composer.lock
7+
/phpstan.neon
8+
/phpunit.xml

‎.php-cs-fixer.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
/** @noinspection DevelopmentDependenciesUsageInspection */
4+
5+
use Ergebnis\PhpCsFixer\Config;
6+
7+
$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php80());
8+
9+
$config->getFinder()->in(__DIR__);
10+
11+
return $config;

‎LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Jérôme Gamez, https://github.com/beste <jerome@gamez.name>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# PHP CS Fixer Config
2+
3+
PHP CS Fixer Config used in BESTE projects
4+
5+
## Installation
6+
7+
```shell
8+
composer require beste/php-cs-fixer-config
9+
```
10+
11+
## Running tests
12+
13+
```shell
14+
composer run tests
15+
```

‎composer.json

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "beste/php-cs-fixer-config",
3+
"description": "PHP CS Fixer Config used in BESTE projects",
4+
"license": "MIT",
5+
"type": "library",
6+
"authors": [
7+
{
8+
"name": "Jérôme Gamez",
9+
"email": "jerome@gamez.name"
10+
}
11+
],
12+
"require": {
13+
"php": "~8.0.0 || ~8.1.0"
14+
},
15+
"require-dev": {
16+
"ergebnis/composer-normalize": "^2.28",
17+
"ergebnis/php-cs-fixer-config": "^4.4",
18+
"ergebnis/phpstan-rules": "^1.0",
19+
"phpstan/extension-installer": "^1.1",
20+
"phpstan/phpstan": "^1.8",
21+
"phpstan/phpstan-deprecation-rules": "^1.0",
22+
"phpstan/phpstan-phpunit": "^1.1.1",
23+
"phpstan/phpstan-strict-rules": "^1.3.0",
24+
"phpunit/phpunit": "^9.5"
25+
},
26+
"autoload": {
27+
"psr-4": {
28+
"Beste\\PhpCsFixer\\": "src"
29+
}
30+
},
31+
"autoload-dev": {
32+
"psr-4": {
33+
"Beste\\PhpCsFixer\\Tests\\": "tests"
34+
}
35+
},
36+
"config": {
37+
"allow-plugins": {
38+
"phpstan/extension-installer": true,
39+
"composer/package-versions-deprecated": true,
40+
"ergebnis/composer-normalize": true
41+
},
42+
"sort-packages": true
43+
},
44+
"scripts": {
45+
"cs": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --verbose",
46+
"phpstan": "vendor/bin/phpstan analyse",
47+
"phpunit": "vendor/bin/phpunit",
48+
"test": [
49+
"@phpstan",
50+
"@phpunit"
51+
]
52+
},
53+
"scripts-descriptions": {
54+
"cs": "Applies coding standards",
55+
"phpstan": "Runs static analysis with PHPStan",
56+
"phpunit": "Runs tests with PHPUnit",
57+
"test": "Runs static analysis and test suites"
58+
}
59+
}

‎phpstan.neon.dist

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
level: max
3+
4+
paths:
5+
- src/
6+
- tests/

‎phpunit.xml.dist

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
>
7+
<testsuites>
8+
<testsuite name="Tests">
9+
<directory>tests</directory>
10+
</testsuite>
11+
</testsuites>
12+
13+
<coverage processUncoveredFiles="true">
14+
<include>
15+
<directory suffix=".php">src</directory>
16+
</include>
17+
</coverage>
18+
19+
</phpunit>

‎src/Placeholder.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Beste\PhpCsFixer;
6+
7+
final class Placeholder
8+
{
9+
private string $prefix;
10+
11+
public function __construct(string $prefix)
12+
{
13+
$this->prefix = $prefix;
14+
}
15+
16+
public function echo(string $value): string
17+
{
18+
return $this->prefix . $value;
19+
}
20+
}

‎tests/PlaceholderTest.php

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Beste\PhpCsFixer\Tests;
6+
7+
use Beste\PhpCsFixer\Placeholder;
8+
use PHPUnit\Framework\TestCase;
9+
10+
/**
11+
* @internal
12+
* @covers \Beste\PhpCsFixer\Placeholder
13+
*/
14+
final class PlaceholderTest extends TestCase
15+
{
16+
private Placeholder $placeholder;
17+
18+
protected function setUp(): void
19+
{
20+
$this->placeholder = new Placeholder('Jérôme Gamez says: ');
21+
}
22+
23+
public function testItEchoesAValue(): void
24+
{
25+
self::assertSame('Jérôme Gamez says: Hello', $this->placeholder->echo('Hello'));
26+
}
27+
}

0 commit comments

Comments
 (0)