Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jarektkaczyk committed Dec 5, 2020
1 parent 11452d6 commit d2e5dc1
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 111 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Tests

on: [push, pull_request]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [7.4]
dependency-version: [prefer-stable]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

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

- name: Install dependencies
run: |
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
mkdir -p build/logs
- name: Execute tests
run: |
vendor/bin/phpunit --coverage-clover build/logs/clover.xml
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=build/logs/clover.xml -v
71 changes: 71 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php


$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src/');

return PhpCsFixer\Config::create()
->setFinder($finder)
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'method_separation' => true,
'no_multiline_whitespace_before_semicolons' => true,
'single_quote' => true,
'blank_line_before_return' => true,
'combine_consecutive_issets' => true,
'compact_nullable_typehint' => true,
'concat_space' => array('spacing' => 'one'),
'declare_equal_normalize' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'include' => true,
'lowercase_cast' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_spaces_around_offset' => true,
'no_unused_imports' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true,
'php_unit_fqcn_annotation' => true,
'phpdoc_no_package' => true,
'phpdoc_scalar' => true,
'phpdoc_single_line_var_spacing' => true,
'protected_to_private' => true,
'return_assignment' => true,
'single_blank_line_before_namespace' => true,
'single_line_after_imports' => true,
'single_class_element_per_statement' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
'no_null_property_initialization' => true,
'binary_operator_spaces' => [
'default' => 'single_space',
],
'class_attributes_separation' => [
'elements' => ['method'],
],
'method_argument_space' => [
'keep_multiple_spaces_after_comma' => true,
],
'braces' => [
'allow_single_line_closure' => false,
'position_after_anonymous_constructs' => 'same',
'position_after_control_structures' => 'same',
'position_after_functions_and_oop_constructs' => 'next',
],
'no_extra_consecutive_blank_lines' => [
'curly_brace_block',
'extra',
'parenthesis_brace_block',
'square_brace_block',
'throw',
'use',
],
])
->setLineEnding("\n")
;
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Sofa/Eloquence

[![Build Status](https://travis-ci.org/jarektkaczyk/eloquence-validable.svg)](https://travis-ci.org/jarektkaczyk/eloquence-validable) [![Coverage Status](https://coveralls.io/repos/jarektkaczyk/eloquence-validable/badge.svg)](https://coveralls.io/r/jarektkaczyk/eloquence-validable) [![Code Quality](https://scrutinizer-ci.com/g/jarektkaczyk/eloquence-validable/badges/quality-score.png)](https://scrutinizer-ci.com/g/jarektkaczyk/eloquence-validable) [![Downloads](https://poser.pugx.org/sofa/eloquence-validable/downloads)](https://packagist.org/packages/sofa/eloquence-validable) [![stable](https://poser.pugx.org/sofa/eloquence-validable/v/stable.svg)](https://packagist.org/packages/sofa/eloquence-validable)
[![GitHub Tests Action Status](https://github.com/jarektkaczyk/eloquence-validable/workflows/Tests/badge.svg)](https://github.com/jarektkaczyk/eloquence-validable/actions?query=workflow%3Atests+branch%3Amaster) [![Coverage Status](https://coveralls.io/repos/jarektkaczyk/eloquence-validable/badge.svg)](https://coveralls.io/r/jarektkaczyk/eloquence-validable) [![Code Quality](https://scrutinizer-ci.com/g/jarektkaczyk/eloquence-validable/badges/quality-score.png)](https://scrutinizer-ci.com/g/jarektkaczyk/eloquence-validable) [![Downloads](https://poser.pugx.org/sofa/eloquence-validable/downloads)](https://packagist.org/packages/sofa/eloquence-validable) [![stable](https://poser.pugx.org/sofa/eloquence-validable/v/stable.svg)](https://packagist.org/packages/sofa/eloquence-validable)

Easy and flexible extensions for the [Eloquent ORM](https://laravel.com/docs/eloquent).

Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
}
],
"require": {
"php": ">=7.0.0",
"php": ">=7.1.0",
"sofa/eloquence-base": ">=5.5"
},
"require-dev": {
"phpunit/phpunit": "4.5.0",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "2.3.3",
"mockery/mockery": "0.9.4"
"mockery/mockery": "^1.0",
"friendsofphp/php-cs-fixer": "^2.0"
},
"autoload": {
"psr-4": {
Expand Down
31 changes: 18 additions & 13 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
verbose="true"
cacheResultFile=".phpunit.cache/test-results"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="Eloquence">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true"
ignoreDeprecatedCodeUnits="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>

<php>
<const name="PHPUNIT_TESTSUITE" value="true"/>
</php>
</phpunit>
12 changes: 6 additions & 6 deletions src/Validable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
use Illuminate\Contracts\Validation\Factory;

/**
* @method integer getKey()
* @method int getKey()
* @method string getKeyName()
*/
trait Validable
{
/**
* Validation switch.
*
* @var boolean
* @var bool
*/
protected $skipValidation = false;

Expand Down Expand Up @@ -60,7 +60,7 @@ public static function bootValidable()
/**
* Determine whether all the attributes on this instance pass validation.
*
* @return boolean
* @return bool
*/
public function isValid()
{
Expand Down Expand Up @@ -106,7 +106,7 @@ public function enableValidation()
/**
* Get current validation flag.
*
* @return integer|false
* @return int|false
*/
public function skipsValidation()
{
Expand All @@ -116,7 +116,7 @@ public function skipsValidation()
/**
* Determine whether validation is enabled for this instance.
*
* @return boolean
* @return bool
*/
public function validationEnabled()
{
Expand Down Expand Up @@ -264,7 +264,7 @@ public function getUpdateRules()
/**
* Get all validation rules for update for given id.
*
* @param \Illuminate\Database\Eloquent\Model|integer|string $id
* @param \Illuminate\Database\Eloquent\Model|int|string $id
* @return array
*/
public static function getUpdateRulesForId($id)
Expand Down
4 changes: 2 additions & 2 deletions src/Validable/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ class Observer
/**
* Validation skipping flag.
*
* @var integer
* @var int
*/
const SKIP_ONCE = 1;

/**
* Validation skipping flag.
*
* @var integer
* @var int
*/
const SKIP_ALWAYS = 2;

Expand Down
Loading

0 comments on commit d2e5dc1

Please sign in to comment.