Skip to content
This repository has been archived by the owner on Feb 23, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from take64/add_collection
Browse files Browse the repository at this point in the history
Initial Commit
  • Loading branch information
take64 authored Feb 22, 2020
2 parents 637ee67 + 17877e6 commit e1ea01e
Show file tree
Hide file tree
Showing 13 changed files with 858 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# IDE
/.idea

# composer
/vendor
composer.lock

# phpunit
.phpunit.result.cache
phpunit.tdx
67 changes: 67 additions & 0 deletions .phan/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

/**
* This configuration will be read and overlaid on top of the
* default configuration. Command line arguments will be applied
* after this file is read.
*/
return [

// Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `'7.4'`, `null`.
// If this is set to `null`,
// then Phan assumes the PHP version which is closest to the minor version
// of the php executable used to execute Phan.
"target_php_version" => null,

// A list of directories that should be parsed for class and
// method information. After excluding the directories
// defined in exclude_analysis_directory_list, the remaining
// files will be statically analyzed for errors.
//
// Thus, both first-party and third-party code being used by
// your application should be included in this list.
'directory_list' => [
'src',
],

// A directory list that defines files that will be excluded
// from static analysis, but whose class and method
// information should be included.
//
// Generally, you'll want to include the directories for
// third-party code (such as "vendor/") in this list.
//
// n.b.: If you'd like to parse but not analyze 3rd
// party code, directories containing that code
// should be added to the `directory_list` as
// to `exclude_analysis_directory_list`.
"exclude_analysis_directory_list" => [
'vendor/',
],

// A list of plugin files to execute.
// Plugins which are bundled with Phan can be added here by providing their name (e.g. 'AlwaysReturnPlugin')
//
// Documentation about available bundled plugins can be found
// at https://github.com/phan/phan/tree/master/.phan/plugins
//
// Alternately, you can pass in the full path to a PHP file
// with the plugin's implementation (e.g. 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php')
'plugins' => [
// checks if a function, closure or method unconditionally returns.
// can also be written as 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php'
'AlwaysReturnPlugin',
'DollarDollarPlugin',
'DuplicateArrayKeyPlugin',
'DuplicateExpressionPlugin',
'PregRegexCheckerPlugin',
'PrintfCheckerPlugin',
'SleepCheckerPlugin',
// Checks for syntactically unreachable statements in
// the global scope or function bodies.
'UnreachableCodePlugin',
'UseReturnValuePlugin',
// 'EmptyStatementListPlugin',
// 'LoopVariableReusePlugin',
],
];
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
DATE=`date +%Y-%m-%d`
DATETIME = `date +%Y-%m-%d_%H-%M-%S`

define highlight
@echo "\033[1;32m$1\033[0m"
endef

.PHONY: test_all
test_all:
@./vendor/bin/phpunit

.PHONY: composer_reload
composer_reload:
@composer clear-cache
@composer dump-autoload

.PHONY: composer_develop
composer_develop:
@composer install -vvv --dev --prefer-dist --optimize-autoloader

.PHONY: composer_public
composer_public:
@composer install -vvv --no-dev --prefer-dist --optimize-autoloader

.PHONY: composer_check
composer_check:
$(call highlight,#### ---- composer diag ---- ####)
@composer diag

.PHONY: phan
phan:
@mkdir -p ./phan/${DATE}
@./vendor/bin/phan --no-progress-bar --output ./.phan/${DATE}/${DATETIME}.txt

.PHONY: insights
insights:
@./vendor/bin/phpinsights analyse ./src

25 changes: 25 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "take64/citrus-collection",
"description": "php collection library",
"keywords": ["citrus", "php", "library", "collection"],
"type": "library",
"license": "MIT",
"authors": [
{
"name": "take64",
"email": "[email protected]"
}
],
"require": {},
"require-dev": {
"phpunit/phpunit": "^8.4",
"nunomaduro/phpinsights": "^v1.13",
"phan/phan": "^2.4"
},
"autoload": {
"psr-4": {
"Citrus\\": "src/",
"Test\\": "tests/"
}
}
}
62 changes: 62 additions & 0 deletions phpinsights.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);

return [
'preset' => 'default',
'exclude' => [
// 'path/to/directory-or-file'
],
'add' => [
// ExampleMetric::class => [
// ExampleInsight::class,
// ]
NunoMaduro\PhpInsights\Domain\Metrics\Code\Code::class => [
SlevomatCodingStandard\Sniffs\ControlStructures\RequireYodaComparisonSniff::class,
],
],
'remove' => [
// ExampleInsight::class,
SlevomatCodingStandard\Sniffs\ControlStructures\DisallowShortTernaryOperatorSniff::class,
SlevomatCodingStandard\Sniffs\ControlStructures\DisallowYodaComparisonSniff::class,
SlevomatCodingStandard\Sniffs\PHP\UselessParenthesesSniff::class,
SlevomatCodingStandard\Sniffs\TypeHints\DisallowArrayTypeHintSyntaxSniff::class,
SlevomatCodingStandard\Sniffs\TypeHints\UselessConstantTypeHintSniff::class,
PhpCsFixer\Fixer\ControlStructure\NoUnneededControlParenthesesFixer::class,
PhpCsFixer\Fixer\Operator\TernaryOperatorSpacesFixer::class,
PhpCsFixer\Fixer\Phpdoc\PhpdocInlineTagFixer::class,
PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer::class,
PhpCsFixer\Fixer\Phpdoc\AlignMultilineCommentFixer::class,
PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ElseIfDeclarationSniff::class,
PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterCastSniff::class,
],
'config' => [
// ExampleInsight::class => [
// 'key' => 'value',
// ],
ObjectCalisthenics\Sniffs\NamingConventions\ElementNameMinimalLengthSniff::class => [
'minLength' => 3,
'allowedShortNames' => ['i', 'id', 'to', 'up', 'ky', 'vl', 'e'],
],
PhpCsFixer\Fixer\CastNotation\CastSpacesFixer::class => [
'space' => 'none',
],
PhpCsFixer\Fixer\Basic\BracesFixer::class => [
'allow_single_line_closure' => false,
'position_after_anonymous_constructs' => 'next',
'position_after_control_structures' => 'next',
'position_after_functions_and_oop_constructs' => 'next',
],
SlevomatCodingStandard\Sniffs\Commenting\DocCommentSpacingSniff::class => [
'linesCountBeforeFirstContent' => 0,
'linesCountBetweenDescriptionAndAnnotations' => 1,
'linesCountBetweenDifferentAnnotationsTypes' => 0,
'linesCountBetweenAnnotationsGroups' => 0,
'linesCountAfterLastContent' => 0,
'annotationsGroups' => [],
],
PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer::class => [
'tokens' => [], // possibles values ['break', 'case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'return', 'square_brace_block', 'switch', 'throw', 'use', 'use_trait']
]
],
];
24 changes: 24 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="./tests/bootstrap.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
processIsolation="false"
verbose="true"
colors="true"
stderr="true"
backupGlobals="false"
beStrictAboutTestsThatDoNotTestAnything="false">
<testsuites>
<testsuite name="CitrusIntersection tests">
<directory suffix="Test.php">tests/</directory>
</testsuite>
</testsuites>

<logging>
<log type="testdox-text" target="./phpunit.tdx"/>
</logging>

</phpunit>
Loading

0 comments on commit e1ea01e

Please sign in to comment.