Skip to content

Commit 787d792

Browse files
committed
Initial commit
0 parents  commit 787d792

16 files changed

Lines changed: 752 additions & 0 deletions

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/.github export-ignore
2+
/.gitattributes export-ignore
3+
/.gitignore export-ignore
4+
5+
/docker-compose.yml export-ignore
6+
/tests export-ignore
7+
8+
/phpstan.neon export-ignore
9+
/.php_cs.php export-ignore
10+
/psalm.xml export-ignore
11+
/phpunit.xml export-ignore
12+
/check export-ignore
13+
/coverage export-ignore

.github/workflows/ci.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: CI
2+
3+
env:
4+
COMPOSE_INTERACTIVE_NO_CLI: 1
5+
PHP_CS_FIXER_IGNORE_ENV: 1
6+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7+
8+
on:
9+
push:
10+
pull_request:
11+
branches: [ master ]
12+
13+
jobs:
14+
phpunit:
15+
name: Tests (PHPUnit)
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Install composer dependencies
21+
run: composer install
22+
- name: Run tests
23+
run: vendor/bin/phpunit
24+
25+
psalm:
26+
name: Static analysis (Psalm)
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- uses: actions/checkout@v2
31+
- name: Install composer dependencies
32+
run: composer install
33+
- name: Run psalm
34+
run: vendor/bin/psalm
35+
36+
phpstan:
37+
name: Static analysis (PHPStan)
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- uses: actions/checkout@v2
42+
- name: Install composer dependencies
43+
run: composer install
44+
- name: Run phpstan
45+
run: vendor/bin/phpstan analyse
46+
47+
php-cs-fixer:
48+
name: Code style (php-cs-fixer)
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v2
52+
- name: Install php-cs-fixer
53+
run: composer global require friendsofphp/php-cs-fixer
54+
- name: Run php-cs-fixer
55+
run: $HOME/.composer/vendor/bin/php-cs-fixer fix --config=.php_cs.php
56+
- name: Commit changes from php-cs-fixer
57+
uses: EndBug/add-and-commit@v5
58+
with:
59+
author_name: Samuel Štancl
60+
author_email: samuel.stancl@gmail.com
61+
message: Fix code style (php-cs-fixer)

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.phpunit.result.cache
2+
package-lock.json
3+
composer.lock
4+
vendor/
5+
.php_cs.cache
6+
.vscode/
7+
coverage/
8+
node_modules

.php_cs.php

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?php
2+
3+
use PhpCsFixer\Config;
4+
use PhpCsFixer\Finder;
5+
6+
$rules = [
7+
'array_syntax' => ['syntax' => 'short'],
8+
'binary_operator_spaces' => [
9+
'default' => 'single_space',
10+
'operators' => ['=>' => null]
11+
],
12+
'blank_line_after_namespace' => true,
13+
'blank_line_after_opening_tag' => true,
14+
'blank_line_before_statement' => [
15+
'statements' => ['return']
16+
],
17+
'braces' => true,
18+
'cast_spaces' => true,
19+
'class_attributes_separation' => [
20+
'elements' => ['method']
21+
],
22+
'class_definition' => true,
23+
'concat_space' => [
24+
'spacing' => 'one'
25+
],
26+
'declare_equal_normalize' => true,
27+
'elseif' => true,
28+
'encoding' => true,
29+
'full_opening_tag' => true,
30+
'declare_strict_types' => true,
31+
'fully_qualified_strict_types' => true, // added by Shift
32+
'function_declaration' => true,
33+
'function_typehint_space' => true,
34+
'heredoc_to_nowdoc' => true,
35+
'include' => true,
36+
'increment_style' => ['style' => 'post'],
37+
'indentation_type' => true,
38+
'linebreak_after_opening_tag' => true,
39+
'line_ending' => true,
40+
'lowercase_cast' => true,
41+
'lowercase_constants' => true,
42+
'lowercase_keywords' => true,
43+
'lowercase_static_reference' => true, // added from Symfony
44+
'magic_method_casing' => true, // added from Symfony
45+
'magic_constant_casing' => true,
46+
'method_argument_space' => true,
47+
'native_function_casing' => true,
48+
'no_alias_functions' => true,
49+
'no_extra_blank_lines' => [
50+
'tokens' => [
51+
'extra',
52+
'throw',
53+
'use',
54+
'use_trait',
55+
]
56+
],
57+
'no_blank_lines_after_class_opening' => true,
58+
'no_blank_lines_after_phpdoc' => true,
59+
'no_closing_tag' => true,
60+
'no_empty_phpdoc' => true,
61+
'no_empty_statement' => true,
62+
'no_leading_import_slash' => true,
63+
'no_leading_namespace_whitespace' => true,
64+
'no_mixed_echo_print' => [
65+
'use' => 'echo'
66+
],
67+
'no_multiline_whitespace_around_double_arrow' => true,
68+
'multiline_whitespace_before_semicolons' => [
69+
'strategy' => 'no_multi_line'
70+
],
71+
'no_short_bool_cast' => true,
72+
'no_singleline_whitespace_before_semicolons' => true,
73+
'no_spaces_after_function_name' => true,
74+
'no_spaces_around_offset' => true,
75+
'no_spaces_inside_parenthesis' => true,
76+
'no_trailing_comma_in_list_call' => true,
77+
'no_trailing_comma_in_singleline_array' => true,
78+
'no_trailing_whitespace' => true,
79+
'no_trailing_whitespace_in_comment' => true,
80+
'no_unneeded_control_parentheses' => true,
81+
'no_unreachable_default_argument_value' => true,
82+
'no_useless_return' => true,
83+
'no_whitespace_before_comma_in_array' => true,
84+
'no_whitespace_in_blank_line' => true,
85+
'normalize_index_brace' => true,
86+
'not_operator_with_successor_space' => true,
87+
'object_operator_without_whitespace' => true,
88+
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
89+
'phpdoc_indent' => true,
90+
'phpdoc_inline_tag' => true,
91+
'phpdoc_no_access' => true,
92+
'phpdoc_no_package' => true,
93+
'phpdoc_no_useless_inheritdoc' => true,
94+
'phpdoc_scalar' => true,
95+
'phpdoc_single_line_var_spacing' => true,
96+
'phpdoc_summary' => true,
97+
'phpdoc_to_comment' => true,
98+
'phpdoc_trim' => true,
99+
'phpdoc_types' => true,
100+
'phpdoc_var_without_name' => true,
101+
'psr4' => true,
102+
'self_accessor' => true,
103+
'short_scalar_cast' => true,
104+
'simplified_null_return' => false, // disabled by Shift
105+
'single_blank_line_at_eof' => true,
106+
'single_blank_line_before_namespace' => true,
107+
'single_class_element_per_statement' => true,
108+
'single_import_per_statement' => true,
109+
'single_line_after_imports' => true,
110+
'no_unused_imports' => true,
111+
'single_line_comment_style' => [
112+
'comment_types' => ['hash']
113+
],
114+
'single_quote' => true,
115+
'space_after_semicolon' => true,
116+
'standardize_not_equals' => true,
117+
'switch_case_semicolon_to_colon' => true,
118+
'switch_case_space' => true,
119+
'ternary_operator_spaces' => true,
120+
'trailing_comma_in_multiline_array' => true,
121+
'trim_array_spaces' => true,
122+
'unary_operator_spaces' => true,
123+
'visibility_required' => [
124+
'elements' => ['method', 'property']
125+
],
126+
'whitespace_after_comma_in_array' => true,
127+
];
128+
129+
$project_path = getcwd();
130+
$finder = Finder::create()
131+
->in([
132+
$project_path . '/src',
133+
])
134+
->name('*.php')
135+
->notName('*.blade.php')
136+
->ignoreDotFiles(true)
137+
->ignoreVCS(true);
138+
139+
return Config::create()
140+
->setFinder($finder)
141+
->setRules($rules)
142+
->setRiskyAllowed(true)
143+
->setUsingCache(true);

check

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
set -e
3+
4+
offer_run() {
5+
read -p "For more output, run $1. Run it now (Y/n)? " run
6+
7+
case ${run:0:1} in
8+
n|N )
9+
exit 1
10+
;;
11+
* )
12+
$1
13+
;;
14+
esac
15+
16+
exit 1
17+
}
18+
19+
if (php-cs-fixer fix --dry-run --config=.php_cs.php > /dev/null 2>/dev/null); then
20+
echo '✅ php-cs-fixer OK'
21+
else
22+
read -p "⚠️ php-cs-fixer found issues. Fix (Y/n)? " fix
23+
case ${fix:0:1} in
24+
n|N )
25+
echo '❌ php-cs-fixer FAIL'
26+
offer_run 'php-cs-fixer fix --config=.php_cs.php'
27+
;;
28+
* )
29+
if (php-cs-fixer fix --config=.php_cs.php > /dev/null 2>/dev/null); then
30+
echo '✅ php-cs-fixer OK'
31+
else
32+
echo '❌ php-cs-fixer FAIL'
33+
offer_run 'php-cs-fixer fix --config=.php_cs.php'
34+
fi
35+
;;
36+
esac
37+
fi
38+
39+
if (./vendor/bin/psalm > /dev/null 2>/dev/null); then
40+
echo '✅ Psalm OK'
41+
else
42+
echo '❌ Psalm FAIL'
43+
offer_run './vendor/bin/psalm'
44+
fi
45+
46+
if (./vendor/bin/phpstan analyse > /dev/null 2>/dev/null); then
47+
echo '✅ PHPStan OK'
48+
else
49+
echo '❌ PHPStan FAIL'
50+
offer_run './vendor/bin/phpstan analyse'
51+
fi
52+
53+
(MYSQL_PORT=3307 docker-compose up -d > /dev/null 2>/dev/null) || true
54+
55+
if (./vendor/bin/phpunit > /dev/null 2>/dev/null); then
56+
echo '✅ PHPUnit OK'
57+
else
58+
echo '❌ PHPUnit FAIL'
59+
offer_run './vendor/bin/phpunit'
60+
fi
61+
62+
echo '=================='
63+
echo '✅ Everything OK'

composer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "leanadmin/installer",
3+
"description": "Installer for Lean Admin",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Samuel Štancl",
9+
"email": "samuel.stancl@gmail.com"
10+
}
11+
],
12+
"autoload": {
13+
"psr-4": {
14+
"Lean\\Installer\\": "src/"
15+
}
16+
},
17+
"require": {
18+
"php": "^7.2|^8.0",
19+
"illuminate/console": "^8.24",
20+
"illuminate/http": "^8.24",
21+
"illuminate/support": "^8.24",
22+
"illuminate/container": "^8.24"
23+
},
24+
"extra": {
25+
"laravel": {
26+
"providers": [
27+
"Lean\\Installer\\LeanInstallerProvider"
28+
]
29+
}
30+
},
31+
"require-dev": {
32+
"orchestra/testbench": "^6.9",
33+
"vimeo/psalm": "^4.2",
34+
"nunomaduro/larastan": "^0.6.10"
35+
}
36+
}

phpstan.neon

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
includes:
2+
- ./vendor/nunomaduro/larastan/extension.neon
3+
4+
parameters:
5+
paths:
6+
- src
7+
- tests
8+
9+
level: 8
10+
11+
universalObjectCratesClasses:
12+
- Illuminate\Routing\Route
13+
14+
ignoreErrors:
15+
# -
16+
# message: '#Offset (.*?) does not exist on array\|null#'
17+
# paths:
18+
# - tests/*
19+
# -
20+
# message: '#expects resource, resource\|false given#'
21+
# paths:
22+
# - tests/*
23+
# - '#should return \$this#'
24+
25+
checkMissingIterableValueType: false

phpunit.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage processUncoveredFiles="true">
4+
<include>
5+
<directory suffix=".php">./src</directory>
6+
</include>
7+
<report>
8+
<clover outputFile="coverage/phpunit/clover.xml"/>
9+
<html outputDirectory="coverage/phpunit/html" lowUpperBound="35" highLowerBound="70"/>
10+
</report>
11+
</coverage>
12+
<testsuites>
13+
<testsuite name="Unit">
14+
<directory suffix="Test.php">./tests</directory>
15+
</testsuite>
16+
</testsuites>
17+
<php>
18+
<env name="APP_ENV" value="testing"/>
19+
<env name="APP_KEY" value="base64:uYlmYxcuuO7dC34yUn2hQcPu8PnlC98LTyOZg4fNAZU="/>
20+
<env name="BCRYPT_ROUNDS" value="4"/>
21+
<env name="CACHE_DRIVER" value="redis"/>
22+
<env name="MAIL_DRIVER" value="array"/>
23+
<env name="QUEUE_CONNECTION" value="sync"/>
24+
<env name="SESSION_DRIVER" value="array"/>
25+
<env name="DB_CONNECTION" value="testbench"/>
26+
<env name="AWS_DEFAULT_REGION" value="us-west-2"/>
27+
</php>
28+
</phpunit>

0 commit comments

Comments
 (0)