Skip to content

Commit

Permalink
Merge branch 'basics' into 'master'
Browse files Browse the repository at this point in the history
Added basic library structure

See merge request iserv/lib/zeit!1
  • Loading branch information
althaus committed Mar 26, 2021
2 parents e22c255 + 16ea156 commit 5ddcd84
Show file tree
Hide file tree
Showing 13 changed files with 210 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
vendor/
.idea/
reports/
coverage/
tools/
.php_cs.cache
.phpunit.cache/
composer.lock

4 changes: 4 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include:
- project: 'iserv-internal/git/ci'
file: '/iserv-library.yml'

66 changes: 66 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
;

return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],

/**
* PSR-12 based on the official pull request on Github
* @see https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/4943/files#diff-1e418beac3b4a9cf60ecd4ca4e2975a8R59
*/
'blank_line_after_opening_tag' => true,
'braces' => [
// Added in later version
// 'allow_single_line_anonymous_class_with_empty_body' => true,
],
'compact_nullable_typehint' => true,
'declare_equal_normalize' => true,
'lowercase_cast' => true,
'lowercase_static_reference' => true,
'new_with_braces' => true,
'no_blank_lines_after_class_opening' => true,
'no_leading_import_slash' => true,
'no_whitespace_in_blank_line' => true,
'ordered_class_elements' => [
'order' => [
'use_trait',
],
],
'ordered_imports' => [
'imports_order' => [
'class',
'function',
'const',
],
'sort_algorithm' => 'none',
],
'return_type_declaration' => true,
'short_scalar_cast' => true,
'single_blank_line_before_namespace' => true,
'single_trait_insert_per_statement' => true,
'ternary_operator_spaces' => true,
'visibility_required' => [
'elements' => [
'const',
'method',
'property',
],
],

// More stricter rules than PSR-12
'concat_space' => ['spacing' => 'one'],
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'no_empty_statement' => true,

// Those rules are in discussion whether or not the PSR include these
'function_typehint_space' => true,
'no_leading_namespace_whitespace' => true,
])
->setFinder($finder)
;

10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## [Unreleased]

### Added

- Initial release of the IServ Zeit library.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Zeit
# IServ Zeit Library

[![coverage report](https://git.iserv.eu/iserv/lib/zeit/badges/master/coverage.svg)](https://git.iserv.eu/iserv/lib/zeit/commits/master)
[![pipeline status](https://git.iserv.eu/iserv/lib/zeit/badges/master/pipeline.svg)](https://git.iserv.eu/iserv/lib/zeit/commits/master)
22 changes: 22 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "iserv/zeit",
"description": "An all purpose library for date and time handling.",
"type": "library",
"require": {
"php": ">=7.3"
},
"autoload": {
"psr-4": {
"IServ\\Library\\Zeit\\": "src/"
}
},
"repositories": [
{
"type": "composer",
"url": "https://composer.iserv.eu"
}
],
"config": {
"sort-packages": true
}
}
8 changes: 8 additions & 0 deletions make.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
php
phpunit
psalm
phpstan
phpcsfixer
debug
help

7 changes: 7 additions & 0 deletions phive.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="^0.12" installed="0.12.82" location="./tools/phpstan.phar" copy="true"/>
<phar name="php-cs-fixer" version="^2.0" installed="2.18.4" location="./tools/php-cs-fixer.phar" copy="true"/>
<phar name="phpunit" version="^9.0" installed="9.5.3" location="./tools/phpunit.phar" copy="true"/>
<phar name="psalm" version="^4.0" installed="4.6.4" location="./tools/psalm.phar" copy="true"/>
</phive>
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
paths:
- src
level: 5
inferPrivatePropertyTypeFromConstructor: true
reportUnmatchedIgnoredErrors: false

26 changes: 26 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
15 changes: 15 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
13 changes: 13 additions & 0 deletions src/TestClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace IServ\Library\Zeit;

final class TestClass
{
public function returnsTrue(): bool
{
return true;
}
}
20 changes: 20 additions & 0 deletions tests/TestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace IServ\Library\Zeit\Tests;

use IServ\Library\Zeit\TestClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \IServ\Library\Zeit\TestClass
*/
final class TestTest extends TestCase
{
public function testTest(): void
{
$class = new TestClass();
$this->assertTrue($class->returnsTrue());
}
}

0 comments on commit 5ddcd84

Please sign in to comment.