Skip to content

Commit

Permalink
updating tools (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Idrinth committed Aug 14, 2020
1 parent 078c9c0 commit c265658
Show file tree
Hide file tree
Showing 19 changed files with 358 additions and 242 deletions.
78 changes: 78 additions & 0 deletions .phan/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

return [
'pretend_newer_core_functions_exist' => false,
'guess_unknown_parameter_type_using_default' => true,
'allow_overriding_vague_return_types' => true,
'infer_default_properties_in_construct' => true,
'enable_extended_internal_return_type_plugins' => true,
'dead_code_detection' => true,
'unused_variable_detection' => true,
'force_tracking_references' => true,
'redundant_condition_detection' => true,
'error_prone_truthy_condition_detection' => true,
'warn_about_redundant_use_namespaced_class' => true,
'simplify_ast' => true,
'generic_types_enabled' => true,
'exclude_file_regex' => '@^vendor/phalcon/ide-stubs/|vendor/.*/Test.php@',
'enable_include_path_checks' => true,
'directory_list' => [
'src',
'vendor',
// @todo reactivate
//'test',
],
'enable_class_alias_support' => true,
'analyzed_file_extensions' => ['php'],
'exclude_analysis_directory_list' => [
'vendor/'
],
'skip_slow_php_options_warning' => false,
'ignore_undeclared_functions_with_known_signatures' => false,
'plugin_config' => [
'has_phpdoc_check_duplicates' => true,
'empty_statement_list_ignore_todos' => true,
'infer_pure_methods' => true,
'regex_warn_if_newline_allowed_at_end' => true,
],
'suppress_issue_types' => [
'PhanPluginRedundantReturnComment',
'PhanPluginRedundantMethodComment',
'PhanPluginRedundantClosureComment',
'PhanUnreferencedPublicMethod',
'PhanPluginDescriptionlessCommentOnPrivateProperty',
'PhanPluginCanUsePHP71Void',
'PhanUnreferencedClosure',
'PhanPluginPossiblyStaticPrivateMethod',
'PhanPluginPossiblyStaticClosure',
//@ todo reactivate

],
'plugins' => [
'AlwaysReturnPlugin',
'DollarDollarPlugin',
'UnreachableCodePlugin',
'DuplicateArrayKeyPlugin',
'PrintfCheckerPlugin',
'PHPUnitAssertionPlugin',
'UseReturnValuePlugin',
'UnknownElementTypePlugin',
'DuplicateExpressionPlugin',
'WhitespacePlugin',
'InlineHTMLPlugin',
'PossiblyStaticMethodPlugin',
'HasPHPDocPlugin',
'PHPDocToRealTypesPlugin',
'PHPDocRedundantPlugin',
'PreferNamespaceUsePlugin',
'EmptyStatementListPlugin',
'EmptyMethodAndFunctionPlugin',
'LoopVariableReusePlugin',
'RedundantAssignmentPlugin',
'StrictComparisonPlugin',
'StrictLiteralComparisonPlugin',
'ShortArrayPlugin',
'SimplifyExpressionPlugin',
'RemoveDebugStatementPlugin',
],
];
107 changes: 28 additions & 79 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ cache:
- ~/cphalcon
jobs:
include:

# PHP Linting
- stage: PHP Linting
php: 7.3
name: PHP 7.3
php: 7.4
name: PHP 7.4
before_install:
- phpenv config-rm xdebug.ini || true
- mkdir ../tools && composer init --name=putg/tools --working-dir=../tools
Expand Down Expand Up @@ -43,33 +44,41 @@ jobs:
install: true
script:
- ../tools/vendor/bin/parallel-lint --exclude vendor .
- stage: PHP Linting
php: 7.1
name: PHP 7.1

# Static Code Analysis
- stage: Static Code Analysis
php: 7.4
name: "PHP Codesniffer: PSR12"
before_install:
- phpenv config-rm xdebug.ini || true
- mkdir ../tools && composer init --name=putg/tools --working-dir=../tools
- composer require jakub-onderka/php-parallel-lint:^1 --working-dir=../tools
- composer require squizlabs/php_codesniffer:^3.5.6 --working-dir=../tools
install: true
script:
- ../tools/vendor/bin/parallel-lint --exclude vendor .
- stage: PHP Linting
php: 7.0
name: PHP 7.0
- ../tools/vendor/bin/phpcs -p --standard=PSR12 .
- stage: Static Code Analysis
php: 7.4
name: PHAN@4
before_install:
- phpenv config-rm xdebug.ini || true
- mkdir ../tools && composer init --name=putg/tools --working-dir=../tools
- composer require jakub-onderka/php-parallel-lint:^1 --working-dir=../tools
install: true
- composer require phan/phan --working-dir=../tools
- pecl install psr
- pecl install ast
- sh install-phalcon.sh
install:
- composer update
script:
- ../tools/vendor/bin/parallel-lint --exclude vendor .
- ../tools/vendor/bin/phan

# Unit Tests
- stage: Test
php: 7.4
name: PHP 7.4
before_install:
- mkdir ../tools && composer init --name=putg/tools --working-dir=../tools
- composer require codacy/coverage:dev-master --working-dir=../tools
- pecl install psr
- sh install-phalcon.sh
install:
- composer update
Expand All @@ -82,6 +91,7 @@ jobs:
before_install:
- mkdir ../tools && composer init --name=putg/tools --working-dir=../tools
- composer require codacy/coverage:dev-master --working-dir=../tools
- pecl install psr
- sh install-phalcon.sh
install:
- composer update
Expand All @@ -94,85 +104,23 @@ jobs:
before_install:
- mkdir ../tools && composer init --name=putg/tools --working-dir=../tools
- composer require codacy/coverage:dev-master --working-dir=../tools
- pecl install psr
- sh install-phalcon.sh
install:
- composer update
script:
- vendor/bin/phpunit --testdox --coverage-text --coverage-clover clover.xml --whitelist src/ test/
- ../tools/vendor/bin/codacycoverage clover clover.xml
- stage: Test
php: 7.1
name: PHP 7.1
before_install:
- phpenv config-rm xdebug.ini || true
- sh install-phalcon.sh
install:
- composer update
script:
- vendor/bin/phpunit --testdox test/
- stage: Test
php: 7.0
name: PHP 7.0
before_install:
- phpenv config-rm xdebug.ini || true
- sh install-phalcon.sh
install:
- composer update
script:
- vendor/bin/phpunit --testdox test/
# Static Code Analysis
- stage: Static Code Analysis
php: 7.4
name: PHP Assumptions
before_install:
- phpenv config-rm xdebug.ini || true
- mkdir ../tools && composer init --name=putg/tools --working-dir=../tools
- composer require rskuipers/php-assumptions:^0.7.0 --working-dir=../tools
- sh install-phalcon.sh
install: composer update
script:
- ../tools/vendor/bin/phpa --exclude=./vendor ./
- stage: Static Code Analysis
php: 7.4
name: "PHP Codesniffer: PSR2"
before_install:
- phpenv config-rm xdebug.ini || true
- mkdir ../tools && composer init --name=putg/tools --working-dir=../tools
- composer require squizlabs/php_codesniffer:^3.2.2 --working-dir=../tools
install: true
script:
- ../tools/vendor/bin/phpcs -p --standard=PSR2 .
- stage: Static Code Analysis
php: 7.4
name: Composer Require Checker
before_install:
- phpenv config-rm xdebug.ini || true
- mkdir ../tools && composer init --name=putg/tools --working-dir=../tools
- composer config repositories.maglnet/composer-require-checker '{"type":"vcs","url":"https://github.com/idrinth/ComposerRequireChecker","no-api":true}' --working-dir=../tools && composer require maglnet/composer-require-checker:dev-bandaid --working-dir=../tools
- sh install-phalcon.sh
install: composer update
script:
- ../tools/vendor/bin/composer-require-checker check --register-namespace=nikic/php-parser:PhpParser\\:lib/PhpParser ./composer.json
- stage: Static Code Analysis
php: 7.4
name: PHPstan
before_install:
- phpenv config-rm xdebug.ini || true
- mkdir ../tools && composer init --name=putg/tools --working-dir=../tools
- composer require phpstan/phpstan:^0.11 phpstan/phpstan-phpunit phpstan/phpstan-strict-rules:^0.11 --working-dir=../tools
- sh install-phalcon.sh
install:
- composer update
script:
- ../tools/vendor/bin/phpstan analyse --level max src test

# Pre-Tag
- stage: Pre-Tag
php: 7.4
name: PHPmetrics
before_install:
- phpenv config-rm xdebug.ini || true
- mkdir ../tools && composer init --name=putg/tools --working-dir=../tools
- composer require phpmetrics/phpmetrics:^2.4.1 --working-dir=../tools
- composer require phpmetrics/phpmetrics:^2.7.4 --working-dir=../tools
- pecl install psr
- sh install-phalcon.sh
install:
- composer update
Expand All @@ -185,6 +133,7 @@ jobs:
- phpenv config-rm xdebug.ini || true
- mkdir ../tools && composer init --name=putg/tools --working-dir=../tools
- composer create-project tomzx/php-semver-checker-git:^0.7 --working-dir=../tools
- pecl install psr
- sh install-phalcon.sh
install: composer update
script:
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
],
"require": {
"php": "^7",
"ext-phalcon": "^3.2",
"ext-phalcon": "^4",
"ext-json": "*",
"phpdocumentor/reflection-docblock": "^4.3.0"
"phpdocumentor/reflection-docblock": "^4.3.0",
"ocramius/package-versions": "^1 <1.10"
},
"autoload": {
"psr-4": {
Expand Down
21 changes: 18 additions & 3 deletions install-phalcon.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
#!/bin/sh

mkdir tmp && \
mv composer.json tmp/ && \
composer require --dev techpivot/phalcon-ci-installer && \
vendor/bin/install-phalcon.sh 3.2.x && \

git clone git://github.com/phalcon/php-zephir-parser.git && \
cd php-zephir-parser && \
phpize && \
./configure && \
make && \
make install && \
echo "extension = zephir_parser.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini &&\
cd .. && \

composer init --name tmp/tmp && \
composer config repositories.phalcon-zephir-update '{"type":"vcs","url":"https://github.com/idrinth/phalcon-ci-installer","no-api":true}' && \
composer require --dev techpivot/phalcon-ci-installer:dev-patch-1 && \
vendor/bin/install-phalcon.sh 4.0.x && \

rm composer.lock && \
rm composer.json && \
mv tmp/composer.json ./ && \
rmdir tmp
rmdir tmp && \
rm -rf php-zephir-parser
10 changes: 0 additions & 10 deletions phpstan.neon.dist

This file was deleted.

17 changes: 13 additions & 4 deletions src/Implementations/Controller.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace De\Idrinth\PhalconRoutes2OpenApi\Implementations;

Expand All @@ -9,7 +11,10 @@
use Phalcon\Http\ResponseInterface;
use Phalcon\Mvc\Controller as PhalconController;

class Controller extends PhalconController implements ControllerInterface
/**
* This is the controller, that handles all requests related to the index route
*/
final class Controller extends PhalconController implements ControllerInterface
{
/**
* Generates an overview over routes registered
Expand All @@ -27,10 +32,11 @@ public function index(): ResponseInterface
->getCorsEnabledResponse()
->setJsonContent(
[
'openapi' => '3.0.1',
'paths' => $this->di->get(RMI::class)->mergeAll(...$paths),
'info' => [
"title"=> Versions::ROOT_PACKAGE_NAME,
"version"=> Versions::getVersion(Versions::ROOT_PACKAGE_NAME)
"title" => Versions::ROOT_PACKAGE_NAME,
"version" => Versions::getVersion(Versions::ROOT_PACKAGE_NAME)
]
]
);
Expand All @@ -48,6 +54,7 @@ public function indexAction(): ResponseInterface

/**
* Generates an overview over routes registered
* @suppress PhanPluginDuplicateMethodDescription
* @return-204 {"type":"string","maxLength":0}
* @return ResponseInterface
*/
Expand All @@ -60,6 +67,7 @@ public function options(): ResponseInterface

/**
* Generates an overview over routes registered
* @suppress PhanPluginDuplicateMethodDescription
* @return-204 {"type":"string","maxLength":0}
* @return ResponseInterface
*/
Expand All @@ -69,6 +77,7 @@ public function optionsAction(): ResponseInterface
}

/**
* Return the Response with added Cross-Origin-Resource-Sharing-Headers
* @return ResponseInterface
*/
private function getCorsEnabledResponse(): ResponseInterface
Expand Down
16 changes: 11 additions & 5 deletions src/Implementations/DefaultResponse.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace De\Idrinth\PhalconRoutes2OpenApi\Implementations;

use stdClass;

class DefaultResponse
/**
* Provides a default route for not correctly defined methods
*/
final class DefaultResponse
{
/**
* @param array $route
* @return array
* Add a defaul response of 200 to paths without a defined one
* @param string[]|array[] $route
* @return string[]|array[]
*/
public static function add(array $route): array
{
if (!isset($route['responses']) || count($route['responses']) === 0) {
$route['responses'] = [
'200' => [
"description" => 'unknown return',
'description' => 'unknown return',
'content' => [
'*/*' => [
'schema' => new stdClass()
Expand Down

0 comments on commit c265658

Please sign in to comment.