mirror of
https://github.com/archtechx/livewire-access.git
synced 2025-12-11 20:04:03 +00:00
Initial commit
This commit is contained in:
commit
a29235253b
13 changed files with 487 additions and 0 deletions
13
.gitattributes
vendored
Normal file
13
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/.github export-ignore
|
||||
/.gitattributes export-ignore
|
||||
/.gitignore export-ignore
|
||||
|
||||
/docker-compose.yml export-ignore
|
||||
/tests export-ignore
|
||||
|
||||
/phpstan.neon export-ignore
|
||||
/.php_cs.php export-ignore
|
||||
/psalm.xml export-ignore
|
||||
/phpunit.xml export-ignore
|
||||
/check export-ignore
|
||||
/coverage export-ignore
|
||||
64
.github/workflows/ci.yml
vendored
Normal file
64
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
name: CI
|
||||
|
||||
env:
|
||||
COMPOSE_INTERACTIVE_NO_CLI: 1
|
||||
PHP_CS_FIXER_IGNORE_ENV: 1
|
||||
MYSQL_PORT: 3307
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
phpunit:
|
||||
name: Tests (PHPUnit)
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Start docker containers
|
||||
run: docker-compose up -d
|
||||
- name: Install composer dependencies
|
||||
run: composer install
|
||||
- name: Run tests
|
||||
run: vendor/bin/phpunit
|
||||
|
||||
psalm:
|
||||
name: Static analysis (Psalm)
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install composer dependencies
|
||||
run: composer install
|
||||
- name: Run psalm
|
||||
run: vendor/bin/psalm
|
||||
|
||||
phpstan:
|
||||
name: Static analysis (PHPStan)
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install composer dependencies
|
||||
run: composer install
|
||||
- name: Run phpstan
|
||||
run: vendor/bin/phpstan analyse
|
||||
|
||||
php-cs-fixer:
|
||||
name: Code style (php-cs-fixer)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install php-cs-fixer
|
||||
run: composer global require friendsofphp/php-cs-fixer
|
||||
- name: Run php-cs-fixer
|
||||
run: $HOME/.composer/vendor/bin/php-cs-fixer fix --config=.php_cs.php
|
||||
- name: Commit changes from php-cs-fixer
|
||||
uses: EndBug/add-and-commit@v5
|
||||
with:
|
||||
author_name: Samuel Štancl
|
||||
author_email: samuel.stancl@gmail.com
|
||||
message: Fix code style (php-cs-fixer)
|
||||
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
.phpunit.result.cache
|
||||
package-lock.json
|
||||
composer.lock
|
||||
vendor/
|
||||
.php_cs.cache
|
||||
.vscode/
|
||||
coverage/
|
||||
node_modules
|
||||
143
.php_cs.php
Normal file
143
.php_cs.php
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
use PhpCsFixer\Config;
|
||||
use PhpCsFixer\Finder;
|
||||
|
||||
$rules = [
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'binary_operator_spaces' => [
|
||||
'default' => 'single_space',
|
||||
'operators' => ['=>' => null]
|
||||
],
|
||||
'blank_line_after_namespace' => true,
|
||||
'blank_line_after_opening_tag' => true,
|
||||
'blank_line_before_statement' => [
|
||||
'statements' => ['return']
|
||||
],
|
||||
'braces' => true,
|
||||
'cast_spaces' => true,
|
||||
'class_attributes_separation' => [
|
||||
'elements' => ['method']
|
||||
],
|
||||
'class_definition' => true,
|
||||
'concat_space' => [
|
||||
'spacing' => 'one'
|
||||
],
|
||||
'declare_equal_normalize' => true,
|
||||
'elseif' => true,
|
||||
'encoding' => true,
|
||||
'full_opening_tag' => true,
|
||||
'declare_strict_types' => true,
|
||||
'fully_qualified_strict_types' => true, // added by Shift
|
||||
'function_declaration' => true,
|
||||
'function_typehint_space' => true,
|
||||
'heredoc_to_nowdoc' => true,
|
||||
'include' => true,
|
||||
'increment_style' => ['style' => 'post'],
|
||||
'indentation_type' => true,
|
||||
'linebreak_after_opening_tag' => true,
|
||||
'line_ending' => true,
|
||||
'lowercase_cast' => true,
|
||||
'lowercase_constants' => true,
|
||||
'lowercase_keywords' => true,
|
||||
'lowercase_static_reference' => true, // added from Symfony
|
||||
'magic_method_casing' => true, // added from Symfony
|
||||
'magic_constant_casing' => true,
|
||||
'method_argument_space' => true,
|
||||
'native_function_casing' => true,
|
||||
'no_alias_functions' => true,
|
||||
'no_extra_blank_lines' => [
|
||||
'tokens' => [
|
||||
'extra',
|
||||
'throw',
|
||||
'use',
|
||||
'use_trait',
|
||||
]
|
||||
],
|
||||
'no_blank_lines_after_class_opening' => true,
|
||||
'no_blank_lines_after_phpdoc' => true,
|
||||
'no_closing_tag' => true,
|
||||
'no_empty_phpdoc' => true,
|
||||
'no_empty_statement' => true,
|
||||
'no_leading_import_slash' => true,
|
||||
'no_leading_namespace_whitespace' => true,
|
||||
'no_mixed_echo_print' => [
|
||||
'use' => 'echo'
|
||||
],
|
||||
'no_multiline_whitespace_around_double_arrow' => true,
|
||||
'multiline_whitespace_before_semicolons' => [
|
||||
'strategy' => 'no_multi_line'
|
||||
],
|
||||
'no_short_bool_cast' => true,
|
||||
'no_singleline_whitespace_before_semicolons' => true,
|
||||
'no_spaces_after_function_name' => true,
|
||||
'no_spaces_around_offset' => true,
|
||||
'no_spaces_inside_parenthesis' => true,
|
||||
'no_trailing_comma_in_list_call' => true,
|
||||
'no_trailing_comma_in_singleline_array' => true,
|
||||
'no_trailing_whitespace' => true,
|
||||
'no_trailing_whitespace_in_comment' => true,
|
||||
'no_unneeded_control_parentheses' => true,
|
||||
'no_unreachable_default_argument_value' => true,
|
||||
'no_useless_return' => true,
|
||||
'no_whitespace_before_comma_in_array' => true,
|
||||
'no_whitespace_in_blank_line' => true,
|
||||
'normalize_index_brace' => true,
|
||||
'not_operator_with_successor_space' => true,
|
||||
'object_operator_without_whitespace' => true,
|
||||
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
|
||||
'phpdoc_indent' => true,
|
||||
'phpdoc_inline_tag' => true,
|
||||
'phpdoc_no_access' => true,
|
||||
'phpdoc_no_package' => true,
|
||||
'phpdoc_no_useless_inheritdoc' => true,
|
||||
'phpdoc_scalar' => true,
|
||||
'phpdoc_single_line_var_spacing' => true,
|
||||
'phpdoc_summary' => true,
|
||||
'phpdoc_to_comment' => true,
|
||||
'phpdoc_trim' => true,
|
||||
'phpdoc_types' => true,
|
||||
'phpdoc_var_without_name' => true,
|
||||
'psr4' => true,
|
||||
'self_accessor' => true,
|
||||
'short_scalar_cast' => true,
|
||||
'simplified_null_return' => false, // disabled by Shift
|
||||
'single_blank_line_at_eof' => true,
|
||||
'single_blank_line_before_namespace' => true,
|
||||
'single_class_element_per_statement' => true,
|
||||
'single_import_per_statement' => true,
|
||||
'single_line_after_imports' => true,
|
||||
'no_unused_imports' => true,
|
||||
'single_line_comment_style' => [
|
||||
'comment_types' => ['hash']
|
||||
],
|
||||
'single_quote' => true,
|
||||
'space_after_semicolon' => true,
|
||||
'standardize_not_equals' => true,
|
||||
'switch_case_semicolon_to_colon' => true,
|
||||
'switch_case_space' => true,
|
||||
'ternary_operator_spaces' => true,
|
||||
'trailing_comma_in_multiline_array' => true,
|
||||
'trim_array_spaces' => true,
|
||||
'unary_operator_spaces' => true,
|
||||
'visibility_required' => [
|
||||
'elements' => ['method', 'property']
|
||||
],
|
||||
'whitespace_after_comma_in_array' => true,
|
||||
];
|
||||
|
||||
$project_path = getcwd();
|
||||
$finder = Finder::create()
|
||||
->in([
|
||||
$project_path . '/src',
|
||||
])
|
||||
->name('*.php')
|
||||
->notName('*.blade.php')
|
||||
->ignoreDotFiles(true)
|
||||
->ignoreVCS(true);
|
||||
|
||||
return Config::create()
|
||||
->setFinder($finder)
|
||||
->setRules($rules)
|
||||
->setRiskyAllowed(true)
|
||||
->setUsingCache(true);
|
||||
31
README.md
Normal file
31
README.md
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Package
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
composer require stancl/package
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```php
|
||||
// ...
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
Running all checks locally:
|
||||
|
||||
```sh
|
||||
./check
|
||||
```
|
||||
|
||||
Running tests:
|
||||
|
||||
```sh
|
||||
MYSQL_PORT=3307 docker-compose up -d
|
||||
|
||||
phpunit
|
||||
```
|
||||
|
||||
Code style will be automatically fixed by php-cs-fixer.
|
||||
63
check
Executable file
63
check
Executable file
|
|
@ -0,0 +1,63 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
offer_run() {
|
||||
read -p "For more output, run $1. Run it now (Y/n)? " run
|
||||
|
||||
case ${run:0:1} in
|
||||
n|N )
|
||||
exit 1
|
||||
;;
|
||||
* )
|
||||
$1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (php-cs-fixer fix --dry-run --config=.php_cs.php > /dev/null 2>/dev/null); then
|
||||
echo '✅ php-cs-fixer OK'
|
||||
else
|
||||
read -p "⚠️ php-cs-fixer found issues. Fix (Y/n)? " fix
|
||||
case ${fix:0:1} in
|
||||
n|N )
|
||||
echo '❌ php-cs-fixer FAIL'
|
||||
offer_run 'php-cs-fixer fix --config=.php_cs.php'
|
||||
;;
|
||||
* )
|
||||
if (php-cs-fixer fix --config=.php_cs.php > /dev/null 2>/dev/null); then
|
||||
echo '✅ php-cs-fixer OK'
|
||||
else
|
||||
echo '❌ php-cs-fixer FAIL'
|
||||
offer_run 'php-cs-fixer fix --config=.php_cs.php'
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if (./vendor/bin/psalm > /dev/null 2>/dev/null); then
|
||||
echo '✅ Psalm OK'
|
||||
else
|
||||
echo '❌ Psalm FAIL'
|
||||
offer_run './vendor/bin/psalm'
|
||||
fi
|
||||
|
||||
if (./vendor/bin/phpstan analyse > /dev/null 2>/dev/null); then
|
||||
echo '✅ PHPStan OK'
|
||||
else
|
||||
echo '❌ PHPStan FAIL'
|
||||
offer_run './vendor/bin/phpstan analyse'
|
||||
fi
|
||||
|
||||
(MYSQL_PORT=3307 docker-compose up -d > /dev/null 2>/dev/null) || true
|
||||
|
||||
if (./vendor/bin/phpunit > /dev/null 2>/dev/null); then
|
||||
echo '✅ PHPUnit OK'
|
||||
else
|
||||
echo '❌ PHPUnit FAIL'
|
||||
offer_run './vendor/bin/phpunit'
|
||||
fi
|
||||
|
||||
echo '=================='
|
||||
echo '✅ Everything OK'
|
||||
37
composer.json
Normal file
37
composer.json
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"name": "stancl/package",
|
||||
"description": "",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Samuel Štancl",
|
||||
"email": "samuel.stancl@gmail.com"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Stancl\\Package\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Stancl\\Package\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"illuminate/support": "^8.24"
|
||||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": "^6.9",
|
||||
"vimeo/psalm": "^4.2",
|
||||
"nunomaduro/larastan": "^0.6.10"
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Stancl\\Package\\PackageServiceProvider"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
version: '3'
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: password
|
||||
MYSQL_DATABASE: main
|
||||
MYSQL_USER: user
|
||||
MYSQL_PASSWORD: password
|
||||
MYSQL_TCP_PORT: ${MYSQL_PORT}
|
||||
ports:
|
||||
- "${MYSQL_PORT}:${MYSQL_PORT}"
|
||||
25
phpstan.neon
Normal file
25
phpstan.neon
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
includes:
|
||||
- ./vendor/nunomaduro/larastan/extension.neon
|
||||
|
||||
parameters:
|
||||
paths:
|
||||
- src
|
||||
- tests
|
||||
|
||||
level: 8
|
||||
|
||||
universalObjectCratesClasses:
|
||||
- Illuminate\Routing\Route
|
||||
|
||||
ignoreErrors:
|
||||
# -
|
||||
# message: '#Offset (.*?) does not exist on array\|null#'
|
||||
# paths:
|
||||
# - tests/*
|
||||
# -
|
||||
# message: '#expects resource, resource\|false given#'
|
||||
# paths:
|
||||
# - tests/*
|
||||
# - '#should return \$this#'
|
||||
|
||||
checkMissingIterableValueType: false
|
||||
28
phpunit.xml
Normal file
28
phpunit.xml
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">./src</directory>
|
||||
</include>
|
||||
<report>
|
||||
<clover outputFile="coverage/phpunit/clover.xml"/>
|
||||
<html outputDirectory="coverage/phpunit/html" lowUpperBound="35" highLowerBound="70"/>
|
||||
</report>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="APP_KEY" value="base64:uYlmYxcuuO7dC34yUn2hQcPu8PnlC98LTyOZg4fNAZU="/>
|
||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||
<env name="CACHE_DRIVER" value="redis"/>
|
||||
<env name="MAIL_DRIVER" value="array"/>
|
||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="DB_CONNECTION" value="testbench"/>
|
||||
<env name="AWS_DEFAULT_REGION" value="us-west-2"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
15
psalm.xml
Normal file
15
psalm.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
errorLevel="7"
|
||||
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"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="src" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor" />
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
</psalm>
|
||||
32
src/PackageServiceProvider.php
Normal file
32
src/PackageServiceProvider.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Package;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class PackageServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
// $this->loadViewsFrom(__DIR__ . '/../assets/views', 'package');
|
||||
|
||||
// $this->publishes([
|
||||
// __DIR__ . '/../assets/views' => resource_path('views/vendor/package'),
|
||||
// ], 'package-views');
|
||||
|
||||
// $this->mergeConfigFrom(
|
||||
// __DIR__ . '/../assets/package.php',
|
||||
// 'package'
|
||||
// );
|
||||
|
||||
// $this->publishes([
|
||||
// __DIR__ . '/../assets/package.php' => config_path('package.php'),
|
||||
// ], 'package-config');
|
||||
}
|
||||
}
|
||||
16
tests/TestCase.php
Normal file
16
tests/TestCase.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Package\Tests;
|
||||
|
||||
use Orchestra\Testbench\TestCase as TestbenchTestCase;
|
||||
use Stancl\Package\PackageServiceProvider;
|
||||
|
||||
class TestCase extends TestbenchTestCase
|
||||
{
|
||||
protected function getPackageProviders($app)
|
||||
{
|
||||
return [
|
||||
PackageServiceProvider::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue