Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
abbadon1334 committed Jul 10, 2019
0 parents commit 2b0e9c7
Show file tree
Hide file tree
Showing 55 changed files with 1,856 additions and 0 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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
composer.phar
/composer.lock
/.idea
/vendor
.DS_Store
.php_cs.cache
/build
/backup
98 changes: 98 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?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
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
language: php

php:
- 7.2
- 7.3

before_script:
- 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:
- php vendor/bin/phpunit --coverage-clover build/logs/clover.xml

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
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Francesco Danti

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# i18next
39 changes: 39 additions & 0 deletions backup/Loader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php declare(strict_types=1);

namespace I18Next;

use atk4\core\ConfigTrait;

class Loader
{

/**
* @param string $path Root folder of languages translations
*
* @param bool $useFolderAsNamespace
*
* @return \Generator
*/
public function getLocalesFromRootPath(string $path, bool $useFolderAsNamespace = false)
{
$language_folders = $this->getLocalesFolders($path);

foreach ($language_folders as $language => $language_folder) {
yield new Locale($language, $language_folder, $useFolderAsNamespace);
}
}

private function getLocalesFolders(string $path): array
{
$language_folders = [];
foreach (new \DirectoryIterator($path) as $fileInfo) {
if ($fileInfo->isDot() || $fileInfo->isFile()) {
continue;
}

$language_folders[$fileInfo->getFilename()] = $fileInfo->getPathName();
}

return $language_folders;
}
}
Loading

0 comments on commit 2b0e9c7

Please sign in to comment.