commit cd223caa18fa500683d1e9a552f5806c19795ad6 Author: Saif Eddin Gmati <29315886+azjezz@users.noreply.github.com> Date: Fri Mar 26 10:10:46 2021 +0100 Initial commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5e9a93e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.yml] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fc99f31 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,40 @@ +# Autodetect text files +* text=auto + +# ...Unless the name matches the following overriding patterns + +# Definitively text files +*.php text +*.css text +*.js text +*.txt text +*.md text +*.xml text +*.json text +*.bat text +*.sql text +*.yml text + +# Ensure those won't be messed up with +*.png binary +*.jpg binary +*.gif binary +*.ttf binary + +# Ignore some meta files when creating an archive of this repository +/.github export-ignore +/.editorconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.scrutinizer.yml export-ignore +/phpunit.xml.dist export-ignore +/psalm.xml export-ignore +/.phpcs.xml export-ignore +/.php_cs.dist export-ignore +/tests export-ignore +/docs export-ignore + +# Avoid merge conflicts in CHANGELOG +# https://about.gitlab.com/2015/02/10/gitlab-reduced-merge-conflicts-by-90-percent-with-changelog-placeholders/ +/CHANGELOG.md merge=union + diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..e6128fb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,25 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: 'Type: Bug' +assignees: azjezz + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Code to reproduce the behavior: + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Environment (please complete the following information):** + - OS: [e.g. iOS, Ubuntu] + - PHP version [e.g. 7.4, 8.0] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..565a405 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: 'Type: Enhancement' +assignees: azjezz + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml new file mode 100644 index 0000000..4a692a2 --- /dev/null +++ b/.github/workflows/code-coverage.yml @@ -0,0 +1,36 @@ +name: "code coverage" + +on: + pull_request: ~ + push: ~ + +jobs: + code-coverage: + name: "code coverage" + + runs-on: "ubuntu-latest" + + steps: + - name: "checkout" + uses: "actions/checkout@v2" + + - name: "installing PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "8.0" + ini-values: memory_limit=-1 + tools: composer:v2, cs2pr + extensions: bcmath, mbstring, intl, sodium, json + + - name: "installing dependencies" + run: "composer install --no-interaction --no-progress --ignore-platform-req php" + + - name: "running unit tests ( phpunit )" + run: "php vendor/bin/phpunit" + + - name: "sending code coverage to coveralls" + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + composer global require php-coveralls/php-coveralls + php-coveralls -x tests/logs/clover.xml -o tests/logs/coveralls-upload.json -v diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml new file mode 100644 index 0000000..90d9ef3 --- /dev/null +++ b/.github/workflows/coding-standards.yml @@ -0,0 +1,30 @@ +name: "coding standards" + +on: + pull_request: ~ + push: ~ + +jobs: + coding-standards: + name: "coding standards" + runs-on: "ubuntu-latest" + steps: + - name: "checkout" + uses: "actions/checkout@v2" + + - name: "installing PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "7.4" + ini-values: memory_limit=-1 + tools: composer:v2, cs2pr + extensions: bcmath, mbstring, intl, sodium, json + + - name: "installing dependencies" + run: "composer update --no-interaction --no-progress" + + - name: "checking coding standards ( codesniffer )" + run: "php vendor/bin/phpcs" + + - name: "checking coding standards ( php-cs-fixer )" + run: "php vendor/bin/php-cs-fixer fix --dry-run --diff --ansi" diff --git a/.github/workflows/security-analysis.yml b/.github/workflows/security-analysis.yml new file mode 100644 index 0000000..6f716fd --- /dev/null +++ b/.github/workflows/security-analysis.yml @@ -0,0 +1,27 @@ +name: "security analysis" + +on: + pull_request: ~ + push: ~ + +jobs: + security-analysis: + name: "security analysis" + runs-on: "ubuntu-latest" + steps: + - name: "checkout" + uses: "actions/checkout@v2" + + - name: "installing PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "7.4" + ini-values: memory_limit=-1 + tools: composer:v2, cs2pr + extensions: bcmath, mbstring, intl, sodium, json + + - name: "installing dependencies" + run: "composer update --no-interaction --no-progress" + + - name: "running security analysis ( psalm )" + run: "vendor/bin/psalm --output-format=github --taint-analysis" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 0000000..8ba6e07 --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,29 @@ +name: "static analysis" + +on: + pull_request: ~ + push: ~ + schedule: + - cron: '0 */3 * * *' + +jobs: + static-analysis: + name: "static analysis" + runs-on: "ubuntu-latest" + steps: + - name: "checkout" + uses: "actions/checkout@v2" + + - name: "installing PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "7.4" + ini-values: memory_limit=-1 + tools: composer:v2, cs2pr + extensions: bcmath, mbstring, intl, sodium, json + + - name: "installing dependencies" + run: "composer update --no-interaction --no-progress" + + - name: "running static analysis ( psalm )" + run: "vendor/bin/psalm --shepherd --stats" diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000..d75d4c6 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,48 @@ +name: "unit tests" + +on: + pull_request: ~ + push: ~ + +jobs: + unit-tests: + name: "unit tests" + + runs-on: ${{ matrix.operating-system }} + + strategy: + matrix: + php-version: + - "7.4" + - "8.0" + operating-system: + - "macos-latest" + - "ubuntu-latest" + - "windows-latest" + + steps: + - name: "checkout" + uses: "actions/checkout@v2" + + - name: "installing PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + ini-values: memory_limit=-1 + tools: composer:v2, cs2pr + extensions: bcmath, mbstring, intl, sodium, json + + - name: "caching dependencies" + uses: "actions/cache@v2" + with: + path: | + ~/.composer/cache + vendor + key: "php-${{ matrix.php-version }}" + restore-keys: "php-${{ matrix.php-version }}" + + - name: "installing dependencies" + run: "composer install --no-interaction --no-progress --ignore-platform-req php" + + - name: "running unit tests ( phpunit )" + run: "php vendor/bin/phpunit" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7b5b5cb --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +# phpstorm project files +.idea + +# vs code project files +.vscode + +# composer vendor dir +/vendor/ + +# composer lock file +/composer.lock + +# Mac DS_Store files +.DS_Store + +# php-cs-fixer cache +.php_cs.cache + +# phpunit cache +.phpunit.result.cache + +# test logs +/tests/logs/* diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 0000000..a29aa1c --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,82 @@ +setFinder( + \Symfony\Component\Finder\Finder::create() + ->in([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ) + ->setRiskyAllowed(true) + ->setRules([ + 'align_multiline_comment' => true, + 'array_indentation' => true, + 'declare_strict_types' => true, + // Currently it is not possible to mark all classes as final (exceptions etc.) + // We can run this fixer periodically on the tests folder only. + // 'final_class' => true, + 'global_namespace_import' => [ + 'import_classes' => true, + 'import_constants' => true, + 'import_functions' => true, + ], + 'list_syntax' => [ + 'syntax' => 'short', + ], + 'lowercase_constants' => true, + 'multiline_comment_opening_closing' => true, + 'native_function_casing' => true, + 'no_empty_phpdoc' => true, + 'no_leading_import_slash' => true, + 'no_superfluous_phpdoc_tags' => [ + 'allow_mixed' => true, + ], + 'no_unused_imports' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'ordered_imports' => [ + 'imports_order' => ['class', 'function', 'const'], + ], + 'ordered_interfaces' => true, + 'php_unit_test_annotation' => true, + 'php_unit_test_case_static_method_calls' => [ + 'call_type' => 'static', + ], + 'single_import_per_statement' => true, + 'single_trait_insert_per_statement' => true, + 'static_lambda' => true, + 'strict_comparison' => true, + 'strict_param' => true, + 'no_blank_lines_after_phpdoc' => true, + 'no_empty_phpdoc' => true, + 'phpdoc_align' => [ + 'align' => 'left', + ], + 'phpdoc_indent' => true, + 'phpdoc_line_span' => [ + 'const' => 'multi', + 'property' => 'multi', + 'method' => 'multi', + ], + 'phpdoc_no_alias_tag' => [ + 'replacements' => [ + 'psalm-var' => 'var', + 'psalm-template' => 'template', + 'psalm-param' => 'param', + 'psalm-return' => 'return', + ] + ], + 'phpdoc_order' => true, + 'phpdoc_scalar' => true, + 'phpdoc_separation' => true, + 'phpdoc_summary' => true, + 'phpdoc_tag_casing' => true, + 'phpdoc_trim' => true, + 'phpdoc_trim_consecutive_blank_line_separation' => true, + 'no_empty_statement' => true, + 'semicolon_after_instruction' => true, + 'declare_strict_types' => true, + 'strict_param' => true, + ]) +; diff --git a/.phpcs.xml b/.phpcs.xml new file mode 100644 index 0000000..9ac1ae8 --- /dev/null +++ b/.phpcs.xml @@ -0,0 +1,43 @@ + + + The coding standard for PHP Standard Library. + + src + tests + + + + + + + error + + + + error + + + + error + + + + + error + + + + + + + + + + + + + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d7091f8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# php-standard-library/repository-template changelog + +## 1.0.0 + +- initial release. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..28a963a --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at azjezz@protonmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2b9ba9d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019-2020 Saif Eddin Gmati + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..eef5e01 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Repository Template + +![Unit tests status](https://github.com/php-standard-library/repository-template/workflows/unit%20tests/badge.svg) +![Static analysis status](https://github.com/php-standard-library/repository-template/workflows/static%20analysis/badge.svg) +![Security analysis status](https://github.com/php-standard-library/repository-template/workflows/security%20analysis/badge.svg) +![Coding standards status](https://github.com/php-standard-library/repository-template/workflows/coding%20standards/badge.svg) +[![Type Coverage](https://shepherd.dev/github/php-standard-library/repository-template/coverage.svg)](https://shepherd.dev/github/php-standard-library/repository-template) + +## Sponsors + +Thanks to our sponsors and supporters: + + +| JetBrains | +|---| +| | + + +## License + +The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..7146cd1 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,7 @@ +# Security + +If you discover a security vulnerability within PSL, please send an e-mail to Saif Eddin Gmati via azjezz@protonmail.com. + +Please withhold public disclosure until after we have addressed the vulnerability. + +There are no hard and fast rules to determine if a bug is worth reporting as a security issue. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..cf1bca5 --- /dev/null +++ b/composer.json @@ -0,0 +1,63 @@ +{ + "name": "php-standard-library/repository-template", + "description": "PHP Standard Library: Repository Template", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "azjezz", + "email": "azjezz@protonmail.com" + } + ], + "require": { + "php": "^7.4 || ^8.0", + "azjezz/psl": "^1.5", + "ext-bcmath": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-sodium": "*", + "ext-intl": "*" + }, + "require-dev": { + "phpunit/phpunit": "^9.5", + "friendsofphp/php-cs-fixer": "^2.18", + "roave/security-advisories": "dev-master", + "squizlabs/php_codesniffer": "^3.5", + "vimeo/psalm": "dev-master" + }, + "autoload": { + "psr-4": { + "Psl\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Psl\\Tests\\": "tests/" + } + }, + "scripts": { + "cs:fix": [ + "phpcbf", + "php-cs-fixer fix" + ], + "cs:check": [ + "phpcs", + "php-cs-fixer fix --dry-run" + ], + "type:check": "psalm", + "type:coverage": "psalm --shepherd", + "test:unit": "phpunit", + "code:coverage": "php-coveralls -v", + "security:analysis": "psalm --taint-analysis", + "check": [ + "@cs:check", + "@type:check", + "@security:analysis", + "@test:unit" + ] + }, + "config": { + "process-timeout": 1200, + "sort-packages": true + } +} \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..4c6ef43 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,21 @@ + + + + + + src + + + + + + + + + + + tests/ + + + + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..b946715 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/.gitkeep b/src/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/.gitkeep b/tests/.gitkeep new file mode 100644 index 0000000..e69de29