Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cesargb authored Oct 20, 2023
0 parents commit 892c559
Show file tree
Hide file tree
Showing 13 changed files with 302 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
14 changes: 14 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.php_cs.dist export-ignore
/psalm.xml export-ignore
/psalm.xml.dist export-ignore
/testbench.yaml export-ignore
37 changes: 37 additions & 0 deletions .github/workflows/analyse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: analyse

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
phpstan:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-8.2-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-8.2-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: |
composer install
composer dump
- name: Run analyse phpstan
run: vendor/bin/phpstan analyse --error-format github
38 changes: 38 additions & 0 deletions .github/workflows/fix_style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Fix Styles

on:
push:
branches: [master]

jobs:
style:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-8.2-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-8.2
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: |
composer install
composer dump
- name: Fix styles
run: vendor/bin/php-cs-fixer fix

- name: Run style
run: vendor/bin/php-cs-fixer fix --dry-run --diff --format junit

- uses: EndBug/add-and-commit@v9
47 changes: 47 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: tests

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
phpunit:

runs-on: ubuntu-latest

strategy:
matrix:
php: [8.2, 8.1, 8.0]

name: PHP${{ matrix.php }}

steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: |
composer install
composer dump
- name: Run test phpunit
run: composer test
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/vendor
/build
/composer.lock
/.php_cs.cache
/.phpunit.result.cache
/.php-cs-fixer.cache
41 changes: 41 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

$finder = Symfony\Component\Finder\Finder::create()
->in([
__DIR__.'/src',
__DIR__.'/tests',
])
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
'method' => 'one',
],
],
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'single_trait_insert_per_statement' => true,
'php_unit_method_casing' => ['case' => 'camel_case'],
])
->setFinder($finder);
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# php-skeleton

## Install

Via Composer

```bash
composer require descom/package_name
```

## Usage

```php
$skeleton = new Descom\Skeleton\SkeletonClass;
```

## Testing

``` bash
composer test
```
39 changes: 39 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "descom/skeleton",
"description": "package_description",
"type": "library",
"require": {
"php": "^8.0"
},
"homepage": "https://github.com/descom/skeleton",
"license": "MIT",
"authors": [
{
"name": "Cesar Garcia",
"email": "cesar@descom.es",
"role": "Developer"
}
],
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true,
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.4",
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.9"
},
"autoload": {
"psr-4": {
"Descom\\Skeleton\\": "src"
}
},
"scripts": {
"test": "vendor/bin/phpunit --colors=always",
"style": "vendor/bin/php-cs-fixer fix",
"analyse": "vendor/bin/phpstan analyse"
}
}
10 changes: 10 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
parameters:

paths:
- src
- tests

# The level 9 is the highest level
level: 5

checkMissingIterableValueType: false
13 changes: 13 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="League Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
8 changes: 8 additions & 0 deletions src/Skeleton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Descom\Skeleton;

class Skeleton
{
//
}
13 changes: 13 additions & 0 deletions tests/SkeletonTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Descom\Skeleton\Test;

use PHPUnit\Framework\TestCase;

class SkeletonTest extends TestCase
{
public function testExample()
{
$this->assertTrue(true);
}
}

0 comments on commit 892c559

Please sign in to comment.