From 934e549ec6df1b18ca7700f49084ab4dd3cf6ae1 Mon Sep 17 00:00:00 2001 From: yaozm Date: Wed, 19 Oct 2022 11:35:14 +0800 Subject: [PATCH] Build the basic skeleton --- .editorconfig | 15 ++ .gitattributes | 21 +++ .github/CONTRIBUTING.md | 55 ++++++ .github/FUNDING.yml | 4 + .github/ISSUE_TEMPLATE/bug_report.md | 27 +++ .github/ISSUE_TEMPLATE/feature_request.md | 20 +++ .github/SECURITY.md | 3 + .github/auto-comment.yml | 10 ++ .github/ci-reporter.yml | 8 + .github/config.yml | 78 ++++++++ .github/dependabot.yml | 15 ++ .github/release-drafter.yml | 4 + .github/stale.yml | 17 ++ .github/workflows/dependabot-auto-merge.yml | 32 ++++ .github/workflows/greetings.yml | 16 ++ .github/workflows/label.yml | 22 +++ .github/workflows/lint-md.yml | 17 ++ .github/workflows/php-cs-fixer.yml | 23 +++ .github/workflows/psalm.yml | 33 ++++ .github/workflows/release-drafter.yml | 38 ++++ .../workflows/release-on-milestone-closed.yml | 72 ++++++++ .github/workflows/release-please.yml | 69 +++++++ .github/workflows/stale.yml | 27 +++ .github/workflows/tests.yml | 45 +++++ .github/workflows/update-changelog.yml | 28 +++ .gitignore | 16 ++ .lintmdrc | 19 ++ .php-cs-fixer.php | 89 +++++++++ CHANGELOG.md | 7 + LICENSE | 21 +++ README-zh_CN.md | 57 ++++++ README.md | 57 ++++++ _ide_helper.php | 13 ++ art/.gitkeep | 0 composer.json | 169 ++++++++++++++++++ config/web-tinker.php | 13 ++ docs/.gitkeep | 0 infection.json.dist | 14 ++ phpstan-baseline.neon | 36 ++++ phpstan.neon | 30 ++++ phpunit.xml.dist | 48 +++++ psalm-baseline.xml | 2 + psalm.xml.dist | 23 +++ rector.php | 134 ++++++++++++++ resources/views/.gitkeep | 0 routes/web.php | 11 ++ src/WebTinkerServiceProvider.php | 28 +++ tests/Datasets/Movies.php | 26 +++ tests/ExampleTest.php | 15 ++ tests/Feature/TestCase.php | 17 ++ tests/Pest.php | 35 ++++ tests/TestCase.php | 82 +++++++++ tests/fixtures/.gitkeep | 0 tests/stubs/.gitkeep | 0 54 files changed, 1661 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/CONTRIBUTING.md 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/SECURITY.md create mode 100644 .github/auto-comment.yml create mode 100644 .github/ci-reporter.yml create mode 100644 .github/config.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/stale.yml create mode 100644 .github/workflows/dependabot-auto-merge.yml create mode 100644 .github/workflows/greetings.yml create mode 100644 .github/workflows/label.yml create mode 100644 .github/workflows/lint-md.yml create mode 100644 .github/workflows/php-cs-fixer.yml create mode 100644 .github/workflows/psalm.yml create mode 100644 .github/workflows/release-drafter.yml create mode 100644 .github/workflows/release-on-milestone-closed.yml create mode 100644 .github/workflows/release-please.yml create mode 100644 .github/workflows/stale.yml create mode 100644 .github/workflows/tests.yml create mode 100644 .github/workflows/update-changelog.yml create mode 100644 .gitignore create mode 100644 .lintmdrc create mode 100644 .php-cs-fixer.php create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 README-zh_CN.md create mode 100644 README.md create mode 100644 _ide_helper.php create mode 100644 art/.gitkeep create mode 100644 composer.json create mode 100644 config/web-tinker.php create mode 100644 docs/.gitkeep create mode 100644 infection.json.dist create mode 100644 phpstan-baseline.neon create mode 100644 phpstan.neon create mode 100644 phpunit.xml.dist create mode 100644 psalm-baseline.xml create mode 100644 psalm.xml.dist create mode 100644 rector.php create mode 100644 resources/views/.gitkeep create mode 100644 routes/web.php create mode 100644 src/WebTinkerServiceProvider.php create mode 100644 tests/Datasets/Movies.php create mode 100644 tests/ExampleTest.php create mode 100644 tests/Feature/TestCase.php create mode 100644 tests/Pest.php create mode 100644 tests/TestCase.php create mode 100644 tests/fixtures/.gitkeep create mode 100644 tests/stubs/.gitkeep diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a7c44dd --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..31cf6de --- /dev/null +++ b/.gitattributes @@ -0,0 +1,21 @@ +# Path-based git attributes +# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html + +# Ignore all test and documentation with "export-ignore". +/.github export-ignore +/art export-ignore +/docs export-ignore +/.editorconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.lintmdrc export-ignore +/.phplint.yml export-ignore +/CHANGELOG.md export-ignore +/composer.json export-ignore +/composer.lock export-ignore +/LICENSE export-ignore +/phpbench.json export-ignore +/phpunit.xml.dist export-ignore +/psalm.xml.dist export-ignore +/README.md export-ignore +/README-zh_CN.md export-ignore diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..b4ae1c4 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,55 @@ +# Contributing + +Contributions are **welcome** and will be fully **credited**. + +Please read and understand the contribution guide before creating an issue or pull request. + +## Etiquette + +This project is open source, and as such, the maintainers give their free time to build and maintain the source code +held within. They make the code freely available in the hope that it will be of use to other developers. It would be +extremely unfair for them to suffer abuse or anger for their hard work. + +Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the +world that developers are civilized and selfless people. + +It's the duty of the maintainer to ensure that all submissions to the project are of sufficient +quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. + +## Viability + +When requesting or submitting new features, first consider whether it might be useful to others. Open +source projects are used by many developers, who may have entirely different needs to your own. Think about +whether or not your feature is likely to be used by other users of the project. + +## Procedure + +Before filing an issue: + +- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. +- Check to make sure your feature suggestion isn't already present within the project. +- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. +- Check the pull requests tab to ensure that the feature isn't already in progress. + +Before submitting a pull request: + +- Check the codebase to ensure that your feature doesn't already exist. +- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. + +## Requirements + +If the project maintainer has any additional requirements, you will find them listed here. + +- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). + +- **Add tests!** - Your patch won't be accepted if it doesn't have tests. + +- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. + +- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. + +- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. + +- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. + +**Happy coding**! diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..60a6fad --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +# These are supported funding model platforms + +patreon: guanguans +custom: https://www.guanguans.cn/images/wechat.jpeg diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..283a9d8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,27 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: guanguans + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '……' +2. Click on '……' +3. Scroll down to '……' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..b26b01a --- /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: good idea +assignees: guanguans + +--- + +**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. \ No newline at end of file diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..13069fc --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,3 @@ +# Security Policy + +If you discover any security related issues, please email ityaozm@gmail.com instead of using the issue tracker. diff --git a/.github/auto-comment.yml b/.github/auto-comment.yml new file mode 100644 index 0000000..665f4dc --- /dev/null +++ b/.github/auto-comment.yml @@ -0,0 +1,10 @@ +# Comment to a new issue. +issueOpened: > + Thank your for raising a issue. We will try and get back to you as soon as possible. + + Please make sure you have given us as much context as possible. + +pullRequestOpened: > + Thank your for raising your pull request. + + Please make sure you have followed our contributing guidelines. We will review it as soon as possible \ No newline at end of file diff --git a/.github/ci-reporter.yml b/.github/ci-reporter.yml new file mode 100644 index 0000000..a61a79c --- /dev/null +++ b/.github/ci-reporter.yml @@ -0,0 +1,8 @@ +# Set to false to create a new comment instead of updating the app's first one +updateComment: true + +# Use a custom string, or set to false to disable +before: "✨ Good work on this PR so far! ✨ Unfortunately, the [ build]() is failing as of . Here's the output:" + +# Use a custom string, or set to false to disable +after: "I'm sure you can fix it! If you need help, don't hesitate to ask a maintainer of the project!" \ No newline at end of file diff --git a/.github/config.yml b/.github/config.yml new file mode 100644 index 0000000..4e4ac49 --- /dev/null +++ b/.github/config.yml @@ -0,0 +1,78 @@ +# Configuration for todo - https://github.com/JasonEtco/todo +todo: + keyword: "@todo" + + + +# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome +# Comment to be posted to on first time issues +newIssueWelcomeComment: > + Thanks for opening your first issue here! Be sure to follow the issue template! + +# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome +# Comment to be posted to on PRs from first time contributors in your repository +newPRWelcomeComment: > + Thanks for opening this pull request! Please check out our contributing guidelines. + +# Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge +# Comment to be posted to on pull requests merged by a first time user +firstPRMergeComment: > + Congrats on merging your first pull request! We here at behaviorbot are proud of you! +# It is recommend to include as many gifs and emojis as possible + + + +# Configuration for request-info - https://github.com/behaviorbot/request-info +# *OPTIONAL* Comment to reply with +# Can be either a string : +requestInfoReplyComment: > + We would appreciate it if you could provide us with more info about this issue/pr! + +# Or an array: +# requestInfoReplyComment: +# - Ah no! young blade! That was a trifle short! +# - Tell me more ! +# - I am sure you can be more effusive + + +# *OPTIONAL* default titles to check against for lack of descriptiveness +# MUST BE ALL LOWERCASE +requestInfoDefaultTitles: + - update readme.md + - updates + +# *OPTIONAL* Label to be added to Issues and Pull Requests with insufficient information given +requestInfoLabelToAdd: needs-more-info + +# *OPTIONAL* Require Issues to contain more information than what is provided in the issue templates +# Will fail if the issue's body is equal to a provided template +checkIssueTemplate: true + +# *OPTIONAL* Require Pull Requests to contain more information than what is provided in the PR template +# Will fail if the pull request's body is equal to the provided template +checkPullRequestTemplate: true + +# *OPTIONAL* Only warn about insufficient information on these events type +# Keys must be lowercase. Valid values are 'issue' and 'pullRequest' +requestInfoOn: + pullRequest: true + issue: true + +# *OPTIONAL* Add a list of people whose Issues/PRs will not be commented on +# keys must be GitHub usernames +requestInfoUserstoExclude: + - guannguans + + +# Configuration for update-docs - https://github.com/behaviorbot/update-docs +# Comment to be posted to on PRs that don't update documentation +updateDocsComment: > + Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update some of our documentation based on your changes. + +updateDocsWhiteList: + - bug + - chore + +updateDocsTargetFiles: + - README + - docs/ \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b80d793 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + time: "21:00" + open-pull-requests-limit: 10 + + - package-ecosystem: composer + directory: "/" + schedule: + interval: daily + time: "21:00" + open-pull-requests-limit: 10 \ No newline at end of file diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..0a5d792 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,4 @@ +template: | + ## What’s Changed + + $CHANGES \ No newline at end of file diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..d9f6563 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,17 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security +# Label to use when marking an issue as stale +staleLabel: wontfix +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false \ No newline at end of file diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 0000000..2237c2e --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,32 @@ +name: dependabot-auto-merge +on: pull_request_target + +permissions: + pull-requests: write + contents: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v1.3.4 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Auto-merge Dependabot PRs for semver-minor updates + if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - name: Auto-merge Dependabot PRs for semver-patch updates + if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml new file mode 100644 index 0000000..5cee86c --- /dev/null +++ b/.github/workflows/greetings.yml @@ -0,0 +1,16 @@ +name: greetings + +on: [pull_request, issues] + +jobs: + greeting: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/first-interaction@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + issue-message: 'Thanks for opening your first issue here! Be sure to follow the issue template!' + pr-message: 'Thanks for opening this pull request! Please check out our contributing guidelines.' diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml new file mode 100644 index 0000000..6e8a763 --- /dev/null +++ b/.github/workflows/label.yml @@ -0,0 +1,22 @@ +# This workflow will triage pull requests and apply a label based on the +# paths that are modified in the pull request. +# +# To use this workflow, you will need to set up a .github/labeler.yml +# file with configuration. For more information, see: +# https://github.com/actions/labeler + +name: labeler +on: [pull_request] + +jobs: + label: + + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + + steps: + - uses: actions/labeler@v4 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/lint-md.yml b/.github/workflows/lint-md.yml new file mode 100644 index 0000000..aaaf2d6 --- /dev/null +++ b/.github/workflows/lint-md.yml @@ -0,0 +1,17 @@ +name: lint markdown + +on: [push, pull_request] + +jobs: + lint-markdown: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: lint-md-github-action + uses: lint-md/github-action@v0.1.1 + with: + configFile: .lintmdrc + failOnWarnings: false + files: ./ ./.github/ ./docs/ diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..c6f3810 --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,23 @@ +name: check & fix styling + +on: [push, pull_request] + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + + - name: Run PHP CS Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php-cs-fixer.php --allow-risky=yes + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Fix styling diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml new file mode 100644 index 0000000..a782da8 --- /dev/null +++ b/.github/workflows/psalm.yml @@ -0,0 +1,33 @@ +name: psalm + +on: + push: + paths: + - '**.php' + - 'psalm.xml.dist' + +jobs: + psalm: + name: psalm + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: none + + - name: Cache composer dependencies + uses: actions/cache@v3 + with: + path: vendor + key: composer-${{ hashFiles('composer.lock') }} + + - name: Run composer install + run: composer install -n --prefer-dist + + - name: Run psalm + run: ./vendor/bin/psalm diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..8fc5942 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,38 @@ +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + # pull_request event is required only for autolabeler + pull_request: + # Only following types are handled by the action, but one can default to all as well + types: [ opened, reopened, synchronize ] + # pull_request_target event is required for autolabeler to support PRs from forks + # pull_request_target: + # types: [opened, reopened, synchronize] + +permissions: + contents: read + +jobs: + update_release_draft: + permissions: + contents: write # for release-drafter/release-drafter to create a github release + pull-requests: write # for release-drafter/release-drafter to add label to PR + runs-on: ubuntu-latest + steps: + # (Optional) GitHub Enterprise requires GHE_HOST variable set + #- name: Set GHE_HOST + # run: | + # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV + + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml + # with: + # config-name: my-config.yml + # disable-autolabeler: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml new file mode 100644 index 0000000..588a0ad --- /dev/null +++ b/.github/workflows/release-on-milestone-closed.yml @@ -0,0 +1,72 @@ +# https://help.github.com/en/categories/automating-your-workflow-with-github-actions + +name: "Automatic Releases" + +on: + milestone: + types: + - "closed" + +jobs: + release: + name: "GIT tag, release & create merge-up PR" + runs-on: ubuntu-latest + + steps: + - name: "Checkout" + uses: "actions/checkout@v3" + + - name: "Release" + uses: "laminas/automatic-releases@1.19.0" + with: + command-name: "laminas:automatic-releases:release" + env: + "SHELL_VERBOSITY": "3" + "GITHUB_TOKEN": ${{ secrets.ORGANIZATION_ADMIN_TOKEN }} + "SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }} + "GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }} + "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} + + - name: "Create Merge-Up Pull Request" + uses: "laminas/automatic-releases@1.19.0" + with: + command-name: "laminas:automatic-releases:create-merge-up-pull-request" + env: + "SHELL_VERBOSITY": "3" + "GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }} + "SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }} + "GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }} + "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} + + - name: "Create and/or Switch to new Release Branch" + uses: "laminas/automatic-releases@1.19.0" + with: + command-name: "laminas:automatic-releases:switch-default-branch-to-next-minor" + env: + "SHELL_VERBOSITY": "3" + "GITHUB_TOKEN": ${{ secrets.ORGANIZATION_ADMIN_TOKEN }} + "SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }} + "GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }} + "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} + + - name: "Bump Changelog Version On Originating Release Branch" + uses: "laminas/automatic-releases@1.19.0" + with: + command-name: "laminas:automatic-releases:bump-changelog" + env: + "SHELL_VERBOSITY": "3" + "GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }} + "SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }} + "GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }} + "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} + + - name: "Create new milestones" + uses: "laminas/automatic-releases@1.19.0" + with: + command-name: "laminas:automatic-releases:create-milestones" + env: + "SHELL_VERBOSITY": "3" + "GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }} + "SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }} + "GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }} + "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} \ No newline at end of file diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..8081d25 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,69 @@ +name: release-please + +on: + push: + branches: + - main + +env: + ACTION_NAME: release-please-action + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + release-please-release: + runs-on: ubuntu-latest + needs: [ build ] + steps: + - uses: GoogleCloudPlatform/release-please-action@main + id: release + with: + token: ${{ secrets.GITHUB_TOKEN }} + release-type: node + package-name: ${{env.ACTION_NAME}} + command: github-release + - uses: actions/checkout@v3 + - name: tag major and patch versions + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + git remote add gh-token "https://${{ secrets.GITHUB_TOKEN}}@github.com/google-github-actions/release-please-action.git" + git tag -d v${{ steps.release.outputs.major }} || true + git tag -d v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true + git push origin :v${{ steps.release.outputs.major }} || true + git push origin :v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true + git tag -a v${{ steps.release.outputs.major }} -m "Release v${{ steps.release.outputs.major }}" + git tag -a v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} -m "Release v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}" + git push origin v${{ steps.release.outputs.major }} + git push origin v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} + if: ${{ steps.release.outputs.release_created }} + release-please-pr: + runs-on: ubuntu-latest + needs: + - build + - release-please-release + steps: + - id: release-pr + uses: GoogleCloudPlatform/release-please-action@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + release-type: php + fork: true + package-name: ${{env.ACTION_NAME}} + command: release-pr + - id: label + if: ${{ steps.release-pr.outputs.pr }} + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/'); + await github.issues.addLabels({ + owner, + repo, + issue_number: ${{steps.release-pr.outputs.pr}}, + labels: ['autorelease: pending'] + }); + console.log(`Tagged ${{steps.release-pr.outputs.pr}}`) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..ac4e515 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,27 @@ +# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. +# +# You can adjust the behavior by modifying this file. +# For more information, see: +# https://github.com/actions/stale +name: Mark stale issues and pull requests + +on: + schedule: + - cron: '30 08 * * *' + +jobs: + stale: + + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + + steps: + - uses: actions/stale@v6 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'Stale issue message' + stale-pr-message: 'Stale pull request message' + stale-issue-label: 'no-issue-activity' + stale-pr-label: 'no-pr-activity' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..25eba77 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,45 @@ +name: tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest] + php: [7.4, 8.0, 8.1] + dependency-version: [prefer-stable] + + name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ~/.composer/cache/files + key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: xdebug + + - name: Install dependencies + run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction + + - name: Execute tests + run: composer test-c + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos + fail_ci_if_error: false # optional (default = false) + verbose: true # optional (default = false) \ No newline at end of file diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml new file mode 100644 index 0000000..411e61d --- /dev/null +++ b/.github/workflows/update-changelog.yml @@ -0,0 +1,28 @@ +name: "update changelog" + +on: + release: + types: [released] + +jobs: + update: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: main + + - name: Update Changelog + uses: stefanzweifel/changelog-updater-action@v1 + with: + latest-version: ${{ github.event.release.name }} + release-notes: ${{ github.event.release.body }} + + - name: Commit updated CHANGELOG + uses: stefanzweifel/git-auto-commit-action@v4 + with: + branch: main + commit_message: Update CHANGELOG + file_pattern: CHANGELOG.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b17c10b --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +.idea/ +.php_cs +.phplint-cache +.php_cs.cache +.php-cs-fixer.cache +.phpunit.result.cache +build/ +composer.lock +coverage/ +clover.xml +phpunit.xml +psalm.xml +vendor/ +tests.php +.DS_Store +.history/ \ No newline at end of file diff --git a/.lintmdrc b/.lintmdrc new file mode 100644 index 0000000..bb04b94 --- /dev/null +++ b/.lintmdrc @@ -0,0 +1,19 @@ +{ + "excludeFiles": [ + "src/", + "tests/", + "vendor/" + ], + "rules": { + "no-empty-code": 1, + "no-long-code": [ + 2, + { + "length": 100, + "exclude": [ + "dot" + ] + } + ] + } +} \ No newline at end of file diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..5fcbb78 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,89 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +$header = << + +This source file is subject to the MIT license that is bundled. +EOF; + +$finder = PhpCsFixer\Finder::create() + ->in([ + __DIR__.'/config', + __DIR__.'/routes', + __DIR__.'/src', + __DIR__.'/tests', + ]) + ->append([ + __DIR__.'/.php-cs-fixer.php', + __DIR__.'/rector.php', + ]) + ->exclude([ + '.github/', + 'doc/', + 'docs/', + 'vendor/', + ]) + ->notPath([ + 'vendor', + ]) + ->name('*.php') + ->notName([ + '*.blade.php', + '_ide_helper.php', + ]) + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return (new PhpCsFixer\Config()) + ->setRules([ + '@DoctrineAnnotation' => true, + '@PHP80Migration:risky' => true, + '@PHPUnit84Migration:risky' => true, + '@PSR12:risky' => true, + '@Symfony' => true, + 'header_comment' => [ + 'header' => $header, + 'comment_type' => 'PHPDoc', + ], + 'blank_line_before_statement' => [ + 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], + ], + 'comment_to_phpdoc' => [ + 'ignored_tags' => [], + ], + 'declare_strict_types' => true, + 'method_argument_space' => [ + 'on_multiline' => 'ensure_fully_multiline', + ], + 'not_operator_with_successor_space' => true, + 'no_useless_return' => true, + 'no_useless_else' => true, + 'is_null' => true, + 'return_assignment' => true, + 'multiline_comment_opening_closing' => true, + 'align_multiline_comment' => [ + 'comment_type' => 'phpdocs_only', + ], + 'phpdoc_to_comment' => [], + 'phpdoc_var_annotation_correct_order' => true, + 'php_unit_construct' => [ + 'assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame'], + ], + 'array_indentation' => true, + 'method_chaining_indentation' => true, + 'statement_indentation' => true, + ]) + ->setRiskyAllowed(true) + ->setFinder($finder); diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..38ff68d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +All notable changes to `guanguans/laravel-web-tinker` will be documented in this file. + +## 1.0.0 - 202X-XX-XX + +- Initial release. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8f811b2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 guanguans + +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-zh_CN.md b/README-zh_CN.md new file mode 100644 index 0000000..5239c32 --- /dev/null +++ b/README-zh_CN.md @@ -0,0 +1,57 @@ +# package-skeleton + +[简体中文](README-zh_CN.md) | [ENGLISH](README.md) + +> 一个 PHP 软件包模板存储库。- A PHP package template repository. + +[![tests](https://github.com/guanguans/laravel-web-tinker/workflows/tests/badge.svg)](https://github.com/guanguans/laravel-web-tinker/actions) +[![check & fix styling](https://github.com/guanguans/laravel-web-tinker/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/guanguans/laravel-web-tinker/actions) +[![codecov](https://codecov.io/gh/guanguans/laravel-web-tinker/branch/main/graph/badge.svg?token=URGFAWS6S4)](https://codecov.io/gh/guanguans/laravel-web-tinker) +[![Latest Stable Version](https://poser.pugx.org/guanguans/laravel-web-tinker/v)](//packagist.org/packages/guanguans/laravel-web-tinker) +[![Total Downloads](https://poser.pugx.org/guanguans/laravel-web-tinker/downloads)](//packagist.org/packages/guanguans/laravel-web-tinker) +[![License](https://poser.pugx.org/guanguans/laravel-web-tinker/license)](//packagist.org/packages/guanguans/laravel-web-tinker) +![GitHub repo size](https://img.shields.io/github/repo-size/guanguans/laravel-web-tinker) +![GitHub release (latest by date)](https://img.shields.io/github/v/release/guanguans/laravel-web-tinker) + +## 功能 + +* 功能 + +## 环境要求 + +* PHP >= 7.4 + +## 安装 + +```bash +$ composer require guanguans/laravel-web-tinker --prefer-dist -vvv +``` + +## 使用 + +## 测试 + +```bash +$ composer test +``` + +## 变更日志 + +请参阅 [CHANGELOG](CHANGELOG.md) 获取最近有关更改的更多信息。 + +## 贡献指南 + +请参阅 [CONTRIBUTING](.github/CONTRIBUTING.md) 有关详细信息。 + +## 安全漏洞 + +请查看[我们的安全政策](../../security/policy)了解如何报告安全漏洞。 + +## 贡献者 + +* [guanguans](https://github.com/guanguans) +* [所有贡献者](../../contributors) + +## 协议 + +MIT 许可证(MIT)。有关更多信息,请参见[协议文件](LICENSE)。 diff --git a/README.md b/README.md new file mode 100644 index 0000000..69b7cc9 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# laravel-web-tinker + +[简体中文](README-zh_CN.md) | [ENGLISH](README.md) + +> A PHP package template repository. - 一个 PHP 软件包模板存储库。 + +[![tests](https://github.com/guanguans/laravel-web-tinker/workflows/tests/badge.svg)](https://github.com/guanguans/laravel-web-tinker/actions) +[![check & fix styling](https://github.com/guanguans/laravel-web-tinker/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/guanguans/laravel-web-tinker/actions) +[![codecov](https://codecov.io/gh/guanguans/laravel-web-tinker/branch/main/graph/badge.svg?token=URGFAWS6S4)](https://codecov.io/gh/guanguans/laravel-web-tinker) +[![Latest Stable Version](https://poser.pugx.org/guanguans/laravel-web-tinker/v)](//packagist.org/packages/guanguans/laravel-web-tinker) +[![Total Downloads](https://poser.pugx.org/guanguans/laravel-web-tinker/downloads)](//packagist.org/packages/guanguans/laravel-web-tinker) +[![License](https://poser.pugx.org/guanguans/laravel-web-tinker/license)](//packagist.org/packages/guanguans/laravel-web-tinker) +![GitHub repo size](https://img.shields.io/github/repo-size/guanguans/laravel-web-tinker) +![GitHub release (latest by date)](https://img.shields.io/github/v/release/guanguans/laravel-web-tinker) + +## Features + +* Feature + +## Requirement + +* PHP >= 7.4 + +## Installation + +```bash +$ composer require guanguans/laravel-web-tinker --prefer-dist -vvv +``` + +## Usage + +## Testing + +```bash +$ composer test +``` + +## Changelog + +Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. + +## Contributing + +Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. + +## Security Vulnerabilities + +Please review [our security policy](../../security/policy) on how to report security vulnerabilities. + +## Credits + +* [guanguans](https://github.com/guanguans) +* [All Contributors](../../contributors) + +## License + +The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/_ide_helper.php b/_ide_helper.php new file mode 100644 index 0000000..1b75651 --- /dev/null +++ b/_ide_helper.php @@ -0,0 +1,13 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace { + +} diff --git a/art/.gitkeep b/art/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..e584a53 --- /dev/null +++ b/composer.json @@ -0,0 +1,169 @@ +{ + "name": "guanguans/laravel-web-tinker", + "description": "Artisan Tinker in your browser", + "license": "MIT", + "type": "library", + "abandoned": false, + "non-feature-branches": [], + "keywords": [ + "web-tinker", + "laravel", + "tinker", + "debug", + "development" + ], + "readme": "README.md", + "authors": [ + { + "name": "guanguans", + "email": "ityaozm@gmail.com", + "homepage": "https://www.guanguans.cn", + "role": "developer" + } + ], + "homepage": "https://github.com/guanguans/laravel-web-tinker", + "support": { + "issues": "https://github.com/guanguans/laravel-web-tinker/issues", + "source": "https://github.com/guanguans/laravel-web-tinker" + }, + "funding": [ + { + "type": "wechat", + "url": "https://www.guanguans.cn/images/wechat.jpeg" + } + ], + "require": { + "php": ">=7.4", + "illuminate/contracts": "^7.0 || ^8.0 || ^9.0", + "laravel/tinker": "^2.7", + "livewire/livewire": "^2.10", + "spatie/laravel-package-tools": "^1.12" + }, + "require-dev": { + "brainmaestro/composer-git-hooks": "^2.8", + "codedungeon/phpunit-result-printer": "^0.32.0", + "dms/phpunit-arraysubset-asserts": "^0.4.0", + "ekino/phpstan-banned-code": "^1.0", + "friendsofphp/php-cs-fixer": "^3.12", + "infection/infection": "^0.26.6", + "jetbrains/phpstorm-attributes": "^1.0", + "johnkary/phpunit-speedtrap": "^4.0", + "mockery/mockery": "^1.5", + "nunomaduro/larastan": "^1.0", + "nyholm/nsa": "^1.3", + "orchestra/testbench": "^5.0 || ^6.0 || ^7.0", + "pestphp/pest": "^1.22", + "pestphp/pest-plugin-faker": "^1.0", + "pestphp/pest-plugin-laravel": "^1.3", + "pestphp/pest-plugin-livewire": "^1.0", + "phpstan/extension-installer": "^1.2", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-strict-rules": "^1.4", + "rector/rector": "^0.14.6", + "roave/security-advisories": "dev-latest", + "spatie/pest-plugin-snapshots": "^1.1", + "vimeo/psalm": "^4.29" + }, + "replace": {}, + "conflict": {}, + "provide": {}, + "suggest": {}, + "repositories": {}, + "minimum-stability": "dev", + "prefer-stable": true, + "autoload": { + "psr-0": {}, + "psr-4": { + "Guanguans\\LaravelWebTinker\\": "src" + }, + "classmap": [], + "files": [], + "exclude-from-classmap": [ + "benchmarks" + ] + }, + "autoload-dev": { + "psr-4": { + "Guanguans\\LaravelWebTinkerTests\\": "tests" + } + }, + "bin": [], + "archive": {}, + "config": { + "allow-plugins": { + "infection/extension-installer": true, + "pestphp/pest-plugin": true, + "phpstan/extension-installer": true + }, + "apcu-autoloader": true, + "classmap-authoritative": true, + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true + }, + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + }, + "hooks": { + "post-merge": [ + "composer checks" + ], + "pre-commit": [ + "composer checks" + ] + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + }, + "laravel": { + "providers": [ + "Guanguans\\LaravelWebTinker\\WebTinkerServiceProvider" + ] + } + }, + "scripts": { + "post-install-cmd": [ + "@cghooks add --ignore-lock", + "@cghooks update" + ], + "post-update-cmd": [ + "@cghooks update" + ], + "post-autoload-dump": [ + ], + "cghooks": "./vendor/bin/cghooks", + "checks": [ + "@mark-start", + "@style-lint", + "@mark-separate", + "@test", + "@mark-finish" + ], + "infection": "./vendor/bin/infection --test-framework=pest --show-mutations --threads=4 --ansi", + "mark-finish": "printf '\\n!\\n!\\t\\033[0;32m%s\\033[0m\\n!\\n\\n' \"Finished\"", + "mark-separate": "printf '\\n!\\n!\\t\\033[0;33m%s\\033[0m\\n!\\n\\n' \"----------------\"", + "mark-start": "printf '\\n!\\n!\\t\\033[0;36m%s\\033[0m\\n!\\n\\n' \"Started\"", + "md-fix": "@md-lint --fix", + "md-lint": "lint-md --config .lintmdrc ./*.md ./.github/ ./docs/", + "pest": "./vendor/bin/pest --cache-result-file=./build//phpunit/.phpunit.result.cache", + "pest-coverage": "@pest --coverage-html=./build/phpunit/ --coverage-clover=clover.xml --coverage", + "phpstan": "./vendor/bin/phpstan analyse -vv", + "phpstan-baseline": "@phpstan --generate-baseline", + "post-merge": [ + "composer install" + ], + "psalm": "./vendor/bin/psalm", + "psalm-baseline": "@psalm --update-baseline", + "rector": "./vendor/bin/rector --clear-cache --ansi -v", + "rector-dry-run": "@rector --dry-run", + "style-fix": "./vendor/bin/php-cs-fixer fix --using-cache=no --config=.php-cs-fixer.php --ansi", + "style-lint": "@style-fix --diff --dry-run", + "test": "@pest", + "test-coverage": "@pest-coverage" + }, + "scripts-descriptions": {} +} diff --git a/config/web-tinker.php b/config/web-tinker.php new file mode 100644 index 0000000..a590b1e --- /dev/null +++ b/config/web-tinker.php @@ -0,0 +1,13 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +return []; diff --git a/docs/.gitkeep b/docs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/infection.json.dist b/infection.json.dist new file mode 100644 index 0000000..2c86c93 --- /dev/null +++ b/infection.json.dist @@ -0,0 +1,14 @@ +{ + "$schema": "vendor/infection/infection/resources/schema.json", + "source": { + "directories": [ + "src" + ] + }, + "phpUnit": { + "configDir": "" + }, + "mutators": { + "@default": true + } +} \ No newline at end of file diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..4156a99 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,36 @@ +parameters: + ignoreErrors: + - + message: "#^Call to an undefined method Illuminate\\\\Database\\\\ConnectionInterface\\:\\:getDriverName\\(\\)\\.$#" + count: 1 + path: src/Exceptions/DatabaseNotSupported.php + + - + message: "#^Method Spatie\\\\Health\\\\Notifications\\\\CheckFailedNotification\\:\\:transParameters\\(\\) should return array\\ but returns array\\\\.$#" + count: 1 + path: src/Notifications/CheckFailedNotification.php + + - + message: "#^Unable to resolve the template type TKey in call to function collect$#" + count: 1 + path: src/ResultStores/ResultStores.php + + - + message: "#^Unable to resolve the template type TValue in call to function collect$#" + count: 1 + path: src/ResultStores/ResultStores.php + + - + message: "#^Property Spatie\\\\Health\\\\ResultStores\\\\StoredCheckResults\\\\StoredCheckResults\\:\\:\\$storedCheckResults \\(Illuminate\\\\Support\\\\Collection\\\\) does not accept Illuminate\\\\Support\\\\Collection\\\\|Illuminate\\\\Support\\\\Collection\\\\.$#" + count: 1 + path: src/ResultStores/StoredCheckResults/StoredCheckResults.php + + - + message: "#^Unable to resolve the template type TKey in call to function collect$#" + count: 2 + path: src/ResultStores/StoredCheckResults/StoredCheckResults.php + + - + message: "#^Unable to resolve the template type TValue in call to function collect$#" + count: 2 + path: src/ResultStores/StoredCheckResults/StoredCheckResults.php diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..1e86cb7 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,30 @@ +includes: + - phpstan-baseline.neon +# - vendor/roave/no-floaters/rules.neon +# - vendor/phpstan/phpstan-strict-rules/rules.neon +# - vendor/ergebnis/phpstan-rules/rules.neon +# - vendor/ekino/phpstan-banned-code/extension.neon + +parameters: + level: 8 + paths: + - src + tmpDir: build/phpstan + checkOctaneCompatibility: true + checkModelProperties: true + checkMissingIterableValueType: true +# disallowFloatsEverywhere: true + + strictRules: + allRules: false + booleansInConditions: false + uselessCast: false + requireParentConstructorCall: false + disallowedConstructs: false + overwriteVariablesWithLoop: false + closureUsesThis: false + matchingInheritedMethodNames: false + numericOperandsInArithmeticOperators: false + strictCalls: false + switchConditionsMatchingType: false + noVariableVariables: false diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..2795967 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,48 @@ + + + + + src/ + + + src/Skeleton.php + + + + + tests/ + vendor/ + + + + + + + + 500 + + + 10 + + + false + + + + + + diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 0000000..6e80e0e --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,2 @@ + + diff --git a/psalm.xml.dist b/psalm.xml.dist new file mode 100644 index 0000000..227c9d9 --- /dev/null +++ b/psalm.xml.dist @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..7ad48ee --- /dev/null +++ b/rector.php @@ -0,0 +1,134 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +use PHPUnit\Framework\TestCase; +use Rector\Caching\ValueObject\Storage\FileCacheStorage; +use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector; +use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; +use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector; +use Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector; +use Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector; +use Rector\CodingStyle\Enum\PreferenceSelfThis; +use Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector; +use Rector\CodingStyle\Rector\Closure\StaticClosureRector; +use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; +use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector; +use Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector; +use Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector; +use Rector\Config\RectorConfig; +use Rector\Core\Configuration\Option; +use Rector\Core\ValueObject\PhpVersion; +use Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector; +use Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector; +use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector; +use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector; +use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector; +use Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector; +use Rector\PHPUnit\Set\PHPUnitLevelSetList; +use Rector\PHPUnit\Set\PHPUnitSetList; +use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector; +use Rector\Set\ValueObject\LevelSetList; +use Rector\Set\ValueObject\SetList; + +return static function (RectorConfig $rectorConfig): void { + $rectorConfig->bootstrapFiles([ + // __DIR__.'/vendor/autoload.php', + ]); + + $rectorConfig->autoloadPaths([ + // __DIR__.'/vendor/autoload.php', + ]); + + $rectorConfig->paths([ + __DIR__.'/src', + __DIR__.'/tests', + ]); + + $rectorConfig->skip([ + // rules + CallableThisArrayToAnonymousFunctionRector::class, + InlineIfToExplicitIfRector::class, + LogicalToBooleanRector::class, + SimplifyBoolIdenticalTrueRector::class, + RemoveEmptyMethodCallRector::class, + AddSeeTestAnnotationRector::class, + NormalizeNamespaceByPSR4ComposerAutoloadRector::class, + ChangeAndIfToEarlyReturnRector::class, + ReturnBinaryOrToEarlyReturnRector::class, + EncapsedStringsToSprintfRector::class, + WrapEncapsedVariableInCurlyBracesRector::class, + + // optional rules + // AddDefaultValueForUndefinedVariableRector::class, + // RemoveUnusedVariableAssignRector::class, + // UnSpreadOperatorRector::class, + // ConsistentPregDelimiterRector::class, + // StaticClosureRector::class, + + // paths + '**/Fixture*', + '**/Fixture/*', + '**/Source*', + '**/Source/*', + '**/Expected/*', + '**/Expected*', + __DIR__.'/src/foundation/tests/AppTest.php', + ]); + + $rectorConfig->sets([ + LevelSetList::UP_TO_PHP_74, + SetList::ACTION_INJECTION_TO_CONSTRUCTOR_INJECTION, + SetList::CODE_QUALITY, + SetList::CODING_STYLE, + SetList::DEAD_CODE, + // SetList::GMAGICK_TO_IMAGICK, + // SetList::MONOLOG_20, + // SetList::MYSQL_TO_MYSQLI, + SetList::NAMING, + // SetList::PRIVATIZATION, + SetList::PSR_4, + SetList::TYPE_DECLARATION, + SetList::TYPE_DECLARATION_STRICT, + SetList::EARLY_RETURN, + + PHPUnitLevelSetList::UP_TO_PHPUNIT_70, + // PHPUnitSetList::PHPUNIT80_DMS, + PHPUnitSetList::PHPUNIT_CODE_QUALITY, + PHPUnitSetList::PHPUNIT_EXCEPTION, + PHPUnitSetList::REMOVE_MOCKS, + PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD, + PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER, + ]); + + $rectorConfig->disableParallel(); + $rectorConfig->importNames(true, false); + $rectorConfig->nestedChainMethodCallLimit(3); + $rectorConfig->phpstanConfig(__DIR__.'/phpstan.neon'); + // $rectorConfig->cacheClass(FileCacheStorage::class); + // $rectorConfig->cacheDirectory(__DIR__.'/build/rector'); + // $rectorConfig->fileExtensions(['php']); + // $rectorConfig->parameters()->set(Option::APPLY_AUTO_IMPORT_NAMES_ON_CHANGED_FILES_ONLY, true); + // $rectorConfig->phpVersion(PhpVersion::PHP_80); + // $rectorConfig->parallel(); + // $rectorConfig->indent(' ', 4); + + $rectorConfig->rules([ + InlineConstructorDefaultToPropertyRector::class, + ]); + + $rectorConfig->ruleWithConfiguration( + PreferThisOrSelfMethodCallRector::class, + [ + TestCase::class => PreferenceSelfThis::PREFER_THIS, + ] + ); +}; diff --git a/resources/views/.gitkeep b/resources/views/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/routes/web.php b/routes/web.php new file mode 100644 index 0000000..58aeb6e --- /dev/null +++ b/routes/web.php @@ -0,0 +1,11 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ diff --git a/src/WebTinkerServiceProvider.php b/src/WebTinkerServiceProvider.php new file mode 100644 index 0000000..8cd9629 --- /dev/null +++ b/src/WebTinkerServiceProvider.php @@ -0,0 +1,28 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\LaravelWebTinker; + +use Spatie\LaravelPackageTools\Package; +use Spatie\LaravelPackageTools\PackageServiceProvider; + +class WebTinkerServiceProvider extends PackageServiceProvider +{ + public function configurePackage(Package $package): void + { + $package + ->name('laravel-web-tinker') + ->hasConfigFile() + ->hasTranslations() + ->hasViews(); + } +} diff --git a/tests/Datasets/Movies.php b/tests/Datasets/Movies.php new file mode 100644 index 0000000..07ebf27 --- /dev/null +++ b/tests/Datasets/Movies.php @@ -0,0 +1,26 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\LaravelWebTinkerTests\Datasets; + +dataset('movies', [ + '肖申克的救赎', + '美丽人生', + '阿甘正传', + '这个杀手不太冷', + '千与千寻', + '海上钢琴师', + '放牛班的春天', + '三傻大闹宝莱坞', + '少年派的奇幻漂流', + '当幸福来敲门', +]); diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php new file mode 100644 index 0000000..62e7f66 --- /dev/null +++ b/tests/ExampleTest.php @@ -0,0 +1,15 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +it('to be string', function ($movie): void { + expect($movie)->toBeString(); +})->group(__DIR__, __FILE__)->with('movies'); diff --git a/tests/Feature/TestCase.php b/tests/Feature/TestCase.php new file mode 100644 index 0000000..72d8c96 --- /dev/null +++ b/tests/Feature/TestCase.php @@ -0,0 +1,17 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\LaravelWebTinkerTests\Feature; + +class TestCase extends \Guanguans\LaravelWebTinkerTests\TestCase +{ +} diff --git a/tests/Pest.php b/tests/Pest.php new file mode 100644 index 0000000..ae244ef --- /dev/null +++ b/tests/Pest.php @@ -0,0 +1,35 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\LaravelWebTinkerTests; + +use Closure; +use Pest\Expectation; + +uses(TestCase::class) + ->beforeEach(function (): void { + }) + ->in(__DIR__); + +expect()->extend('assert', function (Closure $assertions): Expectation { + $assertions($this->value); + + return $this; +}); + +expect()->extend('between', function (int $min, int $max): Expectation { + expect($this->value) + ->toBeGreaterThanOrEqual($min) + ->toBeLessThanOrEqual($max); + + return $this; +}); diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..485d83d --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,82 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\LaravelWebTinkerTests; + +use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; +use Illuminate\Database\Eloquent\Factories\Factory; +use Mockery; + +class TestCase extends \Orchestra\Testbench\TestCase +{ + use ArraySubsetAsserts; + + /** + * This method is called before the first test of this test class is run. + */ + public static function setUpBeforeClass(): void + { + } + + /** + * This method is called after the last test of this test class is run. + */ + public static function tearDownAfterClass(): void + { + } + + /** + * This method is called before each test. + */ + protected function setUp(): void + { + parent::setUp(); + + // \DG\BypassFinals::enable(); + + Factory::guessFactoryNamesUsing( + static fn ($modelName): string => 'Guanguans\\LaravelWebTinker\\Database\\Factories\\'.class_basename($modelName).'Factory' + ); + } + + /** + * This method is called after each test. + */ + protected function tearDown(): void + { + $this->finish(); + Mockery::close(); + } + + /** + * Run extra tear down code. + */ + protected function finish(): void + { + // call more tear down methods + } + + protected function getPackageProviders($app) + { + return [ + // SkeletonServiceProvider::class, + ]; + } + + protected function getEnvironmentSetUp($app): void + { + config()->set('database.default', 'testing'); + + // $migration = include __DIR__.'/../database/migrations/create_skeleton_table.php.stub'; + // $migration->up(); + } +} diff --git a/tests/fixtures/.gitkeep b/tests/fixtures/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/stubs/.gitkeep b/tests/stubs/.gitkeep new file mode 100644 index 0000000..e69de29