chore: initialize project using ramsey/php-library-starter-kit

This commit is contained in:
Dan Jones 2021-10-14 15:41:02 -05:00
commit 3d602ddd69
35 changed files with 1119 additions and 0 deletions

16
.editorconfig Normal file
View file

@ -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

22
.gitattributes vendored Normal file
View file

@ -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

0
.github/CODEOWNERS vendored Normal file
View file

0
.github/FUNDING.yml vendored Normal file
View file

35
.github/ISSUE_TEMPLATE/Bug_Report.md vendored Normal file
View file

@ -0,0 +1,35 @@
---
name: Bug Report
about: Create a bug report to help us improve
labels: bug
assignees:
---
<!--- Provide a general summary of the issue you're having in the title above. -->
## 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.
-->
1. Step one...
2. Step two...
3. Step three...
## 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. -->
- 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
<!-- Provide any additional context that may help us debug the problem. -->

View file

@ -0,0 +1,31 @@
---
name: Feature Request
about: Suggest a feature for this project
labels: enhancement
assignees:
---
<!--- Provide a general summary of your feature request in the title above. -->
<!-- Give your feature a short title here. -->
## My feature title
<!-- Provide a short and clear description of the feature. -->
## Background/problem
<!--
Provide background details to show why this feature is necessary. Is your
feature request related to a problem? If so, please describe the problem.
Provide as much detail as possible.
-->
## Proposal/solution
<!--
Provide a short and clear description of the solution you'd like. Include code
examples, if possible. Feel free to use pseudo-code to show how you think the
feature should work.
-->
## Alternatives
<!-- Describe any alternative solutions or features you've considered. -->
## Additional context
<!-- Please provide any other context or code examples that may help. -->

19
.github/ISSUE_TEMPLATE/Question.md vendored Normal file
View file

@ -0,0 +1,19 @@
---
name: Question
about: Ask a question about how to use this library
labels: question
assignees:
---
<!--- Provide a general summary of your question in the title above. -->
<!-- Write your question here. -->
## How do I... ?
<!-- Provide any additional context that may help us answer your question. -->
## Example code
<!--
If your question is about code that you've written, provide a short and clear
example of what you're trying to accomplish. Try to keep this as short as
possible. If able, please provide an example outside of any framework you are
using. This will help us to quickly respond to your question.
-->

1
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View file

@ -0,0 +1 @@
blank_issues_enabled: false

7
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "monthly"
versioning-strategy: "increase-if-necessary"

27
.github/pull_request_template.md vendored Normal file
View file

@ -0,0 +1,27 @@
<!--- Provide a general summary of your changes in the title above. -->
## Description
<!--- Describe your changes in detail. -->
## Motivation and context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
## How has this been tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->
## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] 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
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] 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.

View file

@ -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"

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
/captainhook.config.json
/composer.lock
/phpcs.xml
/phpunit.xml
/vendor/

28
CHANGELOG.md Normal file
View file

@ -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.

155
CODE_OF_CONDUCT.md Normal file
View file

@ -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
<!-- Provide a URL or instructions for reporting code of conduct issues. -->
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) <!-- Provide the name of your code of conduct committee. --> with
a concise description of your grievance. Your grievance will be handled in
accordance with our existing governing policies.
<!-- Provide a URL or details for governing polcies. -->
<!--
NOTE: Every organization's governing policies should dictate how you handle
warnings and expulsions of community members. It is strongly recommended that
you mention those policies here or in Section 7 and that you include a mechanism
for addressing grievances.
-->
## 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.*

177
CONTRIBUTING.md Normal file
View file

@ -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: <https://github.com/danjones000/object-spy/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/

19
LICENSE Normal file
View file

@ -0,0 +1,19 @@
Copyright (c) 2021 Dan Jones <danjones@goodevilgenius.org>
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.

79
README.md Normal file
View file

@ -0,0 +1,79 @@
<h1 align="center">danjones000/object-spy</h1>
<p align="center">
<strong>Debugging library used to spy on objects' private values/methods</strong>
</p>
<!--
TODO: Make sure the following URLs are correct and working for your project.
Then, remove these comments to display the badges, giving users a quick
overview of your package.
<p align="center">
<a href="https://github.com/danjones000/object-spy"><img src="https://img.shields.io/badge/source-danjones000/object--spy-blue.svg?style=flat-square" alt="Source Code"></a>
<a href="https://packagist.org/packages/danjones000/object-spy"><img src="https://img.shields.io/packagist/v/danjones000/object-spy.svg?style=flat-square&label=release" alt="Download Package"></a>
<a href="https://php.net"><img src="https://img.shields.io/packagist/php-v/danjones000/object-spy.svg?style=flat-square&colorB=%238892BF" alt="PHP Programming Language"></a>
<a href="https://github.com/danjones000/object-spy/blob/main/LICENSE"><img src="https://img.shields.io/packagist/l/danjones000/object-spy.svg?style=flat-square&colorB=darkcyan" alt="Read License"></a>
<a href="https://github.com/danjones000/object-spy/actions/workflows/continuous-integration.yml"><img src="https://img.shields.io/github/workflow/status/danjones000/object-spy/build/main?style=flat-square&logo=github" alt="Build Status"></a>
<a href="https://codecov.io/gh/danjones000/object-spy"><img src="https://img.shields.io/codecov/c/gh/danjones000/object-spy?label=codecov&logo=codecov&style=flat-square" alt="Codecov Code Coverage"></a>
<a href="https://shepherd.dev/github/danjones000/object-spy"><img src="https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fshepherd.dev%2Fgithub%2Fdanjones000%2Fobject-spy%2Fcoverage" alt="Psalm Type Coverage"></a>
</p>
-->
## About
<!--
TODO: Use this space to provide more details about your package. Try to be
concise. This is the introduction to your package. Let others know what
your package does and how it can help them build applications.
-->
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
```
<!--
## Usage
Provide a brief description or short example of how to use this library.
If you need to provide more detailed examples, use the `docs/` directory
and provide a link here to the documentation.
``` php
use Danjones000\Spy\Example;
$example = new Example();
echo $example->greet('fellow human');
```
-->
## 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.

0
bin/.gitkeep Normal file
View file

6
build/.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
*
!.gitignore
!cache
!cache/.gitkeep
!logs
!logs/.gitkeep

0
build/cache/.gitkeep vendored Normal file
View file

0
build/logs/.gitkeep Normal file
View file

113
captainhook.json Normal file
View file

@ -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": []
}
}

29
codecov.yml Normal file
View file

@ -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

49
composer.json Normal file
View file

@ -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
}

23
conventional-commits.json Normal file
View file

@ -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": []
}

0
docs/.gitkeep Normal file
View file

13
phpcs.xml.dist Normal file
View file

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<arg name="extensions" value="php"/>
<arg name="colors"/>
<arg value="sp"/>
<file>./src</file>
<file>./tests</file>
<rule ref="Ramsey"/>
</ruleset>

6
phpstan.neon.dist Normal file
View file

@ -0,0 +1,6 @@
parameters:
tmpDir: ./build/cache/phpstan
level: max
paths:
- ./src
- ./tests

21
phpunit.xml.dist Normal file
View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./vendor/autoload.php"
cacheResultFile="./build/cache/phpunit.result.cache"
colors="true"
verbose="true">
<testsuites>
<testsuite name="unit-tests">
<directory>./tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
</phpunit>

2
psalm-baseline.xml Normal file
View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.9.5@0cfe565d0afbcd31eadcc281b9017b5692911661"/>

17
psalm.xml Normal file
View file

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<psalm xmlns="https://getpsalm.org/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
totallyTyped="true"
cacheDirectory="./build/cache/psalm"
errorBaseline="./psalm-baseline.xml">
<projectFiles>
<directory name="./src"/>
<ignoreFiles>
<directory name="./tests"/>
<directory name="./vendor"/>
</ignoreFiles>
</projectFiles>
</psalm>

0
resources/.gitkeep Normal file
View file

37
src/Example.php Normal file
View file

@ -0,0 +1,37 @@
<?php
/**
* This file is part of danjones000/object-spy
*
* danjones000/object-spy is open source software: you can distribute
* it and/or modify it under the terms of the MIT License
* (the "License"). You may not use this file except in
* compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* @copyright Copyright (c) Dan Jones <danjones@goodevilgenius.org>
* @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}!";
}
}

20
tests/ExampleTest.php Normal file
View file

@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace Danjones000\Test\Spy;
use Danjones000\Spy\Example;
use Mockery\MockInterface;
class ExampleTest extends TestCase
{
public function testGreet(): void
{
/** @var Example & MockInterface $example */
$example = $this->mockery(Example::class);
$example->shouldReceive('greet')->passthru();
$this->assertSame('Hello, Friends!', $example->greet('Friends'));
}
}

14
tests/TestCase.php Normal file
View file

@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace Danjones000\Test\Spy;
use Ramsey\Dev\Tools\TestCase as BaseTestCase;
/**
* A base test case for common test functionality
*/
class TestCase extends BaseTestCase
{
}