From 3d602ddd69985c9567505ead6244527d07734d01 Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Thu, 14 Oct 2021 15:41:02 -0500 Subject: [PATCH] chore: initialize project using ramsey/php-library-starter-kit --- .editorconfig | 16 ++ .gitattributes | 22 +++ .github/CODEOWNERS | 0 .github/FUNDING.yml | 0 .github/ISSUE_TEMPLATE/Bug_Report.md | 35 ++++ .github/ISSUE_TEMPLATE/Feature_Request.md | 31 ++++ .github/ISSUE_TEMPLATE/Question.md | 19 ++ .github/ISSUE_TEMPLATE/config.yml | 1 + .github/dependabot.yml | 7 + .github/pull_request_template.md | 27 +++ .github/workflows/continuous-integration.yml | 148 ++++++++++++++++ .gitignore | 5 + CHANGELOG.md | 28 +++ CODE_OF_CONDUCT.md | 155 ++++++++++++++++ CONTRIBUTING.md | 177 +++++++++++++++++++ LICENSE | 19 ++ README.md | 79 +++++++++ bin/.gitkeep | 0 build/.gitignore | 6 + build/cache/.gitkeep | 0 build/logs/.gitkeep | 0 captainhook.json | 113 ++++++++++++ codecov.yml | 29 +++ composer.json | 49 +++++ conventional-commits.json | 23 +++ docs/.gitkeep | 0 phpcs.xml.dist | 13 ++ phpstan.neon.dist | 6 + phpunit.xml.dist | 21 +++ psalm-baseline.xml | 2 + psalm.xml | 17 ++ resources/.gitkeep | 0 src/Example.php | 37 ++++ tests/ExampleTest.php | 20 +++ tests/TestCase.php | 14 ++ 35 files changed, 1119 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/CODEOWNERS create mode 100644 .github/FUNDING.yml create mode 100644 .github/ISSUE_TEMPLATE/Bug_Report.md create mode 100644 .github/ISSUE_TEMPLATE/Feature_Request.md create mode 100644 .github/ISSUE_TEMPLATE/Question.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/continuous-integration.yml create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 bin/.gitkeep create mode 100644 build/.gitignore create mode 100644 build/cache/.gitkeep create mode 100644 build/logs/.gitkeep create mode 100644 captainhook.json create mode 100644 codecov.yml create mode 100644 composer.json create mode 100644 conventional-commits.json create mode 100644 docs/.gitkeep create mode 100644 phpcs.xml.dist create mode 100644 phpstan.neon.dist create mode 100644 phpunit.xml.dist create mode 100644 psalm-baseline.xml create mode 100644 psalm.xml create mode 100644 resources/.gitkeep create mode 100644 src/Example.php create mode 100644 tests/ExampleTest.php create mode 100644 tests/TestCase.php diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c48539a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# EditorConfig http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# This applies to all files +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 +indent_style = space +indent_size = 4 + +[*.{yml,yaml}] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..28372ec --- /dev/null +++ b/.gitattributes @@ -0,0 +1,22 @@ +/.allowed-licenses export-ignore +/.editorconfig export-ignore +/.gitattributes export-ignore +/.github/ export-ignore +/.gitignore export-ignore +/bin/ export-ignore +/build/ export-ignore +/captainhook.json export-ignore +/CHANGELOG.md export-ignore +/codecov.yml export-ignore +/CODE_OF_CONDUCT.md export-ignore +/CONTRIBUTING.md export-ignore +/conventional-commits.json export-ignore +/docs/ export-ignore +/phpcs.xml.dist export-ignore +/phpstan.neon.dist export-ignore +/phpunit.xml.dist export-ignore +/psalm-baseline.xml export-ignore +/psalm.xml export-ignore +/resources/ export-ignore +/SECURITY.md export-ignore +/tests/ export-ignore diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..e69de29 diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/ISSUE_TEMPLATE/Bug_Report.md b/.github/ISSUE_TEMPLATE/Bug_Report.md new file mode 100644 index 0000000..1d003a7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bug_Report.md @@ -0,0 +1,35 @@ +--- +name: Bug Report +about: Create a bug report to help us improve +labels: bug +assignees: +--- + + +## Description + + +## Steps to reproduce + +1. Step one... +2. Step two... +3. Step three... + +## Expected behavior + + +## Screenshots or output + + +## Environment details + +- version of this package: *e.g. 1.0.0, 1.0.1, 1.1.0* +- PHP version: *e.g. 7.3.16, 7.4.4* +- OS: *e.g. Windows 10, Linux (Ubuntu 18.04.1), macOS Catalina (10.15.3)* + +## Additional context + diff --git a/.github/ISSUE_TEMPLATE/Feature_Request.md b/.github/ISSUE_TEMPLATE/Feature_Request.md new file mode 100644 index 0000000..fdde4b2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Feature_Request.md @@ -0,0 +1,31 @@ +--- +name: Feature Request +about: Suggest a feature for this project +labels: enhancement +assignees: +--- + + + +## My feature title + + +## Background/problem + + +## Proposal/solution + + +## Alternatives + + +## Additional context + diff --git a/.github/ISSUE_TEMPLATE/Question.md b/.github/ISSUE_TEMPLATE/Question.md new file mode 100644 index 0000000..5c76b2a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Question.md @@ -0,0 +1,19 @@ +--- +name: Question +about: Ask a question about how to use this library +labels: question +assignees: +--- + + + +## How do I... ? + + +## Example code + diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..3ba13e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..220288b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + - package-ecosystem: "composer" + directory: "/" + schedule: + interval: "monthly" + versioning-strategy: "increase-if-necessary" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..26d3118 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,27 @@ + + +## Description + + +## Motivation and context + + + +## How has this been tested? + + + + +## Types of changes + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to change) + +## PR checklist + + +- [ ] My change requires a change to the documentation. +- [ ] I have updated the documentation accordingly. +- [ ] I have read the **CONTRIBUTING.md** document. +- [ ] I have added tests to cover my changes. diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..0ce8d5c --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,148 @@ +# GitHub Actions Documentation: https://docs.github.com/en/actions + +name: "build" + +on: ["pull_request", "push"] + +env: + COMPOSER_ROOT_VERSION: "1.99.99" + +jobs: + coding-standards: + name: "Coding standards" + runs-on: "ubuntu-latest" + steps: + - name: "Checkout repository" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "latest" + coverage: "none" + + - name: "Install dependencies (Composer)" + uses: "ramsey/composer-install@v1" + + - name: "Check syntax (php-parallel-lint)" + run: "composer dev:lint:syntax" + + - name: "Check coding standards (PHP_CodeSniffer)" + run: "composer dev:lint:style" + + static-analysis: + name: "Static analysis" + runs-on: "ubuntu-latest" + steps: + - name: "Checkout repository" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "latest" + coverage: "none" + + - name: "Install dependencies (Composer)" + uses: "ramsey/composer-install@v1" + + - name: "Statically analyze code (PHPStan)" + run: "composer dev:analyze:phpstan" + + - name: "Statically analyze code (Psalm)" + run: "composer dev:analyze:psalm -- --shepherd" + + security-analysis: + name: "Security analysis" + runs-on: "ubuntu-latest" + steps: + - name: "Checkout repository" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "latest" + coverage: "none" + + - name: "Install dependencies (Composer)" + uses: "ramsey/composer-install@v1" + + - name: "Analyze security of code (Psalm)" + run: "./vendor/bin/psalm --taint-analysis --report=build/logs/psalm.sarif" + + - name: "Upload security analysis results to GitHub" + uses: "github/codeql-action/upload-sarif@v1" + with: + sarif_file: "build/logs/psalm.sarif" + + code-coverage: + name: "Code coverage" + runs-on: "ubuntu-latest" + steps: + - name: "Checkout repository" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "latest" + coverage: "pcov" + ini-values: "memory_limit=-1" + + - name: "Install dependencies (Composer)" + uses: "ramsey/composer-install@v1" + + - name: "Run unit tests (PHPUnit)" + run: "composer dev:test:coverage:ci" + + - name: "Publish coverage report to Codecov" + uses: "codecov/codecov-action@v1" + + unit-tests: + name: "Unit tests" + runs-on: ${{ matrix.operating-system }} + + strategy: + fail-fast: false + matrix: + php-version: + - "7.4" + - "8.0" + operating-system: + - "macos-latest" + - "ubuntu-latest" + - "windows-latest" + dependencies: + - "lowest" + - "highest" + include: + - php-version: "8.1" + operating-system: "ubuntu-latest" + dependencies: "highest" + composer-options: "--ignore-platform-req=php" + + steps: + - name: "Configure Git (for Windows)" + if: ${{ matrix.operating-system == 'windows-latest' }} + run: | + git config --system core.autocrlf false + git config --system core.eol lf + + - name: "Checkout repository" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + coverage: "none" + + - name: "Install dependencies (Composer)" + uses: "ramsey/composer-install@v1" + with: + dependency-versions: "${{ matrix.dependencies }}" + composer-options: "${{ matrix.composer-options }}" + + - name: "Run unit tests (PHPUnit)" + run: "composer dev:test:unit" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e79da8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/captainhook.config.json +/composer.lock +/phpcs.xml +/phpunit.xml +/vendor/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b261e2f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,28 @@ +# danjones000/object-spy Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## 0.1.0 - TBD + +### Added + +- Nothing. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- Nothing. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..406482e --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,155 @@ +# Citizen Code of Conduct + +## 1. Purpose + +A primary goal of danjones000/object-spy is to be inclusive to the largest number of +contributors, with the most varied and diverse backgrounds possible. As such, we +are committed to providing a friendly, safe and welcoming environment for all, +regardless of gender, sexual orientation, ability, ethnicity, socioeconomic +status, and religion (or lack thereof). + +This code of conduct outlines our expectations for all those who participate in +our community, as well as the consequences for unacceptable behavior. + +We invite all those who participate in danjones000/object-spy to help us create safe and +positive experiences for everyone. + +## 2. Open \[Source/Culture/Tech\] Citizenship + +A supplemental goal of this Code of Conduct is to increase open +\[source/culture/tech\] citizenship by encouraging participants to recognize and +strengthen the relationships between our actions and their effects on our +community. + +Communities mirror the societies in which they exist and positive action is +essential to counteract the many forms of inequality and abuses of power that +exist in society. + +If you see someone who is making an extra effort to ensure our community is +welcoming, friendly, and encourages all participants to contribute to the +fullest extent, we want to know. + +## 3. Expected Behavior + +The following behaviors are expected and requested of all community members: + + * Participate in an authentic and active way. In doing so, you contribute to + the health and longevity of this community. + * Exercise consideration and respect in your speech and actions. + * Attempt collaboration before conflict. + * Refrain from demeaning, discriminatory, or harassing behavior and speech. + * Be mindful of your surroundings and of your fellow participants. Alert + community leaders if you notice a dangerous situation, someone in distress, + or violations of this Code of Conduct, even if they seem inconsequential. + * Remember that community event venues may be shared with members of the + public; please be respectful to all patrons of these locations. + +## 4. Unacceptable Behavior + +The following behaviors are considered harassment and are unacceptable within +our community: + + * Violence, threats of violence or violent language directed against another + person. + * Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory + jokes and language. + * Posting or displaying sexually explicit or violent material. + * Posting or threatening to post other people's personally identifying + information ("doxing"). + * Personal insults, particularly those related to gender, sexual orientation, + race, religion, or disability. + * Inappropriate photography or recording. + * Inappropriate physical contact. You should have someone's consent before + touching them. + * Unwelcome sexual attention. This includes, sexualized comments or jokes; + inappropriate touching, groping, and unwelcomed sexual advances. + * Deliberate intimidation, stalking or following (online or in person). + * Advocating for, or encouraging, any of the above behavior. + * Sustained disruption of community events, including talks and presentations. + +## 5. Weapons Policy + +No weapons will be allowed at danjones000/object-spy events, community spaces, or in other +spaces covered by the scope of this Code of Conduct. Weapons include but are not +limited to guns, explosives (including fireworks), and large knives such as +those used for hunting or display, as well as any other item used for the +purpose of causing injury or harm to others. Anyone seen in possession of one of +these items will be asked to leave immediately, and will only be allowed to +return without the weapon. Community members are further expected to comply with +all state and local laws on this matter. + +## 6. Consequences of Unacceptable Behavior + +Unacceptable behavior from any community member, including sponsors and those +with decision-making authority, will not be tolerated. + +Anyone asked to stop unacceptable behavior is expected to comply immediately. + +If a community member engages in unacceptable behavior, the community organizers +may take any action they deem appropriate, up to and including a temporary ban +or permanent expulsion from the community without warning (and without refund in +the case of a paid event). + +## 7. Reporting Guidelines + +If you are subject to or witness unacceptable behavior, or have any other +concerns, please notify a community organizer as soon as possible. +danjones@goodevilgenius.org + + + +Additionally, community organizers are available to help community members +engage with local law enforcement or to otherwise help those experiencing +unacceptable behavior feel safe. In the context of in-person events, organizers +will also provide escorts as desired by the person experiencing distress. + +## 8. Addressing Grievances + +If you feel you have been falsely or unfairly accused of violating this Code of +Conduct, you should notify the danjones000/object-spy project lead(s) with +a concise description of your grievance. Your grievance will be handled in +accordance with our existing governing policies. + + + + + +## 9. Scope + +We expect all community participants (contributors, paid or otherwise; sponsors; +and other guests) to abide by this Code of Conduct in all community +venues--online and in-person--as well as in all one-on-one communications +pertaining to community business. + +This code of conduct and its related procedures also applies to unacceptable +behavior occurring outside the scope of community activities when such behavior +has the potential to adversely affect the safety and well-being of community +members. + +## 10. Contact info + +danjones@goodevilgenius.org + +## 11. License and attribution + +The Citizen Code of Conduct is distributed by +[Stumptown Syndicate](http://stumptownsyndicate.org) under a +[Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/). + +Portions of text derived from the +[Django Code of Conduct](https://www.djangoproject.com/conduct/) and the +[Geek Feminism Anti-Harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy). + +*Revision 2.3. Posted 6 March 2017.* + +*Revision 2.2. Posted 4 February 2016.* + +*Revision 2.1. Posted 23 June 2014.* + +*Revision 2.0, adopted by the [Stumptown Syndicate](http://stumptownsyndicate.org) +board on 10 January 2013. Posted 17 March 2013.* diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b8771a6 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,177 @@ +# Contributing + +Contributions are welcome. This project accepts pull requests on [GitHub][]. + +This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). By +participating in this project and its community, you are expected to uphold this +code. + +## Communication Channels + +You can find help and discussion in the following places: + +* GitHub Issues: + +## Reporting Bugs + +Report bugs using the project's [issue tracker][issues]. + +⚠️ _**ATTENTION!!!** DO NOT include passwords or other sensitive information in +your bug report._ + +When submitting a bug report, please include enough information to reproduce the +bug. A good bug report includes the following sections: + +* **Description** + + Provide a short and clear description of the bug. + +* **Steps to reproduce** + + Provide steps to reproduce the behavior you are experiencing. Please try to + keep this as short as possible. If able, create a reproducible script outside + of any framework you are using. This will help us to quickly debug the issue. + +* **Expected behavior** + + Provide a short and clear description of what you expect to happen. + +* **Screenshots or output** + + If applicable, add screenshots or program output to help explain your problem. + +* **Environment details** + + Provide details about the system where you're using this package, such as PHP + version and operating system. + +* **Additional context** + + Provide any additional context that may help us debug the problem. + +## Fixing Bugs + +This project welcomes pull requests to fix bugs! + +If you see a bug report that you'd like to fix, please feel free to do so. +Following the directions and guidelines described in the "Adding New Features" +section below, you may create bugfix branches and send pull requests. + +## Adding New Features + +If you have an idea for a new feature, it's a good idea to check out the +[issues][] or active [pull requests][] first to see if anyone is already working +on the feature. If not, feel free to submit an issue first, asking whether the +feature is beneficial to the project. This will save you from doing a lot of +development work only to have your feature rejected. We don't enjoy rejecting +your hard work, but some features don't fit with the goals of the project. + +When you do begin working on your feature, here are some guidelines to consider: + +* Your pull request description should clearly detail the changes you have made. + We will use this description to update the CHANGELOG. If there is no + description, or it does not adequately describe your feature, we may ask you + to update the description. +* danjones000/object-spy follows a superset of **[PSR-12 coding standard][psr-12]**. + Please ensure your code does, too. _Hint: run `composer dev:lint` to check._ +* Please **write tests** for any new features you add. +* Please **ensure that tests pass** before submitting your pull request. + danjones000/object-spy automatically runs tests for pull requests. However, + running the tests locally will help save time. _Hint: run `composer test`._ +* **Use topic/feature branches.** Please do not ask to pull from your main branch. + * For more information, see "[Understanding the GitHub flow][gh-flow]." +* **Submit one feature per pull request.** If you have multiple features you + wish to submit, please break them into separate pull requests. +* **Write good commit messages.** This project follows the + [Conventional Commits][] specification and uses Git hooks to ensure all + commits follow this standard. Running `composer install` will set up the Git + hooks, so when you run `git commit`, you'll be prompted to create a commit + using the Conventional Commits rules. + +## Developing + +To develop this project, you will need [PHP](https://www.php.net) 7.4 or greater +and [Composer](https://getcomposer.org). + +After cloning this repository locally, execute the following commands: + +``` bash +cd /path/to/repository +composer install +``` + +Now, you are ready to develop! + +### Tooling + +This project uses [CaptainHook](https://github.com/CaptainHookPhp/captainhook) +to validate all staged changes prior to commit. + +### Commands + +To see all the commands available for contributing to this project: + +``` bash +composer list dev +``` + +### Coding Standards + +This project follows a superset of [PSR-12](https://www.php-fig.org/psr/psr-12/) +coding standards, enforced by [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer). + +CaptainHook will run coding standards checks before committing. + +You may lint the codebase manually using the following commands: + +``` bash +# Lint +composer dev:lint + +# Attempt to auto-fix coding standards issues +composer dev:lint:fix +``` + +### Static Analysis + +This project uses a combination of [PHPStan](https://github.com/phpstan/phpstan) +and [Psalm](https://github.com/vimeo/psalm) to provide static analysis of PHP +code. + +CaptainHook will run static analysis checks before committing. + +You may run static analysis manually across the whole codebase with the +following command: + +``` bash +# Static analysis +composer dev:analyze +``` + +### Project Structure + +This project uses [pds/skeleton](https://github.com/php-pds/skeleton) as its +base folder structure and layout. + +### Running Tests + +The following must pass before we will accept a pull request. If this does not +pass, it will result in a complete build failure. Before you can run this, be +sure to `composer install`. + +To run all the tests and coding standards checks, execute the following from the +command line, while in the project root directory: + +``` +composer test +``` + +CaptainHook will automatically run all tests before pushing to the remote +repository. + +[github]: https://github.com/danjones000/object-spy +[issues]: https://github.com/danjones000/object-spy/issues +[pull requests]: https://github.com/danjones000/object-spy/pulls +[psr-12]: https://www.php-fig.org/psr/psr-12/ +[gh-flow]: https://guides.github.com/introduction/flow/ +[conventional commits]: https://www.conventionalcommits.org/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5e8a1bb --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2021 Dan Jones + +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..fb81588 --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +

danjones000/object-spy

+ +

+ Debugging library used to spy on objects' private values/methods +

+ + + + +## About + + + + +This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). +By participating in this project and its community, you are expected to +uphold this code. + + +## Installation + +Install this package as a dependency using [Composer](https://getcomposer.org). + +``` bash +composer require danjones000/object-spy +``` + + + + +## Contributing + +Contributions are welcome! To contribute, please familiarize yourself with +[CONTRIBUTING.md](CONTRIBUTING.md). + + + + + + + +## Copyright and License + +The danjones000/object-spy library is copyright © [Dan Jones](https://danielrayjones.com/) +and licensed for use under the terms of the +MIT License (MIT). Please see [LICENSE](LICENSE) for more information. + + diff --git a/bin/.gitkeep b/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 0000000..1375c16 --- /dev/null +++ b/build/.gitignore @@ -0,0 +1,6 @@ +* +!.gitignore +!cache +!cache/.gitkeep +!logs +!logs/.gitkeep diff --git a/build/cache/.gitkeep b/build/cache/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/build/logs/.gitkeep b/build/logs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/captainhook.json b/captainhook.json new file mode 100644 index 0000000..3068ac8 --- /dev/null +++ b/captainhook.json @@ -0,0 +1,113 @@ +{ + "config": { + "ansi-colors": true, + "fail-on-first-error": false, + "plugins": [], + "verbosity": "normal" + }, + "commit-msg": { + "enabled": true, + "actions": [ + { + "action": "\\Ramsey\\CaptainHook\\ValidateConventionalCommit" + } + ] + }, + "pre-push": { + "enabled": true, + "actions": [ + { + "action": "composer test" + } + ] + }, + "pre-commit": { + "enabled": true, + "actions": [ + { + "action": "composer validate", + "conditions": [ + { + "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\Any", + "args": [["composer.json"]] + } + ] + }, + { + "action": "composer normalize --dry-run", + "conditions": [ + { + "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\Any", + "args": [["composer.json"]] + } + ] + }, + { + "action": "composer dev:lint:syntax -- {$STAGED_FILES|of-type:php}", + "conditions": [ + { + "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType", + "args": ["php"] + } + ] + }, + { + "action": "composer dev:lint:style -- {$STAGED_FILES|of-type:php}", + "conditions": [ + { + "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType", + "args": ["php"] + } + ] + } + ] + }, + "prepare-commit-msg": { + "enabled": true, + "actions": [ + { + "action": "\\Ramsey\\CaptainHook\\PrepareConventionalCommit" + } + ] + }, + "post-commit": { + "enabled": false, + "actions": [] + }, + "post-merge": { + "enabled": true, + "actions": [ + { + "action": "composer install --ansi", + "conditions": [ + { + "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileChanged\\Any", + "args": [["composer.json", "composer.lock"]] + } + ] + } + ] + }, + "post-checkout": { + "enabled": true, + "actions": [ + { + "action": "composer install --ansi", + "conditions": [ + { + "exec": "\\CaptainHook\\App\\Hook\\Condition\\FileChanged\\Any", + "args": [["composer.json", "composer.lock"]] + } + ] + } + ] + }, + "post-rewrite": { + "enabled": false, + "actions": [] + }, + "post-change": { + "enabled": false, + "actions": [] + } +} diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..047a8a9 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,29 @@ +codecov: + require_ci_to_pass: yes + +coverage: + precision: 2 + round: down + range: "70...100" + status: + project: + default: + target: auto + threshold: 0% + patch: + default: + target: auto + threshold: 0% + +parsers: + gcov: + branch_detection: + conditional: yes + loop: yes + method: no + macro: no + +comment: + layout: "reach,diff,flags,tree" + behavior: default + require_changes: false diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..c05eb21 --- /dev/null +++ b/composer.json @@ -0,0 +1,49 @@ +{ + "name": "danjones000/object-spy", + "type": "library", + "description": "Debugging library used to spy on objects' private values/methods", + "keywords": [ + "debugging", + "testing" + ], + "license": "MIT", + "authors": [ + { + "name": "Dan Jones", + "email": "danjones@goodevilgenius.org", + "homepage": "https://danielrayjones.com/" + } + ], + "require": { + "php": "^7.4 || ^8" + }, + "require-dev": { + "ramsey/devtools": "^1.7" + }, + "config": { + "sort-packages": true + }, + "extra": { + "captainhook": { + "force-install": true + }, + "ramsey/conventional-commits": { + "configFile": "conventional-commits.json" + }, + "ramsey/devtools": { + "command-prefix": "dev" + } + }, + "autoload": { + "psr-4": { + "Danjones000\\Spy\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Danjones000\\Test\\Spy\\": "tests/" + } + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/conventional-commits.json b/conventional-commits.json new file mode 100644 index 0000000..b5a0823 --- /dev/null +++ b/conventional-commits.json @@ -0,0 +1,23 @@ +{ + "typeCase": "kebab", + "types": [ + "chore", + "ci", + "deps", + "docs", + "feat", + "fix", + "refactor", + "security", + "style", + "test" + ], + "scopeCase": "kebab", + "scopeRequired": false, + "scopes": [], + "descriptionCase": null, + "descriptionEndMark": "", + "bodyRequired": false, + "bodyWrapWidth": 72, + "requiredFooters": [] +} diff --git a/docs/.gitkeep b/docs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..f76cd66 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,13 @@ + + + + + + + + ./src + ./tests + + + + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..7cad6b1 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,6 @@ +parameters: + tmpDir: ./build/cache/phpstan + level: max + paths: + - ./src + - ./tests diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..32ffda6 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,21 @@ + + + + + + ./tests + + + + + + ./src + + + + diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 0000000..ca62028 --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,2 @@ + + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..cba5289 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/resources/.gitkeep b/resources/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/Example.php b/src/Example.php new file mode 100644 index 0000000..89fa948 --- /dev/null +++ b/src/Example.php @@ -0,0 +1,37 @@ + + * @license https://opensource.org/licenses/MIT MIT License + */ + +declare(strict_types=1); + +namespace Danjones000\Spy; + +/** + * An example class to act as a starting point for developing your library + */ +class Example +{ + /** + * Returns a greeting statement using the provided name + */ + public function greet(string $name = 'World'): string + { + return "Hello, {$name}!"; + } +} diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php new file mode 100644 index 0000000..a572c15 --- /dev/null +++ b/tests/ExampleTest.php @@ -0,0 +1,20 @@ +mockery(Example::class); + $example->shouldReceive('greet')->passthru(); + + $this->assertSame('Hello, Friends!', $example->greet('Friends')); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..7990c12 --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,14 @@ +