Skip to content

Commit

Permalink
Merge pull request #7 from abbadon1334/upgrade-to-unit-8
Browse files Browse the repository at this point in the history
upgrade to phpunit8 + php7.2+
  • Loading branch information
abbadon1334 authored Jul 8, 2019
2 parents d7fcca7 + 81e363e commit 26244d5
Show file tree
Hide file tree
Showing 12 changed files with 441 additions and 1,737 deletions.
120 changes: 120 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
version: "2"
plugins:
# Disabling plugins until there is a reasonable way to sanitize their output
phpcodesniffer:
enabled: false
config:
standard: "PSR1,PSR2"
ignore_warnings: true
encoding: utf-8
phpmd:
enabled: false
sonar-php:
enabled: false

checks:
argument-count:
config:
threshold: 5
complex-logic:
config:
threshold: 4
file-lines:
config:
threshold: 1000
method-complexity:
config:
threshold: 50
method-count:
config:
threshold: 40
method-lines:
config:
threshold: 100
nested-control-flow:
config:
threshold: 4
return-statements:
config:
threshold: 7
similar-code:
config:
threshold: 100
identical-code:
config:
threshold: 150


#engines:
# duplication:
# enabled: true
# config:
# languages:
# php:
# mass_threshold: 50
# fixme:
# enabled: true
# phpmd:
# enabled: true
# exclude_fingerprints:
# - 9d462b7c90c564bf28007ee399340fad # table() NPath is too complex.
# - 7c90035f65bb3bdbd2c03c648a705aac # we use static for factory, so it's good
# - 80ef7f404dd4f054ca51d9ee12d9e9dd # we exit from toStrign() because it can't throw exceptions
# - ae61f5e0cda0328c140f3b7298dbb8af # don't complain about call to static connection, as it's a fallback
# - e71149b967391adfaf3347a53d3c0023 # don't complain about $junk used in foreach when we only need keys
# checks:
# CyclomaticComplexity: # because we solve complex stuff
# enabled: false
# Naming/LongVariable: # because we have variable naming patterns
# enabled: false
# UnusedFormalParameter: # because when we extend methods/hooks we wish to keep unified method call interface
# enabled: false
# Design/TooManyPublicMethods: # because we follow our internal design patters
# enabled: false
# Design/TooManyMethods: # because we solve complex stuff
# enabled: false
# Design/LongMethod: # because methods are as long as we need them to be
# enabled: false
# ExcessivePublicCount: # because Model has too many public methods
# enabled: false
# Design/TooManyFields: # because we solve complex things
# enabled: false
# Design/NpathComplexity: # because splitting up complex stuff into methods makes things even more complex
# enabled: false
# Design/WeightedMethodCount: # because we we solve complex stuff
# enabled: false
# Design/LongClass: # because we design carefully what is native and what is extension
# enabled: false
# Controversial/CamelCaseMethodName: # because we need certain method naming patterns, render_blah for rendering [blah]
# enabled: false
# Controversial/CamelCaseParameterName: #
# enabled: false
# Controversial/CamelCasePropertyName: # because we use _better_dont_change properties
# enabled: false
# Controversial/CamelCaseVariableName: #
# enabled: false
# Controversial/CamelCaseClassName: # Because we use Join_SQL where we specifically include _
# enabled: false
# Naming/ShortVariable: # because sometimes variables should be short
# enabled: false
# CleanCode/ElseExpression: # because following this makes code more complex
# enabled: false
#
# radon:
# enabled: true
#ratings:
# paths:
# - "src/**"
#exclude_paths:
#- "docs/**"
#- "tests/**"
#- "vendor/**"
## exclude obsolete classes
#- "src/Field_Many.php"
#- "src/Field_One.php"
#- "src/Field_SQL_One.php"
#- "src/Relation_Many.php"
#- "src/Relation_One.php"
#- "src/Relation_SQL_One.php"
## exclude classes completely inherited from other repos
#- "src/Exception.php"
6 changes: 6 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Set folder to clover (must be the same on travis)
coverage_clover: build/logs/clover.xml
# Same folder here
json_path: build/logs/coveralls-upload.json
# Don't touch that
service_name: travis-ci
105 changes: 105 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
/*
* This document has been generated with
* https://mlocati.github.io/php-cs-fixer-configurator/?version=2.15#configurator
* you can change this configuration by importing this file.
*/
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PSR1' => true,
'@PSR2' => true,
// Each line of multi-line DocComments must have an asterisk [PSR-5] and must be aligned with the first one.
'align_multiline_comment' => ['comment_type' => 'phpdocs_like'],
// PHP arrays should be declared using the configured syntax.
'array_syntax' => ['syntax' => 'short'],
// Binary operators should be surrounded by space as configured.
'binary_operator_spaces' => [
'align_double_arrow' => true,
'align_equals' => true
],
// An empty line feed should precede a return statement.
'blank_line_before_return' => true,
// Concatenation should be spaced according configuration.
'concat_space' => true,
// Equal sign in declare statement should be surrounded by spaces or not following configuration.
'declare_equal_normalize' => true,
// Force strict types declaration in all files.
// Requires PHP >= 7.0.
'declare_strict_types' => true,
// Transforms imported FQCN parameters and return types in function arguments to short version.
'fully_qualified_strict_types' => true,
// All instances created with new keyword must be followed by braces.
'new_with_braces' => true,
// There should not be blank lines between docblock and the documented element.
'no_blank_lines_after_phpdoc' => true,
// There should not be any empty comments.
'no_empty_comment' => true,
// There should not be empty PHPDoc blocks.
'no_empty_phpdoc' => true,
// Remove useless semicolon statements.
'no_empty_statement' => true,
// Remove trailing commas in list function calls.
'no_trailing_comma_in_list_call' => true,
// PHP single-line arrays should not have trailing comma.
'no_trailing_comma_in_singleline_array' => true,
// Removes unneeded curly braces that are superfluous and aren't part of a control structure's body.
'no_unneeded_curly_braces' => true,
// There should not be useless `else` cases.
'no_useless_else' => true,
// There should not be an empty `return` statement at the end of a function.
'no_useless_return' => true,
// Array index should always be written by using square braces.
'normalize_index_brace' => true,
// PHPDoc should contain `@param` for all params.
'phpdoc_add_missing_param_annotation' => true,
// All items of the given phpdoc tags must be either left-aligned or (by default) aligned vertically.
'phpdoc_align' => true,
// PHPDoc annotation descriptions should not be a sentence.
'phpdoc_annotation_without_dot' => true,
// Docblocks should have the same indentation as the documented subject.
'phpdoc_indent' => true,
// Fix PHPDoc inline tags, make `@inheritdoc` always inline.
'phpdoc_inline_tag' => true,
// `@access` annotations should be omitted from PHPDoc.
'phpdoc_no_access' => true,
// `@return void` and `@return null` annotations should be omitted from PHPDoc.
'phpdoc_no_empty_return' => true,
// `@package` and `@subpackage` annotations should be omitted from PHPDoc.
'phpdoc_no_package' => true,
// Classy that does not inherit must not have `@inheritdoc` tags.
'phpdoc_no_useless_inheritdoc' => true,
// Annotations in PHPDoc should be ordered so that `@param` annotations come first, then `@throws` annotations, then `@return` annotations.
'phpdoc_order' => true,
// Scalar types should always be written in the same form.
// `int` not `integer`, `bool` not `boolean`, `float` not `real` or `double`.
'phpdoc_scalar' => true,
// Single line `@var` PHPDoc should have proper spacing.
'phpdoc_single_line_var_spacing' => true,
// PHPDoc summary should end in either a full stop, exclamation mark, or question mark.
'phpdoc_summary' => true,
// Docblocks should only be used on structural elements.
'phpdoc_to_comment' => true,
// PHPDoc should start and end with content, excluding the very first and last line of the docblocks.
'phpdoc_trim' => true,
// The correct case must be used for standard PHP types in PHPDoc.
'phpdoc_types' => true,
// There should be one or no space before colon, and one space after it in return type declarations, according to configuration.
'return_type_declaration' => true,
// Replace all `<>` with `!=`.
'standardize_not_equals' => true,
// Comparisons should be strict.
'strict_comparison' => true,
// PHP multi-line arrays should have a trailing comma.
'trailing_comma_in_multiline_array' => true,
// Add void return type to functions with missing or empty return statements, but priority is given to `@return` annotations.
// Requires PHP >= 7.1.
'void_return' => true,
// Write conditions in Yoda style (`true`), non-Yoda style (`false`) or ignore those conditions (`null`) based on configuration.
'yoda_style' => true,
])
->setFinder(PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__)
)
;
16 changes: 16 additions & 0 deletions .phpmetrics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extensions": [
"php"
],
"exclude": [
"demos",
"infra",
"tests",
"composer",
"vendor",
"generated"
],
"report-xml": "./build/report/phpmetrics.xml",
"report-html": "./build/report/phpmetrics.html",
"report-csv": "./build/report/phpmetrics.csv"
}
7 changes: 7 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
preset: laravel

enabled:
- alpha_ordered_imports

disabled:
- length_ordered_imports
21 changes: 13 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
language: php

php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3

before_script:
- composer self-update
- composer install --prefer-source --dev
- curl -s http://getcomposer.org/installer | php
- php composer.phar install -n
- composer require satooshi/php-coveralls:~1.0@stable # Require phpCoveralls
- mkdir -p coverage/xml # Create a folder to store clover files #1
- mkdir -p build/logs # Create a folder to store clover files #2
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build

script:
- phpunit
- php vendor/bin/phpunit --coverage-clover build/logs/clover.xml

notifications:
email: false
after_script:
- php vendor/bin/codacycoverage clover build/logs/clover.xml
- sh -c 'if( [ "$TRAVIS_PHP_VERSION" != "hhvm" ] ); then php vendor/bin/coveralls -v; fi;'
- ./cc-test-reporter after-build --coverage-input-type clover --exit-code $TRAVIS_TEST_RESULT
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Sun-Position-SPA-php
SPA Sun Position Calc Library for PHP

PHPUNIT TEST PHP 5.6 - 7.0 ![Alt text](https://travis-ci.org/abbadon1334/sun-position-spa-php.svg?branch=master)
[![Build Status](https://travis-ci.org/abbadon1334/sun-position-spa-php.svg?branch=master)](https://travis-ci.org/abbadon1334/sun-position-spa-php)
[![Coverage Status](https://coveralls.io/repos/github/abbadon1334/sun-position-spa-php/badge.svg?branch=upgrade-to-unit-8)](https://coveralls.io/github/abbadon1334/sun-position-spa-php?branch=upgrade-to-unit-8)
[![Maintainability](https://api.codeclimate.com/v1/badges/fe0c85053b434e296254/maintainability)](https://codeclimate.com/github/abbadon1334/sun-position-spa-php/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/fe0c85053b434e296254/test_coverage)](https://codeclimate.com/github/abbadon1334/sun-position-spa-php/test_coverage)

This library is based on the work of Ibrahim Reda and Afshin Andreas
(SPA) Solar Position Algorithm for Solar Radiation Applications ( 2008 National Renewable Energy Laboratory )
Expand Down
54 changes: 51 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,71 @@
"name": "abbadon1334/sun-position-spa-php",
"description": "solar data calculation and sun position",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Francesco Danti",
"email": "fdanti@gmail.com"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=7.2"
},
"require-dev": {
"kint-php/kint": "2.2.0",
"phpunit/phpunit": "8.2.4"
"codacy/coverage": "dev-master",
"friendsofphp/php-cs-fixer": "dev-master@dev",
"phpmd/phpmd": "2.6.0",
"phpmetrics/phpmetrics": "dev-master@dev",
"phpstan/phpstan": "0.11.5",
"phpunit/phpunit": "*",
"squizlabs/php_codesniffer": "3.4.2",
"symfony/yaml": "~2.1|~3.0|~4.0"
},
"config": {
"sort-packages": true
},
"autoload": {
"psr-4": {
"SolarData\\": "src/",
"SolarData\\Tests\\": "tests/"
}
}
},
"scripts": {
"fix": "php-cs-fixer fix src",
"stan": "phpstan analyse src",
"stan1": "phpstan analyse --level 1 src",
"stan2": "phpstan analyse --level 2 src",
"stan3": "phpstan analyse --level 3 src",
"stan4": "phpstan analyse --level 4 src",
"stan5": "phpstan analyse --level 5 src",
"stan6": "phpstan analyse --level 6 src",
"stan7": "phpstan analyse --level 7 src",
"metrics": [
"mkdir -p ./build/report",
"mv ./build/report ./build/report_$(date +\"%Y.%m.%d_%H%M%S\")",
"phpmetrics --config=./.phpmetrics.json .",
"firefox ./build/report/phpmetrics.html/index.html"
],
"metrics-clear": [
"rm -rf ./build/report_*",
"rm -rf ./build/report"
],
"unit": [
"mkdir -p ./build/coverage",
"mv ./build/coverage ./build/coverage_$(date +\"%Y.%m.%d_%H%M%S\")",
"phpunit --configuration phpunit.xml"
],
"unit-html": [
"mkdir -p ./build/coverage",
"mv ./build/coverage ./build/coverage_$(date +\"%Y.%m.%d_%H%M%S\")",
"phpunit --configuration phpunit.xml --coverage-html ./build/coverage",
"firefox ./build/coverage/index.html"
],
"unit-clear": [
"rm -rf ./build/coverage_*",
"rm -rf ./build/coverage"
]
}
}
Loading

0 comments on commit 26244d5

Please sign in to comment.