Repository: ramsey/php-library-starter-kit Branch: main Commit: f1e4383fdf87 Files: 247 Total size: 492.1 KB Directory structure: gitextract_7g50z4tk/ ├── .editorconfig ├── .gitattributes.template ├── .github/ │ ├── CODEOWNERS │ ├── ISSUE_TEMPLATE/ │ │ ├── Bug_Report.md │ │ ├── Feature_Request.md │ │ ├── Question.md │ │ └── config.yml │ ├── dependabot.yml │ ├── pull_request_template.md │ └── workflows/ │ ├── continuous-integration.yml │ └── merge-me.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── bin/ │ └── .gitkeep ├── build/ │ ├── .gitignore │ ├── cache/ │ │ └── .gitkeep │ ├── coverage/ │ │ └── .gitkeep │ └── logs/ │ └── .gitkeep ├── captainhook.json ├── codecov.yml ├── composer.json ├── conventional-commits.json ├── docs/ │ └── .gitkeep ├── phpcs.xml.dist ├── phpstan.neon.dist ├── phpunit.xml.dist ├── psalm.xml ├── resources/ │ ├── .gitkeep │ └── templates/ │ ├── CHANGELOG.md.twig │ ├── CONTRIBUTING.md.twig │ ├── FUNDING.yml.twig │ ├── code-of-conduct/ │ │ ├── Citizen-2.3.md.twig │ │ ├── Contributor-1.4.md.twig │ │ ├── Contributor-2.0.md.twig │ │ └── Contributor-2.1.md.twig │ ├── header/ │ │ ├── AGPL-3.0-or-later.twig │ │ ├── Apache-2.0.twig │ │ ├── BSD-2-Clause.twig │ │ ├── BSD-3-Clause.twig │ │ ├── CC0-1.0.twig │ │ ├── GPL-3.0-or-later.twig │ │ ├── Hippocratic-2.1.twig │ │ ├── LGPL-3.0-or-later.twig │ │ ├── MIT-0.twig │ │ ├── MIT.twig │ │ ├── MPL-2.0.twig │ │ ├── Proprietary.twig │ │ ├── Unlicense.twig │ │ └── source-file-header.twig │ ├── license/ │ │ ├── AGPL-3.0-or-later-NOTICE.twig │ │ ├── AGPL-3.0-or-later.twig │ │ ├── Apache-2.0-NOTICE.twig │ │ ├── Apache-2.0.twig │ │ ├── BSD-2-Clause.twig │ │ ├── BSD-3-Clause.twig │ │ ├── CC0-1.0.twig │ │ ├── GPL-3.0-or-later-NOTICE.twig │ │ ├── GPL-3.0-or-later.twig │ │ ├── Hippocratic-2.1.twig │ │ ├── LGPL-3.0-or-later-NOTICE.twig │ │ ├── LGPL-3.0-or-later.twig │ │ ├── MIT-0.twig │ │ ├── MIT.twig │ │ ├── MPL-2.0-NOTICE.twig │ │ ├── MPL-2.0.twig │ │ ├── Proprietary.twig │ │ ├── Unlicense.twig │ │ └── copyright-statement.twig │ ├── readme/ │ │ ├── badges.md.twig │ │ ├── code-of-conduct.md.twig │ │ ├── copyright.md.twig │ │ ├── description.md.twig │ │ ├── security.md.twig │ │ └── usage.md.twig │ └── security-policy/ │ └── HackerOne.md.twig ├── src/ │ ├── Example.php │ └── LibraryStarterKit/ │ ├── Answers.php │ ├── Console/ │ │ ├── InstallQuestions.php │ │ ├── Question/ │ │ │ ├── AnswersTool.php │ │ │ ├── AuthorEmail.php │ │ │ ├── AuthorHoldsCopyright.php │ │ │ ├── AuthorName.php │ │ │ ├── AuthorUrl.php │ │ │ ├── CodeOfConduct.php │ │ │ ├── CodeOfConductCommittee.php │ │ │ ├── CodeOfConductEmail.php │ │ │ ├── CodeOfConductPoliciesUrl.php │ │ │ ├── CodeOfConductReportingUrl.php │ │ │ ├── CopyrightEmail.php │ │ │ ├── CopyrightHolder.php │ │ │ ├── CopyrightUrl.php │ │ │ ├── CopyrightYear.php │ │ │ ├── EmailValidatorTool.php │ │ │ ├── GithubUsername.php │ │ │ ├── License.php │ │ │ ├── PackageDescription.php │ │ │ ├── PackageKeywords.php │ │ │ ├── PackageName.php │ │ │ ├── PackageNamespace.php │ │ │ ├── SecurityPolicy.php │ │ │ ├── SecurityPolicyContactEmail.php │ │ │ ├── SecurityPolicyContactFormUrl.php │ │ │ ├── SkippableQuestion.php │ │ │ ├── StarterKitQuestion.php │ │ │ ├── UrlValidatorTool.php │ │ │ └── VendorName.php │ │ ├── Style.php │ │ └── StyleFactory.php │ ├── Exception/ │ │ ├── InvalidConsoleInput.php │ │ └── StarterKitException.php │ ├── Filesystem.php │ ├── Project.php │ ├── Setup.php │ ├── Task/ │ │ ├── Build.php │ │ ├── Builder/ │ │ │ ├── Cleanup.php │ │ │ ├── FixStyle.php │ │ │ ├── InstallDependencies.php │ │ │ ├── RenameTemplates.php │ │ │ ├── RunTests.php │ │ │ ├── SetupRepository.php │ │ │ ├── UpdateChangelog.php │ │ │ ├── UpdateCodeOfConduct.php │ │ │ ├── UpdateComposerJson.php │ │ │ ├── UpdateContributing.php │ │ │ ├── UpdateFunding.php │ │ │ ├── UpdateLicense.php │ │ │ ├── UpdateNamespace.php │ │ │ ├── UpdateReadme.php │ │ │ ├── UpdateSecurityPolicy.php │ │ │ └── UpdateSourceFileHeaders.php │ │ └── Builder.php │ └── Wizard.php └── tests/ ├── ExampleTest.php ├── LibraryStarterKit/ │ ├── AnswersTest.php │ ├── Console/ │ │ ├── InstallQuestionsTest.php │ │ ├── Question/ │ │ │ ├── AuthorEmailTest.php │ │ │ ├── AuthorHoldsCopyrightTest.php │ │ │ ├── AuthorNameTest.php │ │ │ ├── AuthorUrlTest.php │ │ │ ├── CodeOfConductCommitteeTest.php │ │ │ ├── CodeOfConductEmailTest.php │ │ │ ├── CodeOfConductPoliciesUrlTest.php │ │ │ ├── CodeOfConductReportingUrlTest.php │ │ │ ├── CodeOfConductTest.php │ │ │ ├── CopyrightEmailTest.php │ │ │ ├── CopyrightHolderTest.php │ │ │ ├── CopyrightUrlTest.php │ │ │ ├── CopyrightYearTest.php │ │ │ ├── EmailValidatorToolTest.php │ │ │ ├── GithubUsernameTest.php │ │ │ ├── LicenseTest.php │ │ │ ├── PackageDescriptionTest.php │ │ │ ├── PackageKeywordsTest.php │ │ │ ├── PackageNameTest.php │ │ │ ├── PackageNamespaceTest.php │ │ │ ├── QuestionTestCase.php │ │ │ ├── SecurityPolicyContactEmailTest.php │ │ │ ├── SecurityPolicyContactFormUrlTest.php │ │ │ ├── SecurityPolicyTest.php │ │ │ ├── UrlValidatorToolTest.php │ │ │ └── VendorNameTest.php │ │ └── StyleFactoryTest.php │ ├── FilesystemTest.php │ ├── ProjectTest.php │ ├── SetupTest.php │ ├── SnapshotsTool.php │ ├── Task/ │ │ ├── BuildTest.php │ │ ├── Builder/ │ │ │ ├── CleanupTest.php │ │ │ ├── FixStyleTest.php │ │ │ ├── InstallDependenciesTest.php │ │ │ ├── RenameTemplatesTest.php │ │ │ ├── RunTestsTest.php │ │ │ ├── SetupRepositoryTest.php │ │ │ ├── UpdateChangelogTest.php │ │ │ ├── UpdateCodeOfConductTest.php │ │ │ ├── UpdateComposerJsonTest.php │ │ │ ├── UpdateContributingTest.php │ │ │ ├── UpdateFundingTest.php │ │ │ ├── UpdateLicenseTest.php │ │ │ ├── UpdateNamespaceTest.php │ │ │ ├── UpdateReadmeTest.php │ │ │ ├── UpdateSecurityPolicyTest.php │ │ │ ├── UpdateSourceFileHeadersTest.php │ │ │ ├── __snapshots__/ │ │ │ │ ├── UpdateComposerJsonTest__testBuildWithMinimalComposerJson__1.txt │ │ │ │ ├── UpdateComposerJsonTest__testBuild__1.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__0__1.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__0__2.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__0__3.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__0__4.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__0__5.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__0__6.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__1__1.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__1__2.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__1__3.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__1__4.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__1__5.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__1__6.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__2__1.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__2__2.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__2__3.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__2__4.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__2__5.txt │ │ │ │ ├── UpdateNamespaceTest__testBuild_with_data_set__2__6.txt │ │ │ │ ├── UpdateReadmeTest__testBuildWhenCodeOfConductIsNullAndSecurityPolicyIsFalse__1.txt │ │ │ │ ├── UpdateReadmeTest__testBuildWhenCodeOfConductIsNull__1.txt │ │ │ │ ├── UpdateReadmeTest__testBuild__1.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__0__1.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__0__2.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__10__1.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__10__2.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__11__1.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__11__2.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__1__1.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__1__2.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__2__1.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__2__2.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__3__1.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__3__2.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__4__1.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__4__2.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__5__1.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__5__2.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__6__1.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__6__2.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__7__1.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__7__2.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__8__1.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__8__2.txt │ │ │ │ ├── UpdateSourceFileHeadersTest__testBuild_with_data_set__9__1.txt │ │ │ │ └── UpdateSourceFileHeadersTest__testBuild_with_data_set__9__2.txt │ │ │ └── fixtures/ │ │ │ ├── composer-full.json │ │ │ ├── composer-minimal.json │ │ │ ├── readme-full.md │ │ │ ├── update-namespace-test.php │ │ │ ├── update-source-file-headers-test-1.php │ │ │ └── update-source-file-headers-test-2.php │ │ └── BuilderTest.php │ ├── TestCase.php │ ├── WindowsSafeTextDriver.php │ ├── WizardTest.php │ └── answers-test.json └── TestCase.php ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ # 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 ================================================ FILE: .gitattributes.template ================================================ /.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 ================================================ FILE: .github/CODEOWNERS ================================================ ================================================ FILE: .github/ISSUE_TEMPLATE/Bug_Report.md ================================================ --- 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 ================================================ FILE: .github/ISSUE_TEMPLATE/Feature_Request.md ================================================ --- name: Feature Request about: Suggest a feature for this project labels: enhancement assignees: --- ## My feature title ## Background/problem ## Proposal/solution ## Alternatives ## Additional context ================================================ FILE: .github/ISSUE_TEMPLATE/Question.md ================================================ --- name: Question about: Ask a question about how to use this library labels: question assignees: --- ## How do I... ? ## Example code ================================================ FILE: .github/ISSUE_TEMPLATE/config.yml ================================================ blank_issues_enabled: false ================================================ FILE: .github/dependabot.yml ================================================ version: 2 updates: - package-ecosystem: "composer" directory: "/" schedule: interval: "monthly" - package-ecosystem: "github-actions" directory: "/" schedule: interval: "monthly" ================================================ FILE: .github/pull_request_template.md ================================================ ## 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. ================================================ FILE: .github/workflows/continuous-integration.yml ================================================ # GitHub Actions Documentation: https://docs.github.com/en/actions name: "Continuous Integration" on: push: branches: - "main" tags: - "*" pull_request: branches: - "main" # Cancels all previous workflow runs for the same branch that have not yet completed. concurrency: # The concurrency group contains the workflow name and the branch name. group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: COMPOSER_ROOT_VERSION: "1.99.99" jobs: coding-standards: name: "Coding standards" runs-on: "ubuntu-latest" steps: - name: "Checkout repository" uses: "actions/checkout@v5" - name: "Install PHP" uses: "shivammathur/setup-php@v2" with: php-version: "latest" coverage: "none" - name: "Install dependencies (Composer)" uses: "ramsey/composer-install@v3" - 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@v5" - name: "Install PHP" uses: "shivammathur/setup-php@v2" with: php-version: "latest" coverage: "none" - name: "Install dependencies (Composer)" uses: "ramsey/composer-install@v3" - 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" needs: ["coding-standards", "static-analysis"] runs-on: "ubuntu-latest" # If you encounter "Resource not accessible by integration" errors on # GitHub Actions for this job, uncomment the following lines. Your # organization permissions may not be set to allow writing security events. permissions: security-events: write steps: - name: "Checkout repository" uses: "actions/checkout@v5" - name: "Install PHP" uses: "shivammathur/setup-php@v2" with: php-version: "latest" coverage: "none" - name: "Install dependencies (Composer)" uses: "ramsey/composer-install@v3" - 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@v4" with: sarif_file: "build/logs/psalm.sarif" code-coverage: name: "Code coverage" needs: ["coding-standards", "static-analysis"] runs-on: "ubuntu-latest" steps: - name: "Checkout repository" uses: "actions/checkout@v5" - 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@v3" - name: "Run unit tests (PHPUnit)" run: "composer dev:test:coverage:ci" - name: "Publish coverage report to Codecov" uses: "codecov/codecov-action@v5" unit-tests: name: "Unit tests" needs: ["code-coverage"] runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: php: - "8.1" - "8.2" - "8.3" - "8.4" os: - "macos-latest" - "ubuntu-latest" - "windows-latest" composer-deps: - "lowest" - "highest" steps: - name: "Configure Git (for Windows)" if: ${{ matrix.os == 'windows-latest' }} shell: "bash" run: | git config --system core.autocrlf false git config --system core.eol lf - name: "Checkout repository" uses: "actions/checkout@v5" - name: "Install PHP" uses: "shivammathur/setup-php@v2" with: php-version: "${{ matrix.php }}" coverage: "none" - name: "Install dependencies (Composer)" uses: "ramsey/composer-install@v3" with: dependency-versions: "${{ matrix.composer-deps }}" - name: "Run unit tests (PHPUnit)" shell: "bash" run: "composer dev:test:unit" ================================================ FILE: .github/workflows/merge-me.yml ================================================ # Merge Me! Documentation: https://github.com/ridedott/merge-me-action/ name: "Merge Dependabot PRs" on: workflow_run: types: - "completed" workflows: - "Continuous Integration" jobs: merge-me: name: "Merge me!" runs-on: "ubuntu-latest" steps: - name: "Auto-merge" if: ${{ github.event.workflow_run.conclusion == 'success' }} uses: "ridedott/merge-me-action@v2" with: # This must be used as GitHub Actions token does not support pushing # to protected branches. # # Create a token with repository permissions: # https://github.com/settings/tokens/new?scopes=repo&description=Merge+Me!+GitHub+Actions+Workflow # # Set MERGE_TOKEN as an environment variable on your repository: # https://github.com/yourname/repo-name/settings/secrets/actions/new GITHUB_TOKEN: ${{ secrets.MERGE_TOKEN }} ================================================ FILE: .gitignore ================================================ .phpunit.result.cache /captainhook.config.json /composer.lock /phpcs.xml /phpunit.xml /vendor/ ================================================ FILE: CHANGELOG.md ================================================ # ramsey/php-library-starter-kit Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## 3.5.6 - 2025-03-07 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Partially revert commit dbec32c337e4bab527ca829db3d8cef3e7f08536; the attempt to define the full Symfony Question interface on the custom StarterKitQuestion interface caused problems when using older versions of symfony/console. ## 3.5.5 - 2025-03-07 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Modernize and update type declarations and annotations throughout (no BC breaks). - Ensure all tests and static analysis tools pass on PHP 8.3 and 8.4. - Update symfony/finder dependency to `^6.4 || ^7.2`. - Update twig/twig dependency to `^3.20`. ## 3.5.4 - 2023-10-31 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Add missing instructions for creating `MERGE_TOKEN` to `merge-me.yml` GitHub Action file. ## 3.5.3 - 2023-10-31 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - By default, assign permissions to upload security reports ## 3.5.2 - 2023-05-25 ### Added - Add comment about permissions for security events to continuous integration workflow file. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Disable rendering Code of Conduct messages if None selected. ## 3.5.1 - 2023-04-27 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Remove code supporting old versions of symfony/process. - Improve checks for line-endings. ## 3.5.0 - 2023-04-27 ### Added - Add an option for version 2.1 of the Contributor Covenant - Update GitHub workflows to support auto-merging of Dependabot pull requests ### Changed - Update ramsey/devtools to version 2.0 - Increase minimum PHP version to 8.1 ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Stop passing `starter-kit` command name to avoid confusing newer versions of symfony/console. ## 3.4.2 - 2022-01-27 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Use a new instance of the Symfony Finder for each use. ## 3.4.1 - 2022-01-02 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Bump codecov/codecov-action to v2.1.0 ## 3.4.0 - 2022-01-02 ### Added - Add the `allow-plugins` property to composer.json. - Tell Dependabot to update GitHub Actions. - Run GitHub Actions CI builds only on pushes to `main` and PRs based on `main`. ### Changed - Remove "deps" as a type from conventional commits configuration. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Use v2 of ramsey/composer-install. - Fix a few package compatibility issues with PHP 8.1. ## 3.3.0 - 2021-09-26 ### Added - Allow use of an existing answers file when creating new projects. When using Composer's `create-project` command, users may now provide an environment variable (`STARTER_KIT_ANSWERS_FILE`) to indicate the location of an already-existing answers file to use when setting up a new library. This must be a JSON file including properties defined in `Ramsey\Dev\LibraryStarterKit\Answers`. To completely turn off the question prompts, include the property `skipPrompts: true`. For example: ```shell STARTER_KIT_ANSWERS_FILE=/path/to/answers.json composer create-project ramsey/php-library-starter-kit YOUR-PROJECT-NAME ``` - Include a builder task (`Ramsey\Dev\LibraryStarterKit\Task\Builder\FixStyle`) that fixes any style issues before instantiating the new repository. This avoids coding standards errors caused by out-of-order `use` statements, etc. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Nothing. ## 3.2.2 - 2021-08-11 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Remove description case from Conventional Commits configuration, since the lowercase requirement causes confusion - Remove PHPStan and Psalm checks from pre-commit hook, since these can result in false positives/negatives when analyzing only a few files at a time - Use https in URLs - Use the correct branch name in GitHub URLs ## 3.2.1 - 2021-08-07 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Fix link to SECURITY.md ## 3.2.0 - 2021-08-06 ### Added - Provide Creative Commons Zero v1.0 Universal as a license option ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Write a Coordinated Disclosure section to the README if choosing to include a security policy - Move the pull request template so that GitHub will use it ## 3.1.1 - 2021-08-05 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Detect author name and email using Git config ## 3.1.0 - 2021-08-05 ### Added - Use the author name and email address for git config, if necessary - Require the author email address ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Set the branch name *after* the initial commit to avoid errors on older versions of Git ## 3.0.3 - 2021-08-04 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Support older versions of Git that do not implement the `-b` option for `git init` - Improve exception handling to aid with debugging ## 3.0.2 - 2021-07-18 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Add missing newline to end of generated composer.json file ## 3.0.1 - 2021-07-18 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Make sure CaptainHook installation runs after the repository initialization ## 3.0.0 - 2021-07-14 ### Added - Allow users to exit the wizard and restart it later, saving their answers - Use ramsey/devtools instead of `vnd:*` scripts in the local `composer.json` - Use [CaptainHook](https://github.com/captainhookphp/captainhook) to manage Git hooks - Enforce the use of [Conventional Commits](https://www.conventionalcommits.org) - Validate and check normalization of `composer.json` in pre-commit hook - Run syntax, style, and static analysis checks in pre-commit hook - Run `composer install` on post-merge and post-checkout hooks - Run `composer test` in pre-push hook - Add option to include a security policy (vulnerability disclosure policy) as part of the wizard - Add [GitHub Actions](https://docs.github.com/en/actions) configuration for CI workflows - Add [Codecov](https://about.codecov.io) configuration for viewing code coverage reports - Use ramsey/coding-standard ### Changed - Rename from ramsey/php-library-skeleton to ramsey/php-library-starter-kit - Major re-working of the library to use [symfony/console](https://symfony.com/doc/current/components/console.html) ### Deprecated - Nothing. ### Removed - Remove dependencies on NodeJS and npm packages - Remove all `vnd:*` scripts from `composer.json` - Remove `bin/repl`, since ramsey/devtools uses ramsey/composer-repl - Remove Travis CI configuration, in favor of GitHub Actions - Remove Coveralls configuration, in favor of Codecov ### Fixed - Nothing. ## 2.1.4 - 2020-05-29 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Remove package name from license file, since it caused conflicts with GitHub's automatic license-detection software ## 2.1.3 - 2020-05-29 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Fix case of incorrect license used in generated package.json ## 2.1.2 - 2020-05-29 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Fix typo in `export-ignore` directives in `.gitattributes` ## 2.1.1 - 2020-05-29 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Fix links to code of conduct and contributing guide ## 2.1.0 - 2020-05-29 ### Added - Nothing. ### Changed - Rename phpstan.neon to phpstan.neon.dist ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Nothing. ## 2.0.1 - 2020-05-29 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Fix typo in CONTRIBUTING.md. ## 2.0.0 - 2020-05-29 ### Added - Nothing. ### Changed - Pretty much a full re-write ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Nothing. ## 1.1.1 - 2019-10-23 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Fixed PSR-12 coding standards violations. ## 1.1.0 - 2019-05-27 ### Added - Nothing. ### Changed - Moved the `README.md` file to the project root to support packages that will not be placed on GitHub. - Upgraded to the latest versions of dev tools: - PHPStan `^0.11` - PHPUnit `^8` - Now using `--no-suggest` when installing packages after finishing the wizard. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Nothing. ## 1.0.2 - 2019-01-03 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - The `.gitattributes` file continues to be problematic when using the zip distribution, so this release removes the file entirely. ## 1.0.1 - 2019-01-03 ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Fixed a problem where using `composer create-project` was not properly creating a project from the 1.0.0 release because the `.gitattributes` file was too liberal, failing to include important skeleton files in the release zip bundle. ## 1.0.0 - 2019-01-02 This is the initial release of ramsey/php-library-starter-kit, with the ability to quickly generate a PHP library including all the starting files that I ([@ramsey][]) prefer to have in my projects. Future versions of this project may expand on this and allow for more generic options. To create the starting point for a PHP library using this project, run the following: ``` bash composer create-project --remove-vcs ramsey/php-library-starter-kit target-directory ``` You will be walked through a series of questions, and your PHP library source files will be located in `target-directory`, when completed. Change to that directory, `git init`, and off you go! ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Nothing. [@ramsey]: https://github.com/ramsey ================================================ FILE: CODE_OF_CONDUCT.md ================================================ # Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ben@benramsey.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq ================================================ FILE: CONTRIBUTING.md ================================================ # 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. * ramsey/php-library-starter-kit 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. ramsey/php-library-starter-kit 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/PHPCSStandards/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. ### Running `create-project` Locally You can test Composer's `create-project` command locally to make sure the starter kit wizard runs properly with your changes. To do so, use a command similar to the following: ```shell composer create-project ramsey/php-library-starter-kit YOUR-PROJECT-NAME \ --repository='{ "type": "path", "url": "/path/to/local/php-library-starter-kit", "options": { "symlink": false } }' \ --remove-vcs \ --stability=dev ``` [github]: https://github.com/ramsey/php-library-starter-kit [issues]: https://github.com/ramsey/php-library-starter-kit/issues [pull requests]: https://github.com/ramsey/php-library-starter-kit/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/ ================================================ FILE: LICENSE ================================================ Copyright (c) 2019-2025 Ben Ramsey 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. ================================================ FILE: README.md ================================================

PHP Library Starter Kit

A starter kit for quickly setting up a new PHP library package.

Source Code Download Package PHP Programming Language Read License Build Status Codecov Code Coverage Psalm Type Coverage

## About ramsey/php-library-starter-kit is a package that may be used to generate a basic PHP library project directory structure, complete with many of the starting files (i.e. README, LICENSE, GitHub issue templates, PHPUnit configuration, etc.) that are commonly found in PHP libraries. You may use the project directory that's created as a starting point for creating your own PHP libraries. 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. ## Usage ``` bash composer create-project ramsey/php-library-starter-kit YOUR-PROJECT-NAME ``` Running this command will create a new repository containing the same files and structure as this repository. Afterward, it will run the `Ramsey\Dev\LibraryStarterKit\Wizard::start()` method to set up the project, which will walk you through a series of questions and make changes to files based on your answers. When complete, it will remove the `./src/LibraryStarterKit` and `./tests/LibraryStarterKit` directories, leaving everything else in place with an initial commit. ### Using An Existing Answers File When executing `create-project`, if you exit the program while in the middle of the question prompts, you might notice it creates a `.starter-kit-answers` file in the project directory. When you return later and run `composer starter-kit`, it will use this file to pre-fill any questions you've already answered. Once finished, the starter kit removes this file. You may also use an existing answers file to provide all your answers to the prompts, including skipping the question prompts. To do this, set an environment variable with the path to your answers file: ```shell STARTER_KIT_ANSWERS_FILE=/path/to/starter-kit-answers.json ``` To skip the question prompts, make sure you include the `skipPrompts` property in the answers file, and set it to `true`. The answers file is a JSON object, consisting of all the public properties found in `Ramsey\Dev\LibraryStarterKit\Answers`. For example: ```json { "authorEmail": "author@example.com", "authorHoldsCopyright": true, "authorName": "Author Smith", "authorUrl": "https://example.com/", "codeOfConduct": "Contributor-2.0", "codeOfConductCommittee": null, "codeOfConductEmail": "conduct@example.com", "codeOfConductPoliciesUrl": null, "codeOfConductReportingUrl": null, "copyrightEmail": "author@example.com", "copyrightHolder": "Acme, Inc.", "copyrightUrl": "https://example.com/acme", "copyrightYear": "2021", "githubUsername": "example", "license": "MIT", "packageDescription": "An awesome library that does stuff.", "packageKeywords": [ "awesome", "stuff" ], "packageName": "acme/awesome", "packageNamespace": "Acme\\Awesome", "projectName": "My Awesome Library", "securityPolicy": true, "securityPolicyContactEmail": "security@example.com", "securityPolicyContactFormUrl": null, "skipPrompts": true, "vendorName": "acme" } ``` ## Contributing Contributions are welcome! To contribute, please familiarize yourself with [CONTRIBUTING.md](CONTRIBUTING.md). ## Coordinated Disclosure Keeping user information safe and secure is a top priority, and we welcome the contribution of external security researchers. If you believe you've found a security issue in software that is maintained in this repository, please read [SECURITY.md](SECURITY.md) for instructions on submitting a vulnerability report. ## FAQs ### Why did you include package/tool *x* and not *y*? I created this project starter kit for my own uses, and these are the common files, packages, and tools I use in my PHP libraries. If you like what you see, feel free to use it. If you like some of it but not all, fork it and customize it to fit your needs. I hope you find it helpful! ## Copyright and License ramsey/php-library-starter-kit is copyright © [Ben Ramsey](https://benramsey.com) and licensed for use under the terms of the MIT License (MIT). Please see [LICENSE](LICENSE) for more information. ================================================ FILE: SECURITY.md ================================================ # Vulnerability Disclosure Policy (VDP) ## Brand Promise Keeping user information safe and secure is a top priority, and we welcome the contribution of external security researchers. ## Scope If you believe you've found a security issue in software that is maintained in this repository, we encourage you to notify us. | Version | In scope | Source code | | ------- | :------: | ----------- | | latest | ✅ | https://github.com/ramsey/php-library-starter-kit | ## How to Submit a Report To submit a vulnerability report, please contact us at security@ramsey.dev. Your submission will be reviewed and validated by a member of our team. ## Safe Harbor We support safe harbor for security researchers who: * Make a good faith effort to avoid privacy violations, destruction of data, and interruption or degradation of our services. * Only interact with accounts you own or with explicit permission of the account holder. If you do encounter Personally Identifiable Information (PII) contact us immediately, do not proceed with access, and immediately purge any local information. * Provide us with a reasonable amount of time to resolve vulnerabilities prior to any disclosure to the public or a third party. We will consider activities conducted consistent with this policy to constitute "authorized" conduct and will not pursue civil action or initiate a complaint to law enforcement. We will help to the extent we can if legal action is initiated by a third party against you. Please submit a report to us before engaging in conduct that may be inconsistent with or unaddressed by this policy. ## Preferences * Please provide detailed reports with reproducible steps and a clearly defined impact. * Include the version number of the vulnerable package in your report * Social engineering (e.g. phishing, vishing, smishing) is prohibited. ## Encryption Key for security@ramsey.dev For increased privacy when reporting sensitive issues, you may encrypt your message using the following public key: ``` -----BEGIN PGP PUBLIC KEY BLOCK----- mQINBF+Z9gEBEACbT/pIx8RR0K18t8Z2rDnmEV44YdT7HNsMdq+D6SAlx8UUb6AU jGIbV9dgBgGNtOLU1pxloaJwL9bWIRbj+X/Qb2WNIP//Vz1Y40ox1dSpfCUrizXx kb4p58Xml0PsB8dg3b4RDUgKwGC37ne5xmDnigyJPbiB2XJ6Xc46oPCjh86XROTK wEBB2lY67ClBlSlvC2V9KmbTboRQkLdQDhOaUosMb99zRb0EWqDLaFkZVjY5HI7i 0pTveE6dI12NfHhTwKjZ5pUiAZQGlKA6J1dMjY2unxHZkQj5MlMfrLSyJHZxccdJ xD94T6OTcTHt/XmMpI2AObpewZDdChDQmcYDZXGfAhFoJmbvXsmLMGXKgzKoZ/ls RmLsQhh7+/r8E+Pn5r+A6Hh4uAc14ApyEP0ckKeIXw1C6pepHM4E8TEXVr/IA6K/ z6jlHORixIFX7iNOnfHh+qwOgZw40D6JnBfEzjFi+T2Cy+JzN2uy7I8UnecTMGo3 5t6astPy6xcH6kZYzFTV7XERR6LIIVyLAiMFd8kF5MbJ8N5ElRFsFHPW+82N2HDX c60iSaTB85k6R6xd8JIKDiaKE4sSuw2wHFCKq33d/GamYezp1wO+bVUQg88efljC 2JNFyD+vl30josqhw1HcmbE1TP3DlYeIL5jQOlxCMsgai6JtTfHFM/5MYwARAQAB tBNzZWN1cml0eUByYW1zZXkuZGV2iQJUBBMBCAA+FiEE4drPD+/ofZ570fAYq0bv vXQCywIFAl+Z9gECGwMFCQeGH4AFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQ q0bvvXQCywIkEA//Qcwv8MtTCy01LHZd9c7VslwhNdXQDYymcTyjcYw8x7O22m4B 3hXE6vqAplFhVxxkqXB2ef0tQuzxhPHNJgkCE4Wq4i+V6qGpaSVHQT2W6DN/NIhL vS8OdScc6zddmIbIkSrzVVAtjwehFNEIrX3DnbbbK+Iku7vsKT5EclOluIsjlYoX goW8IeReyDBqOe2H3hoCGw6EA0D/NYV2bJnfy53rXVIyarsXXeOLp7eNEH6Td7aW PVSrMZJe1t+knrEGnEdrXWzlg4lCJJCtemGv+pKBUomnyISXSdqyoRCCzvQjqyig 2kRebUX8BXPW33p4OXPj9sIboUOjZwormWwqqbFMO+J4TiVCUoEoheI7emPFRcNN QtPJrjbY1++OznBc0GRpfeUkGoU1cbRl1bnepnFIZMTDLkrVW6I1Y4q8ZVwX3BkE N81ctFrRpHBlU36EdHvjPQmGtuiL77Qq3fWmMv7yTvK1wHJAXfEb0ZJWHZCbck3w l0CVq0Z+UUAOM8Rp1N0N8m92xtapav0qCFU9qzf2J5qX6GRmWv+d29wPgFHzDWBm nnrYYIA4wJLx00U6SMcVBSnNe91B+RfGY5XQhbWPjQQecOGCSDsxaFAq2MeOVJyZ bIjLYfG9GxoLKr5R7oLRJvZI4nKKBc1Kci/crZbdiSdQhSQGlDz88F1OHeCIdQQQ EQgAHRYhBOhdAxHd+lus86YQ57Atl5icjAcbBQJfmfdIAAoJELAtl5icjAcbFVcA /1LqB3ZjsnXDAvvAXZVjSPqofSlpMLeRQP6IM/A9Odq0AQCZrtZc1knOMGEcjppK Rk+sy/R0Mshy8TDuaZIRgh2Ux7kCDQRfmfYBARAAmchKzzVz7IaEq7PnZDb3szQs T/+E9F3m39yOpV4fEB1YzObonFakXNT7Gw2tZEx0eitUMqQ/13jjfu3UdzlKl2bR qA8LrSQRhB+PTC9A1XvwxCUYhhjGiLzJ9CZL6hBQB43qHOmE9XJPme90geLsF+gK u39Waj1SNWzwGg+Gy1Gl5f2AJoDTxznreCuFGj+Vfaczt/hlfgqpOdb9jsmdoE7t 3DSWppA9dRHWwQSgE6J28rR4QySBcqyXS6IMykqaJn7Z26yNIaITLnHCZOSY8zhP ha7GFsN549EOCgECbrnPt9dmI2+hQE0RO0e7SOBNsIf5sz/i7urhwuj0CbOqhjc2 X1AEVNFCVcb6HPi/AWefdFCRu0gaWQxn5g+9nkq5slEgvzCCiKYzaBIcr8qR6Hb4 FaOPVPxO8vndRouq57Ws8XpAwbPttioFuCqF4u9K+tK/8e2/R8QgRYJsE3Cz/Fu8 +pZFpMnqbDEbK3DL3ss+1ed1sky+mDV8qXXeI33XW5hMFnk1JWshUjHNlQmE6ftC U0xSTMVUtwJhzH2zDp8lEdu7qi3EsNULOl68ozDr6soWAvCbHPeTdTOnFySGCleG /3TonsoZJs/sSPPJnxFQ1DtgQL6EbhIwa0ZwU4eKYVHZ9tjxuMX3teFzRvOrJjgs +ywGlsIURtEckT5Y6nMAEQEAAYkCPAQYAQgAJhYhBOHazw/v6H2ee9HwGKtG7710 AssCBQJfmfYBAhsMBQkHhh+AAAoJEKtG7710AssC8NcP/iDAcy1aZFvkA0EbZ85p i7/+ywtE/1wF4U4/9OuLcoskqGGnl1pJNPooMOSBCfreoTB8HimT0Fln0CoaOm4Q pScNq39JXmf4VxauqUJVARByP6zUfgYarqoaZNeuFF0S4AZJ2HhGzaQPjDz1uKVM PE6tQSgQkFzdZ9AtRA4vElTH6yRAgmepUsOihk0b0gUtVnwtRYZ8e0Qt3ie97a73 DxLgAgedFRUbLRYiT0vNaYbainBsLWKpN/T8odwIg/smP0Khjp/ckV60cZTdBiPR szBTPJESMUTu0VPntc4gWwGsmhZJg/Tt/qP08XYo3VxNYBegyuWwNR66zDWvwvGH muMv5UchuDxp6Rt3JkIO4voMT1JSjWy9p8krkPEE4V6PxAagLjdZSkt92wVLiK5x y5gNrtPhU45YdRAKHr36OvJBJQ42CDaZ6nzrzghcIp9CZ7ANHrI+QLRM/csz+AGA szSp6S4mc1lnxxfbOhPPpebZPn0nIAXoZnnoVKdrxBVedPQHT59ZFvKTQ9Fs7gd3 sYNuc7tJGFGC2CxBH4ANDpOQkc5q9JJ1HSGrXU3juxIiRgfA26Q22S9c71dXjElw Ri584QH+bL6kkYmm8xpKF6TVwhwu5xx/jBPrbWqFrtbvLNrnfPoapTihBfdIhkT6 nmgawbBHA02D5xEqB5SU3WJu =eJNx -----END PGP PUBLIC KEY BLOCK----- ``` ================================================ FILE: bin/.gitkeep ================================================ ================================================ FILE: build/.gitignore ================================================ * !.gitignore cache/* !cache !cache/.gitkeep coverage/* !coverage !coverage/.gitkeep logs/* !logs !logs/.gitkeep ================================================ FILE: build/cache/.gitkeep ================================================ ================================================ FILE: build/coverage/.gitkeep ================================================ ================================================ FILE: build/logs/.gitkeep ================================================ ================================================ FILE: captainhook.json ================================================ { "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": [] } } ================================================ FILE: codecov.yml ================================================ 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 ================================================ FILE: composer.json ================================================ { "name": "ramsey/php-library-starter-kit", "description": "A starter kit for quickly setting up a new PHP library package.", "license": "MIT", "type": "project", "keywords": [ "builder", "library", "package", "skeleton", "template" ], "authors": [ { "name": "Ben Ramsey", "email": "ben@benramsey.com", "homepage": "https://benramsey.com" } ], "require": { "php": "^8.1", "symfony/finder": "^6.4 || ^7.2", "twig/twig": "^3.20" }, "require-dev": { "ramsey/devtools": "^2.1", "spatie/phpunit-snapshot-assertions": "^5.1" }, "suggest": { "ext-pcntl": "Provides the ability to quit and resume the starter kit wizard on POSIX systems" }, "minimum-stability": "dev", "prefer-stable": true, "autoload": { "psr-4": { "Ramsey\\Dev\\LibraryStarterKit\\": "src/LibraryStarterKit/", "Vendor\\SubNamespace\\": "src/" } }, "autoload-dev": { "psr-4": { "Ramsey\\Test\\Dev\\LibraryStarterKit\\": "tests/LibraryStarterKit/", "Vendor\\Test\\SubNamespace\\": "tests/" } }, "config": { "allow-plugins": { "captainhook/plugin-composer": true, "dealerdirect/phpcodesniffer-composer-installer": true, "ergebnis/composer-normalize": true, "php-http/discovery": true, "phpstan/extension-installer": true, "ramsey/composer-repl": true, "ramsey/devtools": true }, "sort-packages": true }, "extra": { "captainhook": { "force-install": true }, "ramsey/conventional-commits": { "configFile": "conventional-commits.json" }, "ramsey/devtools": { "command-prefix": "dev", "memory-limit": "-1" } }, "scripts": { "post-root-package-install": "git init", "post-create-project-cmd": "Ramsey\\Dev\\LibraryStarterKit\\Wizard::start", "starter-kit": "Ramsey\\Dev\\LibraryStarterKit\\Wizard::start" }, "scripts-descriptions": { "starter-kit": "Runs the PHP Library Starter Kit wizard." } } ================================================ FILE: conventional-commits.json ================================================ { "typeCase": "kebab", "types": [ "chore", "ci", "docs", "feat", "fix", "refactor", "security", "style", "test" ], "scopeCase": "kebab", "scopeRequired": false, "scopes": [], "descriptionCase": null, "descriptionEndMark": "", "bodyRequired": false, "bodyWrapWidth": 72, "requiredFooters": [] } ================================================ FILE: docs/.gitkeep ================================================ ================================================ FILE: phpcs.xml.dist ================================================ ./src ./tests ================================================ FILE: phpstan.neon.dist ================================================ parameters: tmpDir: ./build/cache/phpstan treatPhpDocTypesAsCertain: false level: max paths: - ./src - ./tests ================================================ FILE: phpunit.xml.dist ================================================ ./tests ./src ================================================ FILE: psalm.xml ================================================ ================================================ FILE: resources/.gitkeep ================================================ ================================================ FILE: resources/templates/CHANGELOG.md.twig ================================================ # {{ packageName }} Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## 0.1.0 - TBD ### Added - Nothing. ### Changed - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Nothing. ================================================ FILE: resources/templates/CONTRIBUTING.md.twig ================================================ # Contributing Contributions are welcome. This project accepts pull requests on [GitHub][]. {% if codeOfConduct != 'None' %} 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. {% endif %} ## 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. * {{ packageName }} 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. {{ packageName }} 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/PHPCSStandards/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/{{ packageName }} [issues]: https://github.com/{{ packageName }}/issues [pull requests]: https://github.com/{{ packageName }}/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/ ================================================ FILE: resources/templates/FUNDING.yml.twig ================================================ ================================================ FILE: resources/templates/code-of-conduct/Citizen-2.3.md.twig ================================================ # Citizen Code of Conduct ## 1. Purpose A primary goal of {{ packageName }} 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 {{ packageName }} 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 {{ packageName }} 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. {{ codeOfConductEmail }} {% if codeOfConductReportingUrl %} {{ codeOfConductReportingUrl }} {% else %} {% endif %} 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 {% if codeOfConductCommittee %}{{ codeOfConductCommittee }}{% else %}the {{ packageName }} project lead(s) {% endif %} with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies. {% if codeOfConductPoliciesUrl %} {{ codeOfConductPoliciesUrl }} {% else %} {% endif %} ## 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 {{ codeOfConductEmail }} ## 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.* ================================================ FILE: resources/templates/code-of-conduct/Contributor-1.4.md.twig ================================================ # Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at {{ codeOfConductEmail }}. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq ================================================ FILE: resources/templates/code-of-conduct/Contributor-2.0.md.twig ================================================ # Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at {{ codeOfConductEmail }}. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. ================================================ FILE: resources/templates/code-of-conduct/Contributor-2.1.md.twig ================================================ # Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at {{ codeOfConductEmail }}. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations]. [homepage]: https://www.contributor-covenant.org [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html [Mozilla CoC]: https://github.com/mozilla/diversity [FAQ]: https://www.contributor-covenant.org/faq [translations]: https://www.contributor-covenant.org/translations ================================================ FILE: resources/templates/header/AGPL-3.0-or-later.twig ================================================ {{ packageName }} is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. {{ packageName }} is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with {{ packageName }}. If not, see . @copyright {{ copyright }} @license https://opensource.org/license/agpl-v3/ GNU Affero General Public License version 3 or later ================================================ FILE: resources/templates/header/Apache-2.0.twig ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 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 }} @license https://opensource.org/license/apache-2-0/ Apache License, Version 2.0 ================================================ FILE: resources/templates/header/BSD-2-Clause.twig ================================================ @copyright {{ copyright }} @license https://opensource.org/license/bsd-2-clause/ BSD 2-Clause "Simplified" License ================================================ FILE: resources/templates/header/BSD-3-Clause.twig ================================================ @copyright {{ copyright }} @license https://opensource.org/license/bsd-3-clause/ BSD 3-Clause "New" or "Revised" License ================================================ FILE: resources/templates/header/CC0-1.0.twig ================================================ To the extent possible under law, {{ copyrightHolder }} has waived all copyright and related or neighboring rights to {{ packageName }}. @license https://creativecommons.org/publicdomain/zero/1.0/ CC0 1.0 Universal ================================================ FILE: resources/templates/header/GPL-3.0-or-later.twig ================================================ {{ packageName }} is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. {{ packageName }} is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with {{ packageName }}. If not, see . @copyright {{ copyright }} @license https://opensource.org/license/gpl-3-0/ GNU General Public License version 3 or later ================================================ FILE: resources/templates/header/Hippocratic-2.1.twig ================================================ @copyright {{ copyright }} @license https://spdx.org/licenses/Hippocratic-2.1.html Hippocratic License 2.1 ================================================ FILE: resources/templates/header/LGPL-3.0-or-later.twig ================================================ {{ packageName }} is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. {{ packageName }} is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with {{ packageName }}. If not, see . @copyright {{ copyright }} @license https://opensource.org/license/lgpl-3-0/ GNU Lesser General Public License version 3 or later ================================================ FILE: resources/templates/header/MIT-0.twig ================================================ @copyright {{ copyright }} @license https://opensource.org/license/mit-0/ MIT No Attribution ================================================ FILE: resources/templates/header/MIT.twig ================================================ @copyright {{ copyright }} @license https://opensource.org/license/mit/ MIT License ================================================ FILE: resources/templates/header/MPL-2.0.twig ================================================ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. @copyright {{ copyright }} @license https://opensource.org/license/mpl-2-0/ Mozilla Public License 2.0 ================================================ FILE: resources/templates/header/Proprietary.twig ================================================ @copyright {{ copyright }}. All rights reserved. ================================================ FILE: resources/templates/header/Unlicense.twig ================================================ {{ packageName }} is free and unencumbered software released into the public domain. For more information, please view the UNLICENSE file that was distributed with this source code. @license https://opensource.org/license/unlicense/ The Unlicense ================================================ FILE: resources/templates/header/source-file-header.twig ================================================ {% set headerTemplate %}header/{{ license }}.twig{% endset %} {% set copyright %}Copyright (c) {{ copyrightHolder }}{% if copyrightEmail %} <{{ copyrightEmail }}>{% elseif copyrightUrl %} <{{ copyrightUrl }}>{% endif %}{% endset %} {% set licenseStatement %}{{ include(headerTemplate) }}{% endset %} /** * This file is part of {{ packageName }} * {{ licenseStatement|preg_replace('/^/m', ' * ')|preg_replace('/\\s+$/m', '')|trim }} */ ================================================ FILE: resources/templates/license/AGPL-3.0-or-later-NOTICE.twig ================================================ {{ include('license/copyright-statement.twig') }} This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . ================================================ FILE: resources/templates/license/AGPL-3.0-or-later.twig ================================================ GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU Affero General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Remote Network Interaction; Use with the GNU General Public License. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . ================================================ FILE: resources/templates/license/Apache-2.0-NOTICE.twig ================================================ {{ include('license/copyright-statement.twig') }} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 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. ================================================ FILE: resources/templates/license/Apache-2.0.twig ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 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. ================================================ FILE: resources/templates/license/BSD-2-Clause.twig ================================================ {{ include('license/copyright-statement.twig') }} All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: resources/templates/license/BSD-3-Clause.twig ================================================ {{ include('license/copyright-statement.twig') }} All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: resources/templates/license/CC0-1.0.twig ================================================ Creative Commons Legal Code CC0 1.0 Universal CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER. Statement of Purpose The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work"). Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others. For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights. 1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following: i. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work; ii. moral rights retained by the original author(s) and/or performer(s); iii. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work; iv. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below; v. rights protecting the extraction, dissemination, use and reuse of data in a Work; vi. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and vii. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof. 2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose. 3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose. 4. Limitations and Disclaimers. a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document. b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law. c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work. d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. ================================================ FILE: resources/templates/license/GPL-3.0-or-later-NOTICE.twig ================================================ {{ include('license/copyright-statement.twig') }} This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ================================================ FILE: resources/templates/license/GPL-3.0-or-later.twig ================================================ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ================================================ FILE: resources/templates/license/Hippocratic-2.1.twig ================================================ {{ include('license/copyright-statement.twig') }} (“Licensor”) Hippocratic License Version Number: 2.1. Purpose. The purpose of this License is for the Licensor named above to permit the Licensee (as defined below) broad permission, if consistent with Human Rights Laws and Human Rights Principles (as each is defined below), to use and work with the Software (as defined below) within the full scope of Licensor’s copyright and patent rights, if any, in the Software, while ensuring attribution and protecting the Licensor from liability. Permission and Conditions. The Licensor grants permission by this license (“License”), free of charge, to the extent of Licensor’s rights under applicable copyright and patent law, to any person or entity (the “Licensee”) obtaining a copy of this software and associated documentation files (the “Software”), to do everything with the Software that would otherwise infringe (i) the Licensor’s copyright in the Software or (ii) any patent claims to the Software that the Licensor can license or becomes able to license, subject to all of the following terms and conditions: * Acceptance. This License is automatically offered to every person and entity subject to its terms and conditions. Licensee accepts this License and agrees to its terms and conditions by taking any action with the Software that, absent this License, would infringe any intellectual property right held by Licensor. * Notice. Licensee must ensure that everyone who gets a copy of any part of this Software from Licensee, with or without changes, also receives the License and the above copyright notice (and if included by the Licensor, patent, trademark and attribution notice). Licensee must cause any modified versions of the Software to carry prominent notices stating that Licensee changed the Software. For clarity, although Licensee is free to create modifications of the Software and distribute only the modified portion created by Licensee with additional or different terms, the portion of the Software not modified must be distributed pursuant to this License. If anyone notifies Licensee in writing that Licensee has not complied with this Notice section, Licensee can keep this License by taking all practical steps to comply within 30 days after the notice. If Licensee does not do so, Licensee’s License (and all rights licensed hereunder) shall end immediately. * Compliance with Human Rights Principles and Human Rights Laws. 1. Human Rights Principles. (a) Licensee is advised to consult the articles of the United Nations Universal Declaration of Human Rights and the United Nations Global Compact that define recognized principles of international human rights (the “Human Rights Principles”). Licensee shall use the Software in a manner consistent with Human Rights Principles. (b) Unless the Licensor and Licensee agree otherwise, any dispute, controversy, or claim arising out of or relating to (i) Section 1(a) regarding Human Rights Principles, including the breach of Section 1(a), termination of this License for breach of the Human Rights Principles, or invalidity of Section 1(a) or (ii) a determination of whether any Law is consistent or in conflict with Human Rights Principles pursuant to Section 2, below, shall be settled by arbitration in accordance with the Hague Rules on Business and Human Rights Arbitration (the “Rules”); provided, however, that Licensee may elect not to participate in such arbitration, in which event this License (and all rights licensed hereunder) shall end immediately. The number of arbitrators shall be one unless the Rules require otherwise. Unless both the Licensor and Licensee agree to the contrary: (1) All documents and information concerning the arbitration shall be public and may be disclosed by any party; (2) The repository referred to under Article 43 of the Rules shall make available to the public in a timely manner all documents concerning the arbitration which are communicated to it, including all submissions of the parties, all evidence admitted into the record of the proceedings, all transcripts or other recordings of hearings and all orders, decisions and awards of the arbitral tribunal, subject only to the arbitral tribunal's powers to take such measures as may be necessary to safeguard the integrity of the arbitral process pursuant to Articles 18, 33, 41 and 42 of the Rules; and (3) Article 26(6) of the Rules shall not apply. 2. Human Rights Laws. The Software shall not be used by any person or entity for any systems, activities, or other uses that violate any Human Rights Laws. “Human Rights Laws” means any applicable laws, regulations, or rules (collectively, “Laws”) that protect human, civil, labor, privacy, political, environmental, security, economic, due process, or similar rights; provided, however, that such Laws are consistent and not in conflict with Human Rights Principles (a dispute over the consistency or a conflict between Laws and Human Rights Principles shall be determined by arbitration as stated above). Where the Human Rights Laws of more than one jurisdiction are applicable or in conflict with respect to the use of the Software, the Human Rights Laws that are most protective of the individuals or groups harmed shall apply. 3. Indemnity. Licensee shall hold harmless and indemnify Licensor (and any other contributor) against all losses, damages, liabilities, deficiencies, claims, actions, judgments, settlements, interest, awards, penalties, fines, costs, or expenses of whatever kind, including Licensor’s reasonable attorneys’ fees, arising out of or relating to Licensee’s use of the Software in violation of Human Rights Laws or Human Rights Principles. * Failure to Comply. Any failure of Licensee to act according to the terms and conditions of this License is both a breach of the License and an infringement of the intellectual property rights of the Licensor (subject to exceptions under Laws, e.g., fair use). In the event of a breach or infringement, the terms and conditions of this License may be enforced by Licensor under the Laws of any jurisdiction to which Licensee is subject. Licensee also agrees that the Licensor may enforce the terms and conditions of this License against Licensee through specific performance (or similar remedy under Laws) to the extent permitted by Laws. For clarity, except in the event of a breach of this License, infringement, or as otherwise stated in this License, Licensor may not terminate this License with Licensee. * Enforceability and Interpretation. If any term or provision of this License is determined to be invalid, illegal, or unenforceable by a court of competent jurisdiction, then such invalidity, illegality, or unenforceability shall not affect any other term or provision of this License or invalidate or render unenforceable such term or provision in any other jurisdiction; provided, however, subject to a court modification pursuant to the immediately following sentence, if any term or provision of this License pertaining to Human Rights Laws or Human Rights Principles is deemed invalid, illegal, or unenforceable against Licensee by a court of competent jurisdiction, all rights in the Software granted to Licensee shall be deemed null and void as between Licensor and Licensee. Upon a determination that any term or provision is invalid, illegal, or unenforceable, to the extent permitted by Laws, the court may modify this License to affect the original purpose that the Software be used in compliance with Human Rights Principles and Human Rights Laws as closely as possible. The language in this License shall be interpreted as to its fair meaning and not strictly for or against any party. * Disclaimer. TO THE FULL EXTENT ALLOWED BY LAW, THIS SOFTWARE COMES “AS IS,” WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED, AND LICENSOR AND ANY OTHER CONTRIBUTOR SHALL NOT BE LIABLE TO ANYONE FOR ANY DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THIS LICENSE, UNDER ANY KIND OF LEGAL CLAIM. This Hippocratic License is an Ethical Source license (https://ethicalsource.dev) and is offered for use by licensors and licensees at their own risk, on an “AS IS” basis, and with no warranties express or implied, to the maximum extent permitted by Laws. ================================================ FILE: resources/templates/license/LGPL-3.0-or-later-NOTICE.twig ================================================ {{ include('license/copyright-statement.twig') }} This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . ================================================ FILE: resources/templates/license/LGPL-3.0-or-later.twig ================================================ GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. ================================================ FILE: resources/templates/license/MIT-0.twig ================================================ {{ include('license/copyright-statement.twig') }} 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. 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. ================================================ FILE: resources/templates/license/MIT.twig ================================================ {{ include('license/copyright-statement.twig') }} 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. ================================================ FILE: resources/templates/license/MPL-2.0-NOTICE.twig ================================================ {{ include('license/copyright-statement.twig') }} This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ================================================ FILE: resources/templates/license/MPL-2.0.twig ================================================ Mozilla Public License Version 2.0 ================================== 1. Definitions -------------- 1.1. "Contributor" means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. 1.2. "Contributor Version" means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor's Contribution. 1.3. "Contribution" means Covered Software of a particular Contributor. 1.4. "Covered Software" means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. 1.5. "Incompatible With Secondary Licenses" means (a) that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or (b) that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. 1.6. "Executable Form" means any form of the work other than Source Code Form. 1.7. "Larger Work" means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. "License" means this document. 1.9. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. 1.10. "Modifications" means any of the following: (a) any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or (b) any new file in Source Code Form that contains any Covered Software. 1.11. "Patent Claims" of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. 1.12. "Secondary License" means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. 1.13. "Source Code Form" means the form of the work preferred for making modifications. 1.14. "You" (or "Your") means an individual or a legal entity exercising rights under this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. License Grants and Conditions -------------------------------- 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: (a) under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and (b) under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. 2.2. Effective Date The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. 2.3. Limitations on Grant Scope The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: (a) for any code that a Contributor has removed from Covered Software; or (b) for infringements caused by: (i) Your and any other third party's modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or (c) under Patent Claims infringed by Covered Software in the absence of its Contributions. This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). 2.4. Subsequent Licenses No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). 2.5. Representation Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. 2.6. Fair Use This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. 2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. 3. Responsibilities ------------------- 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients' rights in the Source Code Form. 3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then: (a) such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and (b) You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients' rights in the Source Code Form under this License. 3.3. Distribution of a Larger Work You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). 3.4. Notices You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. 3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. 4. Inability to Comply Due to Statute or Regulation --------------------------------------------------- If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Termination -------------- 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. ************************************************************************ * * * 6. Disclaimer of Warranty * * ------------------------- * * * * Covered Software is provided under this License on an "as is" * * basis, without warranty of any kind, either expressed, implied, or * * statutory, including, without limitation, warranties that the * * Covered Software is free of defects, merchantable, fit for a * * particular purpose or non-infringing. The entire risk as to the * * quality and performance of the Covered Software is with You. * * Should any Covered Software prove defective in any respect, You * * (not any Contributor) assume the cost of any necessary servicing, * * repair, or correction. This disclaimer of warranty constitutes an * * essential part of this License. No use of any Covered Software is * * authorized under this License except under this disclaimer. * * * ************************************************************************ ************************************************************************ * * * 7. Limitation of Liability * * -------------------------- * * * * Under no circumstances and under no legal theory, whether tort * * (including negligence), contract, or otherwise, shall any * * Contributor, or anyone who distributes Covered Software as * * permitted above, be liable to You for any direct, indirect, * * special, incidental, or consequential damages of any character * * including, without limitation, damages for lost profits, loss of * * goodwill, work stoppage, computer failure or malfunction, or any * * and all other commercial damages or losses, even if such party * * shall have been informed of the possibility of such damages. This * * limitation of liability shall not apply to liability for death or * * personal injury resulting from such party's negligence to the * * extent applicable law prohibits such limitation. Some * * jurisdictions do not allow the exclusion or limitation of * * incidental or consequential damages, so this exclusion and * * limitation may not apply to You. * * * ************************************************************************ 8. Litigation ------------- Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party's ability to bring cross-claims or counter-claims. 9. Miscellaneous ---------------- This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. 10. Versions of the License --------------------------- 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. 10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. 10.3. Modified Versions If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. Exhibit A - Source Code Form License Notice ------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. You may add additional accurate notices of copyright ownership. Exhibit B - "Incompatible With Secondary Licenses" Notice --------------------------------------------------------- This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. ================================================ FILE: resources/templates/license/Proprietary.twig ================================================ {{ include('license/copyright-statement.twig') }}. All rights reserved. ================================================ FILE: resources/templates/license/Unlicense.twig ================================================ This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. 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 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. For more information, please refer to ================================================ FILE: resources/templates/license/copyright-statement.twig ================================================ Copyright (c) {{ 'now'|date('Y') }} {{ copyrightHolder }}{% if copyrightEmail %} <{{ copyrightEmail }}>{% elseif copyrightUrl %} <{{ copyrightUrl }}>{% endif %} ================================================ FILE: resources/templates/readme/badges.md.twig ================================================ {% if packageDescription %}

{{ packageDescription }}

{% endif %} ================================================ FILE: resources/templates/readme/code-of-conduct.md.twig ================================================ 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. ================================================ FILE: resources/templates/readme/copyright.md.twig ================================================ {% set copyright %}{% if copyrightUrl %}[{{ copyrightHolder }}]({{ copyrightUrl }}){% elseif copyrightEmail %}[{{ copyrightHolder }}](mailto:{{ copyrightEmail }}){% else %}{{ copyrightHolder }}{% endif %}{% endset %} {% set licenseStatement %} {% if license == 'AGPL-3.0-or-later' %} GNU Affero General Public License (AGPL-3.0-or-later) as published by the Free Software Foundation. Please see [COPYING](COPYING) and [NOTICE](NOTICE) for more information. {% elseif license == 'Apache-2.0' %} Apache License, Version 2.0 (Apache-2.0). Please see [LICENSE](LICENSE) and [NOTICE](NOTICE) for more information. {% elseif license == 'BSD-2-Clause' %} BSD 2-Clause "Simplified" License (BSD-2-Clause). Please see [LICENSE](LICENSE) for more information. {% elseif license == 'BSD-3-Clause' %} BSD 3-Clause "New" or "Revised" License (BSD-3-Clause). Please see [LICENSE](LICENSE) for more information. {% elseif license == 'GPL-3.0-or-later' %} GNU General Public License (GPL-3.0-or-later) as published by the Free Software Foundation. Please see [COPYING](COPYING) and [NOTICE](NOTICE) for more information. {% elseif license == 'LGPL-3.0-or-later' %} GNU Lesser General Public License (LGPL-3.0-or-later) as published by the Free Software Foundation. Please see [COPYING.LESSER](COPYING.LESSER), [COPYING](COPYING), and [NOTICE](NOTICE) for more information. {% elseif license == 'MIT' %} MIT License (MIT). Please see [LICENSE](LICENSE) for more information. {% elseif license == 'MIT-0' %} MIT No Attribution (MIT-0) license. Please see [LICENSE](LICENSE) for more information. {% elseif license == 'MPL-2.0' %} Mozilla Public License 2.0 (MPL-2.0). Please see [LICENSE](LICENSE) and [NOTICE](NOTICE) for more information. {% endif %} {% endset %} ## Copyright and License {% if license == 'Unlicense' %} {{ packageName }} is free and unencumbered software released into the public domain. Please see [UNLICENSE](UNLICENSE) for more information. {% elseif license == 'CC0-1.0' %} To the extent possible under law, {{ copyright }} has waived all copyright and related or neighboring rights to {{ packageName }}. Please see [LICENSE](LICENSE) for more information. CC0 {% elseif license == 'Proprietary' %} {{ packageName }} is copyright © {{ copyright }}. All rights reserved. {% else %} {{ packageName }} is copyright © {{ copyright }} and licensed for use under the terms of the {{ licenseStatement }} {% endif %} ================================================ FILE: resources/templates/readme/description.md.twig ================================================ ## About ================================================ FILE: resources/templates/readme/security.md.twig ================================================ ## Coordinated Disclosure Keeping user information safe and secure is a top priority, and we welcome the contribution of external security researchers. If you believe you've found a security issue in software that is maintained in this repository, please read [SECURITY.md](SECURITY.md) for instructions on submitting a vulnerability report. ================================================ FILE: resources/templates/readme/usage.md.twig ================================================ ## Installation Install this package as a dependency using [Composer](https://getcomposer.org). ``` bash composer require {{ packageName }} ``` ================================================ FILE: resources/templates/security-policy/HackerOne.md.twig ================================================ # Vulnerability Disclosure Policy (VDP) ## Brand Promise Keeping user information safe and secure is a top priority, and we welcome the contribution of external security researchers. ## Scope If you believe you've found a security issue in software that is maintained in this repository, we encourage you to notify us. | Version | In scope | Source code | | ------- | :------: | ----------- | | latest | ✅ | https://github.com/{{ packageName }} | ## How to Submit a Report To submit a vulnerability report, please {% if securityPolicyContactFormUrl %}fill out this [form]({{ securityPolicyContactFormUrl }}){% endif %}{% if securityPolicyContactFormUrl and securityPolicyContactFormUrl %} or {% endif %}{% if securityPolicyContactEmail %}contact us at {{ securityPolicyContactEmail }}{% endif %}{% if not securityPolicyContactFormUrl and not securityPolicyContactEmail %}contact us{% endif %}. Your submission will be reviewed and validated by a member of our team. ## Safe Harbor We support safe harbor for security researchers who: * Make a good faith effort to avoid privacy violations, destruction of data, and interruption or degradation of our services. * Only interact with accounts you own or with explicit permission of the account holder. If you do encounter Personally Identifiable Information (PII) contact us immediately, do not proceed with access, and immediately purge any local information. * Provide us with a reasonable amount of time to resolve vulnerabilities prior to any disclosure to the public or a third party. We will consider activities conducted consistent with this policy to constitute "authorized" conduct and will not pursue civil action or initiate a complaint to law enforcement. We will help to the extent we can if legal action is initiated by a third party against you. Please submit a report to us before engaging in conduct that may be inconsistent with or unaddressed by this policy. ## Preferences * Please provide detailed reports with reproducible steps and a clearly defined impact. * Include the version number of the vulnerable package in your report * Social engineering (e.g. phishing, vishing, smishing) is prohibited. ================================================ FILE: src/Example.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Vendor\SubNamespace; /** * 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}!"; } } ================================================ FILE: src/LibraryStarterKit/Answers.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit; use Ramsey\Dev\LibraryStarterKit\Console\Question\CodeOfConduct; use Ramsey\Dev\LibraryStarterKit\Console\Question\License; use ReflectionObject; use ReflectionProperty; use function array_keys; use function array_values; use function json_decode; use function json_encode; use function property_exists; use const JSON_PRETTY_PRINT; use const JSON_UNESCAPED_SLASHES; use const JSON_UNESCAPED_UNICODE; /** * Answers to questions prompted to the user building a library */ final class Answers { public ?string $authorEmail = null; public bool $authorHoldsCopyright = true; public ?string $authorName = null; public ?string $authorUrl = null; public string $codeOfConduct = CodeOfConduct::DEFAULT; public ?string $codeOfConductCommittee = null; public ?string $codeOfConductEmail = null; public ?string $codeOfConductPoliciesUrl = null; public ?string $codeOfConductReportingUrl = null; public ?string $copyrightEmail = null; public ?string $copyrightHolder = null; public ?string $copyrightUrl = null; public ?string $copyrightYear = null; public ?string $githubUsername = null; public ?string $license = License::DEFAULT; public ?string $packageDescription = null; /** @var string[] */ public array $packageKeywords = []; public ?string $packageName = null; public ?string $packageNamespace = null; public ?string $projectName = null; public bool $securityPolicy = true; public ?string $securityPolicyContactEmail = null; public ?string $securityPolicyContactFormUrl = null; public bool $skipPrompts = false; public ?string $vendorName = null; public function __construct( private readonly string $saveToPath, private readonly Filesystem $filesystem, ) { $this->loadFile(); } /** * Returns the property names a tokens to use in templates * * @return string[] */ public function getTokens(): array { return array_keys($this->getArrayCopy()); } /** * Returns the property values to replace tokens in template * * @return array */ public function getValues(): array { return array_values($this->getArrayCopy()); } /** * Returns an array of key-value pairs of token names and values * * @return array */ public function getArrayCopy(): array { $answers = []; $reflected = new ReflectionObject($this); foreach ($reflected->getProperties(ReflectionProperty::IS_PUBLIC) as $property) { /** @var string | string[] | bool | null $value */ $value = $property->getValue($this); $answers[$property->getName()] = $value; } return $answers; } /** * Stores the answers to a JSON file on local disk */ public function saveToFile(): void { $this->filesystem->dumpFile( $this->saveToPath, (string) json_encode( $this->getArrayCopy(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE, ), ); } /** * If an answers file already exists, loads the file and hydrates this * answers instance with the values */ private function loadFile(): void { if (!$this->filesystem->exists($this->saveToPath)) { return; } $file = $this->filesystem->getFile($this->saveToPath); /** @var array $answers */ $answers = json_decode($file->getContents(), true); /** @var mixed $value */ foreach ($answers as $propertyName => $value) { if (property_exists($this, $propertyName)) { $this->{$propertyName} = $value; } } } } ================================================ FILE: src/LibraryStarterKit/Console/InstallQuestions.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console; use Ramsey\Dev\LibraryStarterKit\Answers; use Ramsey\Dev\LibraryStarterKit\Console\Question\AuthorEmail; use Ramsey\Dev\LibraryStarterKit\Console\Question\AuthorHoldsCopyright; use Ramsey\Dev\LibraryStarterKit\Console\Question\AuthorName; use Ramsey\Dev\LibraryStarterKit\Console\Question\AuthorUrl; use Ramsey\Dev\LibraryStarterKit\Console\Question\CodeOfConduct; use Ramsey\Dev\LibraryStarterKit\Console\Question\CodeOfConductCommittee; use Ramsey\Dev\LibraryStarterKit\Console\Question\CodeOfConductEmail; use Ramsey\Dev\LibraryStarterKit\Console\Question\CodeOfConductPoliciesUrl; use Ramsey\Dev\LibraryStarterKit\Console\Question\CodeOfConductReportingUrl; use Ramsey\Dev\LibraryStarterKit\Console\Question\CopyrightEmail; use Ramsey\Dev\LibraryStarterKit\Console\Question\CopyrightHolder; use Ramsey\Dev\LibraryStarterKit\Console\Question\CopyrightUrl; use Ramsey\Dev\LibraryStarterKit\Console\Question\CopyrightYear; use Ramsey\Dev\LibraryStarterKit\Console\Question\GithubUsername; use Ramsey\Dev\LibraryStarterKit\Console\Question\License; use Ramsey\Dev\LibraryStarterKit\Console\Question\PackageDescription; use Ramsey\Dev\LibraryStarterKit\Console\Question\PackageKeywords; use Ramsey\Dev\LibraryStarterKit\Console\Question\PackageName; use Ramsey\Dev\LibraryStarterKit\Console\Question\PackageNamespace; use Ramsey\Dev\LibraryStarterKit\Console\Question\SecurityPolicy; use Ramsey\Dev\LibraryStarterKit\Console\Question\SecurityPolicyContactEmail; use Ramsey\Dev\LibraryStarterKit\Console\Question\SecurityPolicyContactFormUrl; use Ramsey\Dev\LibraryStarterKit\Console\Question\StarterKitQuestion; use Ramsey\Dev\LibraryStarterKit\Console\Question\VendorName; use Symfony\Component\Console\Question\Question as SymfonyQuestion; /** * A list of questions to ask the user upon installation */ class InstallQuestions { /** * @return list */ public function getQuestions(Answers $answers): array { return [ new GithubUsername($answers), new VendorName($answers), new PackageName($answers), new PackageDescription($answers), new AuthorName($answers), new AuthorEmail($answers), new AuthorUrl($answers), new AuthorHoldsCopyright($answers), new CopyrightHolder($answers), new CopyrightEmail($answers), new CopyrightUrl($answers), new CopyrightYear($answers), new License($answers), new SecurityPolicy($answers), new SecurityPolicyContactEmail($answers), new SecurityPolicyContactFormUrl($answers), new CodeOfConduct($answers), new CodeOfConductEmail($answers), new CodeOfConductCommittee($answers), new CodeOfConductPoliciesUrl($answers), new CodeOfConductReportingUrl($answers), new PackageKeywords($answers), new PackageNamespace($answers), ]; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/AnswersTool.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; trait AnswersTool { private Answers $answers; public function getAnswers(): Answers { return $this->answers; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/AuthorEmail.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; /** * Asks for the email address of the library author */ class AuthorEmail extends Question implements StarterKitQuestion { use AnswersTool; use EmailValidatorTool; public function getName(): string { return 'authorEmail'; } public function __construct(Answers $answers) { parent::__construct( 'What is your email address?', $answers->authorEmail, ); $this->answers = $answers; // Require the author's email address. $this->isOptional = false; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/AuthorHoldsCopyright.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\ConfirmationQuestion; /** * Asks whether the author is the same person as the copyright holder */ class AuthorHoldsCopyright extends ConfirmationQuestion implements StarterKitQuestion { use AnswersTool; public function getName(): string { return 'authorHoldsCopyright'; } public function __construct(Answers $answers) { parent::__construct( 'Are you the copyright holder?', $answers->authorHoldsCopyright, ); $this->answers = $answers; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/AuthorName.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; /** * Asks for the name of the library author */ class AuthorName extends Question implements StarterKitQuestion { use AnswersTool; public function getName(): string { return 'authorName'; } public function __construct(Answers $answers) { parent::__construct( 'What is your name?', $answers->authorName, ); $this->answers = $answers; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/AuthorUrl.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; /** * Asks for the URL of the library author */ class AuthorUrl extends Question implements StarterKitQuestion { use AnswersTool; use UrlValidatorTool; public function getName(): string { return 'authorUrl'; } public function __construct(Answers $answers) { parent::__construct( 'What is your website address?', $answers->authorUrl, ); $this->answers = $answers; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/CodeOfConduct.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Ramsey\Dev\LibraryStarterKit\Exception\InvalidConsoleInput; use Symfony\Component\Console\Question\ChoiceQuestion; use function array_combine; use function array_search; use function ctype_digit; use function in_array; use function sprintf; use function trim; /** * Asks for the creator to select a code of conduct for the project */ class CodeOfConduct extends ChoiceQuestion implements StarterKitQuestion { use AnswersTool; public const DEFAULT = 'None'; public const CHOICES = [ 1 => self::DEFAULT, 2 => 'Contributor Covenant Code of Conduct, version 1.4', 3 => 'Contributor Covenant Code of Conduct, version 2.0', 4 => 'Contributor Covenant Code of Conduct, version 2.1', 5 => 'Citizen Code of Conduct, version 2.3', ]; public const CHOICE_IDENTIFIER_MAP = [ 1 => self::DEFAULT, 2 => 'Contributor-1.4', 3 => 'Contributor-2.0', 4 => 'Contributor-2.1', 5 => 'Citizen-2.3', ]; public function getName(): string { return 'codeOfConduct'; } public function __construct(Answers $answers) { parent::__construct( 'Choose a code of conduct for your project', self::CHOICES, array_search($answers->codeOfConduct, self::CHOICE_IDENTIFIER_MAP) ?: 1, ); $this->answers = $answers; } /** * @return callable(string | null): string */ public function getNormalizer(): callable { $choiceMap = array_combine(self::CHOICES, self::CHOICE_IDENTIFIER_MAP); return function (?string $value) use ($choiceMap): string { if (ctype_digit((string) $value)) { return (string) (self::CHOICE_IDENTIFIER_MAP[(int) $value] ?? $value); } return (string) ($choiceMap[trim((string) $value)] ?? $value); }; } /** * @return callable(string | null): (string | null) */ public function getValidator(): callable { return function (?string $value): ?string { if (!in_array($value, self::CHOICE_IDENTIFIER_MAP)) { throw new InvalidConsoleInput(sprintf( '"%s" is not a valid code of conduct choice.', (string) $value, )); } return $value; }; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/CodeOfConductCommittee.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; /** * Asks for the name of the committee responsible for handling code of conduct issues */ class CodeOfConductCommittee extends Question implements SkippableQuestion, StarterKitQuestion { use AnswersTool; public function getName(): string { return 'codeOfConductCommittee'; } public function __construct(Answers $answers) { parent::__construct( 'What is the name of your group or committee who oversees code of conduct issues?', $answers->codeOfConductCommittee, ); $this->answers = $answers; } /** * @return callable(string | null): (string | null) */ public function getValidator(): callable { return fn (?string $data): ?string => $data; } public function shouldSkip(): bool { // This question is only applicable for the Citizen-2.3 code of conduct. return $this->getAnswers()->codeOfConduct !== CodeOfConduct::CHOICE_IDENTIFIER_MAP[5]; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/CodeOfConductEmail.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; /** * Asks for the email address to which code of conduct issues should be submitted */ class CodeOfConductEmail extends Question implements SkippableQuestion, StarterKitQuestion { use AnswersTool; use EmailValidatorTool; public function getName(): string { return 'codeOfConductEmail'; } public function __construct(Answers $answers) { parent::__construct( 'What email address should people use to report code of conduct issues?', $answers->codeOfConductEmail, ); $this->answers = $answers; } public function shouldSkip(): bool { return $this->getAnswers()->codeOfConduct === CodeOfConduct::DEFAULT; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/CodeOfConductPoliciesUrl.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; /** * Asks for a URL that describes governing policies for the code of conduct */ class CodeOfConductPoliciesUrl extends Question implements SkippableQuestion, StarterKitQuestion { use AnswersTool; use UrlValidatorTool; public function getName(): string { return 'codeOfConductPoliciesUrl'; } public function __construct(Answers $answers) { parent::__construct( 'At what URL are your committee\'s governing policies described?', $answers->codeOfConductPoliciesUrl, ); $this->answers = $answers; } public function shouldSkip(): bool { // This question is only applicable for the Citizen-2.3 code of conduct. return $this->getAnswers()->codeOfConduct !== CodeOfConduct::CHOICE_IDENTIFIER_MAP[5]; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/CodeOfConductReportingUrl.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; /** * Asks for a URL that describes guidelines for reporting code of conduct issues */ class CodeOfConductReportingUrl extends Question implements SkippableQuestion, StarterKitQuestion { use AnswersTool; use UrlValidatorTool; public function getName(): string { return 'codeOfConductReportingUrl'; } public function __construct(Answers $answers) { parent::__construct( 'At what URL are your code of conduct reporting guidelines described?', $answers->codeOfConductReportingUrl, ); $this->answers = $answers; } public function shouldSkip(): bool { // This question is only applicable for the Citizen-2.3 code of conduct. return $this->getAnswers()->codeOfConduct !== CodeOfConduct::CHOICE_IDENTIFIER_MAP[5]; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/CopyrightEmail.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; /** * Asks for the email address of the copyright holder */ class CopyrightEmail extends Question implements SkippableQuestion, StarterKitQuestion { use AnswersTool; use EmailValidatorTool; public function getName(): string { return 'copyrightEmail'; } public function __construct(Answers $answers) { parent::__construct('What is the copyright holder\'s email address?'); $this->answers = $answers; } public function getDefault(): float | bool | int | string | null { return $this->getAnswers()->copyrightEmail ?? $this->getAnswers()->authorEmail; } public function shouldSkip(): bool { return $this->getAnswers()->authorHoldsCopyright === true; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/CopyrightHolder.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; /** * Asks for the name of the copyright holder */ class CopyrightHolder extends Question implements SkippableQuestion, StarterKitQuestion { use AnswersTool; public function getName(): string { return 'copyrightHolder'; } public function __construct(Answers $answers) { parent::__construct('Who is the copyright holder?'); $this->answers = $answers; } public function getDefault(): float | bool | int | string | null { return $this->getAnswers()->copyrightHolder ?? $this->getAnswers()->authorName; } public function shouldSkip(): bool { return $this->getAnswers()->authorHoldsCopyright === true; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/CopyrightUrl.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; /** * Asks for the URL of the copyright holder */ class CopyrightUrl extends Question implements SkippableQuestion, StarterKitQuestion { use AnswersTool; use UrlValidatorTool; public function getName(): string { return 'copyrightUrl'; } public function __construct(Answers $answers) { parent::__construct('What is the copyright holder\'s website address?'); $this->answers = $answers; } public function getDefault(): float | bool | int | string | null { return $this->getAnswers()->copyrightUrl ?? $this->getAnswers()->authorUrl; } public function shouldSkip(): bool { return $this->getAnswers()->authorHoldsCopyright === true; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/CopyrightYear.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Ramsey\Dev\LibraryStarterKit\Exception\InvalidConsoleInput; use Symfony\Component\Console\Question\Question; use function date; use function preg_match; use function trim; /** * Asks for the initial copyright year */ class CopyrightYear extends Question implements StarterKitQuestion { use AnswersTool; private const VALID_PATTERN = '/^\d{4}$/'; public function getName(): string { return 'copyrightYear'; } public function __construct(Answers $answers) { parent::__construct('What is the copyright year?'); $this->answers = $answers; } public function getDefault(): float | bool | int | string | null { return $this->getAnswers()->copyrightYear ?? date('Y'); } /** * @return callable(string | null): string */ public function getValidator(): callable { return function (?string $data): string { if (preg_match(self::VALID_PATTERN, trim((string) $data)) === 1) { return (string) $data; } throw new InvalidConsoleInput('You must enter a valid, 4-digit year.'); }; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/EmailValidatorTool.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Exception\InvalidConsoleInput; use function filter_var; use function trim; use const FILTER_VALIDATE_EMAIL; /** * Common question email validation functionality */ trait EmailValidatorTool { private bool $isOptional = true; /** * @return callable(string | null): (string | null) */ public function getValidator(): callable { return function (?string $data): ?string { if ($this->isOptional && ($data === null || trim($data) === '')) { return null; } if (filter_var($data, FILTER_VALIDATE_EMAIL)) { return $data; } throw new InvalidConsoleInput('You must enter a valid email address.'); }; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/GithubUsername.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; /** * Asks for the GitHub username or org name of the project owner */ class GithubUsername extends Question implements StarterKitQuestion { use AnswersTool; public function getName(): string { return 'githubUsername'; } public function __construct(Answers $answers) { parent::__construct( 'What is the GitHub username or org name for your package?', $answers->githubUsername, ); $this->answers = $answers; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/License.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Ramsey\Dev\LibraryStarterKit\Exception\InvalidConsoleInput; use Symfony\Component\Console\Question\ChoiceQuestion; use function array_combine; use function array_search; use function ctype_digit; use function in_array; use function sprintf; use function trim; /** * Asks the user what license they wish to use for this project */ class License extends ChoiceQuestion implements StarterKitQuestion { use AnswersTool; public const DEFAULT = 'Proprietary'; public const CHOICES = [ 1 => self::DEFAULT, 2 => 'Apache License 2.0', 3 => 'BSD 2-Clause "Simplified" License', 4 => 'BSD 3-Clause "New" or "Revised" License', 5 => 'Creative Commons Zero v1.0 Universal', 6 => 'GNU Affero General Public License v3.0 or later', 7 => 'GNU General Public License v3.0 or later', 8 => 'GNU Lesser General Public License v3.0 or later', 9 => 'Hippocratic License 2.1', 10 => 'MIT License', 11 => 'MIT No Attribution', 12 => 'Mozilla Public License 2.0', 13 => 'Unlicense', ]; public const CHOICE_IDENTIFIER_MAP = [ 1 => self::DEFAULT, 2 => 'Apache-2.0', 3 => 'BSD-2-Clause', 4 => 'BSD-3-Clause', 5 => 'CC0-1.0', 6 => 'AGPL-3.0-or-later', 7 => 'GPL-3.0-or-later', 8 => 'LGPL-3.0-or-later', 9 => 'Hippocratic-2.1', 10 => 'MIT', 11 => 'MIT-0', 12 => 'MPL-2.0', 13 => 'Unlicense', ]; public function getName(): string { return 'license'; } public function __construct(Answers $answers) { parent::__construct( 'Choose a license for your project', self::CHOICES, array_search($answers->license, self::CHOICE_IDENTIFIER_MAP) ?: 1, ); $this->answers = $answers; } /** * @return callable(string | null): string */ public function getNormalizer(): callable { $choiceMap = array_combine(self::CHOICES, self::CHOICE_IDENTIFIER_MAP); return function (?string $value) use ($choiceMap): string { if (ctype_digit((string) $value)) { return (string) (self::CHOICE_IDENTIFIER_MAP[(int) $value] ?? $value); } return (string) ($choiceMap[trim((string) $value)] ?? $value); }; } /** * @return callable(string | null): string */ public function getValidator(): callable { return function (?string $value): string { if (!in_array($value, self::CHOICE_IDENTIFIER_MAP)) { throw new InvalidConsoleInput(sprintf( '"%s" is not a valid license choice.', (string) $value, )); } return (string) $value; }; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/PackageDescription.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; /** * Asks for a brief description of the library */ class PackageDescription extends Question implements StarterKitQuestion { use AnswersTool; public function getName(): string { return 'packageDescription'; } public function __construct(Answers $answers) { parent::__construct( 'Enter a brief description of your library', $answers->packageDescription, ); $this->answers = $answers; } /** * @return callable(string | null): (string | null) */ public function getValidator(): callable { return fn (?string $data): ?string => $data; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/PackageKeywords.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; use function array_filter; use function array_map; use function array_values; use function explode; use function implode; use function trim; /** * Asks for keywords to associate with the library */ class PackageKeywords extends Question implements StarterKitQuestion { use AnswersTool; public function getName(): string { return 'packageKeywords'; } public function __construct(Answers $answers) { parent::__construct( 'Enter a set of comma-separated keywords describing your library', implode(',', $answers->packageKeywords) ?: null, ); $this->answers = $answers; } /** * @return callable(string | null): list */ public function getNormalizer(): callable { return function (?string $answer): array { if ($answer === null || trim($answer) === '') { return []; } return array_values( array_filter( array_map( fn ($v) => trim($v), explode(',', $answer), ), ), ); }; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/PackageName.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Ramsey\Dev\LibraryStarterKit\Exception\InvalidConsoleInput; use Symfony\Component\Console\Question\Question; use function preg_match; use function str_starts_with; use function strtolower; use function trim; /** * Asks for the package name (i.e., the name to use for this package on Packagist.org) */ class PackageName extends Question implements StarterKitQuestion { use AnswersTool; private const VALID_PATTERN = '/^[a-z0-9]([_.-]?[a-z0-9]+)*\/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$/'; public function getName(): string { return 'packageName'; } public function __construct(Answers $answers) { parent::__construct('What is your package name?'); $this->answers = $answers; } public function getDefault(): float | bool | int | string | null { if ($this->getAnswers()->packageName !== null) { return $this->getAnswers()->packageName; } $packageName = (string) $this->getAnswers()->vendorName . '/' . (string) $this->getAnswers()->projectName; if (trim($packageName) === '/') { return null; } return $packageName; } public function getValidator(): callable { return function (?string $data): string { $vendorPrefix = ''; if ($this->getAnswers()->vendorName !== null) { $vendorPrefix = strtolower((string) $this->getAnswers()->vendorName) . '/'; } $data = strtolower((string) $data); if ($vendorPrefix !== '' && !str_starts_with($data, $vendorPrefix)) { $data = $vendorPrefix . $data; } if (preg_match(self::VALID_PATTERN, $data)) { return $data; } throw new InvalidConsoleInput( 'You must enter a valid package name.', ); }; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/PackageNamespace.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Ramsey\Dev\LibraryStarterKit\Exception\InvalidConsoleInput; use Symfony\Component\Console\Question\Question; use function array_map; use function explode; use function implode; use function preg_match; use function preg_replace; use function str_replace; use function substr; use function trim; use function ucwords; /** * Asks for the namespace to use for this package */ class PackageNamespace extends Question implements StarterKitQuestion { use AnswersTool; private const VALID_PATTERN = '/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/'; public function getName(): string { return 'packageNamespace'; } public function __construct(Answers $answers) { parent::__construct('What is the library\'s root namespace?'); $this->answers = $answers; } public function getQuestion(): string { $question = parent::getQuestion(); if ($this->getDefault() === null) { $question .= ' (e.g., Foo\\Bar\\Baz)'; } return $question; } public function getDefault(): float | bool | int | string | null { if ($this->getAnswers()->packageNamespace !== null) { return $this->getAnswers()->packageNamespace; } $packageName = $this->getAnswers()->packageName; if ($packageName === null || trim($packageName) === '') { return null; } $packageName = str_replace('/', '\\', $packageName); $packageNameParts = explode('\\', $packageName); /** @var string[] $packageNameParts */ $packageNameParts = array_map($this->namify(), $packageNameParts); return implode('\\', $packageNameParts); } public function getValidator(): callable { return function (?string $data): string { $packageNameParts = explode('\\', (string) $data); foreach ($packageNameParts as $namePart) { if (!preg_match(self::VALID_PATTERN, $namePart)) { throw new InvalidConsoleInput( 'You must enter a valid library namespace.', ); } } return (string) $data; }; } private function namify(): callable { return function (string $value): string { // Replace any invalid characters with a space. $value = preg_replace('/[^a-zA-Z0-9_\x80-\xff]/', ' ', $value); $valueParts = explode(' ', (string) $value); foreach ($valueParts as &$part) { // Check the first character to make sure it's valid. if (preg_match('/[^a-zA-Z_\x80-\xff]/', $part[0]) === 1) { $part = substr($part, 1); } } // Upper-case the words and separate with namespaces. return str_replace(' ', '\\', ucwords(implode(' ', $valueParts))); }; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/SecurityPolicy.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\ConfirmationQuestion; /** * Asks whether the library creator wishes to include a security policy */ class SecurityPolicy extends ConfirmationQuestion implements StarterKitQuestion { use AnswersTool; public function getName(): string { return 'securityPolicy'; } public function __construct(Answers $answers) { parent::__construct( 'Do you want to include a security policy?', $answers->securityPolicy, ); $this->answers = $answers; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/SecurityPolicyContactEmail.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; /** * Asks for the email address to which researchers should submit vulnerability reports */ class SecurityPolicyContactEmail extends Question implements SkippableQuestion, StarterKitQuestion { use AnswersTool; use EmailValidatorTool; public function getName(): string { return 'securityPolicyContactEmail'; } public function __construct(Answers $answers) { parent::__construct( 'What email address should researchers use to submit vulnerability reports?', $answers->securityPolicyContactEmail, ); $this->answers = $answers; } public function shouldSkip(): bool { return $this->getAnswers()->securityPolicy === false; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/SecurityPolicyContactFormUrl.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Symfony\Component\Console\Question\Question; /** * Asks for a URL that where security researchers may submit reports */ class SecurityPolicyContactFormUrl extends Question implements SkippableQuestion, StarterKitQuestion { use AnswersTool; use UrlValidatorTool; public function getName(): string { return 'securityPolicyContactFormUrl'; } public function __construct(Answers $answers) { parent::__construct( 'At what URL should researchers submit vulnerability reports?', $answers->securityPolicyContactFormUrl, ); $this->answers = $answers; } public function shouldSkip(): bool { return $this->getAnswers()->securityPolicy === false; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/SkippableQuestion.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; interface SkippableQuestion { public function shouldSkip(): bool; } ================================================ FILE: src/LibraryStarterKit/Console/Question/StarterKitQuestion.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; interface StarterKitQuestion { public function getAnswers(): Answers; public function getName(): string; } ================================================ FILE: src/LibraryStarterKit/Console/Question/UrlValidatorTool.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Exception\InvalidConsoleInput; use function filter_var; use function str_starts_with; use function trim; use const FILTER_VALIDATE_URL; /** * Common URL validation functionality */ trait UrlValidatorTool { private bool $isOptional = true; /** * @return callable(string | null): (string | null) */ public function getValidator(): callable { return function (?string $data): ?string { if ($this->isOptional && ($data === null || trim($data) === '')) { return null; } if ( filter_var((string) $data, FILTER_VALIDATE_URL) && str_starts_with((string) $data, 'http') ) { return $data; } throw new InvalidConsoleInput( 'You must enter a valid URL, beginning with "http://" or "https://".', ); }; } } ================================================ FILE: src/LibraryStarterKit/Console/Question/VendorName.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console\Question; use Ramsey\Dev\LibraryStarterKit\Answers; use Ramsey\Dev\LibraryStarterKit\Exception\InvalidConsoleInput; use Symfony\Component\Console\Question\Question; use function preg_match; use function strtolower; /** * Asks for the vendor name to use for this package */ class VendorName extends Question implements StarterKitQuestion { use AnswersTool; private const VALID_PATTERN = '/^[a-z0-9]([_.-]?[a-z0-9]+)*$/'; public function getName(): string { return 'vendorName'; } public function __construct(Answers $answers) { parent::__construct('What is your package vendor name?'); $this->answers = $answers; } public function getDefault(): float | bool | int | string | null { return $this->getAnswers()->vendorName ?? $this->getAnswers()->githubUsername; } public function getValidator(): callable { return function (?string $data): string { $data = strtolower((string) $data); if (preg_match(self::VALID_PATTERN, $data)) { return $data; } throw new InvalidConsoleInput( 'You must enter a valid vendor name.', ); }; } } ================================================ FILE: src/LibraryStarterKit/Console/Style.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console; use Symfony\Component\Console\Style\SymfonyStyle; class Style extends SymfonyStyle { } ================================================ FILE: src/LibraryStarterKit/Console/StyleFactory.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Console; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** * A factory useful for creating a Style instance */ class StyleFactory { public function factory(InputInterface $input, OutputInterface $output): Style { return new Style($input, $output); } } ================================================ FILE: src/LibraryStarterKit/Exception/InvalidConsoleInput.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Exception; use RuntimeException; class InvalidConsoleInput extends RuntimeException implements StarterKitException { } ================================================ FILE: src/LibraryStarterKit/Exception/StarterKitException.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Exception; use Throwable as PhpThrowable; interface StarterKitException extends PhpThrowable { } ================================================ FILE: src/LibraryStarterKit/Filesystem.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit; use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem; use Symfony\Component\Finder\SplFileInfo; /** * Wraps the Symfony Filesystem class to provide additional file operations */ class Filesystem extends SymfonyFilesystem { /** * Returns an instance of a file */ public function getFile(string $path): SplFileInfo { return new SplFileInfo($path, '', ''); } } ================================================ FILE: src/LibraryStarterKit/Project.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit; class Project { public function __construct( private readonly string $name, private readonly string $path, ) { } public function getName(): string { return $this->name; } public function getPath(): string { return $this->path; } } ================================================ FILE: src/LibraryStarterKit/Setup.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit; use Composer\Script\Event; use Ramsey\Dev\LibraryStarterKit\Task\Build; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Finder\Finder; use Symfony\Component\Process\Process; use Twig\Environment as TwigEnvironment; use Twig\Loader\FilesystemLoader; use Twig\TwigFilter; use function preg_replace; use const DIRECTORY_SEPARATOR; class Setup { /** * @phpstan-param OutputInterface::VERBOSITY_* $verbosity */ public function __construct( private readonly Project $project, private readonly Event $event, private readonly Filesystem $filesystem, private readonly Finder $finder, private readonly int $verbosity, ) { } /** * Returns the absolute path to the directory for the application */ public function getAppPath(): string { return $this->project->getPath(); } /** * Returns the Composer event that triggered this action */ public function getEvent(): Event { return $this->event; } /** * Returns a filesystem object to use when executing filesystem commands */ public function getFilesystem(): Filesystem { return $this->filesystem; } /** * Returns an object used to search for files or directories */ public function getFinder(): Finder { return $this->finder::create(); } /** * Returns the project name */ public function getProjectName(): string { return $this->project->getName(); } /** * Returns the project we are setting up */ public function getProject(): Project { return $this->project; } /** * Returns the verbosity level * * @return OutputInterface::VERBOSITY_* */ public function getVerbosity(): int { return $this->verbosity; } /** * Returns an instance used for executing a system command * * @param string[] $command */ public function getProcess(array $command): Process { return new Process($command, $this->getProject()->getPath()); } /** * Given a project-relative directory or filename, constructs an absolute path */ public function path(string $fileName): string { return $this->getProject()->getPath() . DIRECTORY_SEPARATOR . $fileName; } /** * Returns a Build object used to process all the user inputs */ public function getBuild(SymfonyStyle $console, Answers $answers): Build { return new Build( $this, $console, $answers, ); } /** * Returns a Twig environment object for rendering Twig templates */ public function getTwigEnvironment(): TwigEnvironment { $pregReplaceFilter = new TwigFilter( 'preg_replace', /** * @param non-empty-string $p */ fn (string $s, string $p, string $r): string => (string) preg_replace($p, $r, $s), ); $twig = new TwigEnvironment( new FilesystemLoader($this->getProject()->getPath() . '/resources/templates'), [ 'debug' => true, 'strict_variables' => true, 'autoescape' => false, ], ); $twig->addFilter($pregReplaceFilter); return $twig; } /** * Runs the steps to set up the project */ public function run(SymfonyStyle $console, Answers $answers): void { $this->getBuild($console, $answers)->run(); } } ================================================ FILE: src/LibraryStarterKit/Task/Build.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task; use Ramsey\Dev\LibraryStarterKit\Answers; use Ramsey\Dev\LibraryStarterKit\Setup; use Ramsey\Dev\LibraryStarterKit\Task\Builder\Cleanup; use Ramsey\Dev\LibraryStarterKit\Task\Builder\FixStyle; use Ramsey\Dev\LibraryStarterKit\Task\Builder\InstallDependencies; use Ramsey\Dev\LibraryStarterKit\Task\Builder\RenameTemplates; use Ramsey\Dev\LibraryStarterKit\Task\Builder\RunTests; use Ramsey\Dev\LibraryStarterKit\Task\Builder\SetupRepository; use Ramsey\Dev\LibraryStarterKit\Task\Builder\UpdateChangelog; use Ramsey\Dev\LibraryStarterKit\Task\Builder\UpdateCodeOfConduct; use Ramsey\Dev\LibraryStarterKit\Task\Builder\UpdateComposerJson; use Ramsey\Dev\LibraryStarterKit\Task\Builder\UpdateContributing; use Ramsey\Dev\LibraryStarterKit\Task\Builder\UpdateFunding; use Ramsey\Dev\LibraryStarterKit\Task\Builder\UpdateLicense; use Ramsey\Dev\LibraryStarterKit\Task\Builder\UpdateNamespace; use Ramsey\Dev\LibraryStarterKit\Task\Builder\UpdateReadme; use Ramsey\Dev\LibraryStarterKit\Task\Builder\UpdateSecurityPolicy; use Ramsey\Dev\LibraryStarterKit\Task\Builder\UpdateSourceFileHeaders; use Symfony\Component\Console\Style\SymfonyStyle; /** * The Build task executes all the builders used to build the library */ class Build { public function __construct( private readonly Setup $setup, private readonly SymfonyStyle $console, private readonly Answers $answers, ) { } public function getAnswers(): Answers { return $this->answers; } public function getConsole(): SymfonyStyle { return $this->console; } public function getSetup(): Setup { return $this->setup; } /** * Executes each builder */ public function run(): void { foreach ($this->getBuilders() as $builder) { $builder->build(); } } /** * Returns a list of builders to use for creating a library * * @return Builder[] */ public function getBuilders(): array { return [ new RenameTemplates($this), new UpdateComposerJson($this), new UpdateReadme($this), new UpdateLicense($this), new UpdateSourceFileHeaders($this), new UpdateNamespace($this), new UpdateSecurityPolicy($this), new UpdateCodeOfConduct($this), new UpdateChangelog($this), new UpdateContributing($this), new UpdateFunding($this), new InstallDependencies($this), new Cleanup($this), new FixStyle($this), new SetupRepository($this), new RunTests($this), ]; } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/Cleanup.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Task\Builder; use function sprintf; use const DIRECTORY_SEPARATOR; /** * Removes files that we don't want to include in the newly-created project */ class Cleanup extends Builder { /** * The files and directories listed here are relative to the project root. */ private const CLEANUP_FILES = [ 'resources' . DIRECTORY_SEPARATOR . 'templates', 'src' . DIRECTORY_SEPARATOR . 'LibraryStarterKit', 'tests' . DIRECTORY_SEPARATOR . 'LibraryStarterKit', '.git', '.starter-kit-answers', ]; public function build(): void { $this->getConsole()->section('Cleaning up...'); foreach (self::CLEANUP_FILES as $file) { $this->getEnvironment()->getFilesystem()->remove( $this->getEnvironment()->path($file), ); $this->getConsole()->text(sprintf( ' - Deleted \'%s\'.', $this->getEnvironment()->path($file), )); } } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/FixStyle.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Task\Builder; /** * Fixes any style issues we might encounter (e.g., use statements sorting, etc.) */ class FixStyle extends Builder { public function build(): void { $this->getConsole()->section('Fixing style issues...'); $this ->getEnvironment() ->getProcess(['composer', 'dev:lint:fix']) ->mustRun($this->streamProcessOutput()); } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/InstallDependencies.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Task\Builder; /** * Installs project dependencies after building a new library */ class InstallDependencies extends Builder { public function build(): void { $this->getConsole()->section('Installing dependencies'); // Remove lock files and vendor directories to start fresh. $this->getEnvironment()->getFilesystem()->remove([ $this->getEnvironment()->path('composer.lock'), $this->getEnvironment()->path('vendor'), ]); $process = $this->getEnvironment()->getProcess([ 'composer', 'update', '--no-interaction', '--ansi', '--no-progress', ]); $process->mustRun($this->streamProcessOutput()); } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/RenameTemplates.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Task\Builder; use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\SplFileInfo; use function basename; use function dirname; use function sprintf; use const DIRECTORY_SEPARATOR; /** * Removes the .template suffix from any files in the project */ class RenameTemplates extends Builder { public function build(): void { $this->getConsole()->section('Renaming template files'); foreach ($this->getTemplatesFinder() as $template) { $this->removeTemplateExtension($template); } } private function getTemplatesFinder(): Finder { $finder = $this->getEnvironment()->getFinder(); $finder ->ignoreDotFiles(false) ->exclude([ 'build', 'vendor', ]) ->in($this->getEnvironment()->getAppPath()) ->name('*.template') ->name('.*.template'); return $finder; } private function removeTemplateExtension(SplFileInfo $file): void { $path = (string) $file->getRealPath(); $dirName = dirname($path); $baseName = basename($path, '.template'); $newPath = $dirName . DIRECTORY_SEPARATOR . $baseName; $this->getConsole()->text(sprintf( ' - Renaming \'%s\' to \'%s\'.', $path, $newPath, )); $this->getEnvironment()->getFilesystem()->rename($path, $newPath); } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/RunTests.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Task\Builder; /** * Runs all tests for the newly-created project */ class RunTests extends Builder { public function build(): void { $this->getConsole()->section('Running project tests...'); $this ->getEnvironment() ->getProcess(['composer', 'dev:test:all']) ->mustRun($this->streamProcessOutput()); } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/SetupRepository.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Task\Builder; use Symfony\Component\Process\Process; use function sprintf; use function trim; /** * Initializes a local Git repository for the newly-created project */ class SetupRepository extends Builder { private const COMMIT_MSG = 'chore: initialize project using ramsey/php-library-starter-kit'; private const DEFAULT_BRANCH = 'main'; public function build(): void { $this->getConsole()->section('Setting up Git repository'); $this ->initializeRepository() ->gitConfigUser() ->cleanBuildDir() ->gitAddAllFiles() ->gitInitialCommit() ->setGitBranchName() ->installHooks(); } private function getDefaultBranch(): string { $process = $this->getEnvironment()->getProcess( ['git', 'config', 'init.defaultBranch'], ); $process->run(); $defaultBranch = trim($process->getOutput()); return $defaultBranch ?: self::DEFAULT_BRANCH; } private function getUserName(): string { $process = $this->getEnvironment()->getProcess( ['git', 'config', 'user.name'], ); $process->run(); return trim($process->getOutput()); } private function getUserEmail(): string { $process = $this->getEnvironment()->getProcess( ['git', 'config', 'user.email'], ); $process->run(); return trim($process->getOutput()); } private function initializeRepository(): self { $this ->getEnvironment() ->getProcess(['git', 'init']) ->mustRun(function (string $type, string $buffer): void { if ($type === Process::OUT) { $this->getConsole()->write($buffer); } }); return $this; } private function installHooks(): self { $captainHookPath = $this->getEnvironment()->path('vendor') . '/bin/captainhook'; $this ->getEnvironment() ->getProcess([$captainHookPath, 'install', '--force', '--skip-existing']) ->mustRun($this->streamProcessOutput()); return $this; } private function cleanBuildDir(): self { $this ->getEnvironment() ->getProcess(['composer', 'dev:build:clean']) ->mustRun(); return $this; } private function gitAddAllFiles(): self { $this ->getEnvironment() ->getProcess(['git', 'add', '--all']) ->mustRun($this->streamProcessOutput()); return $this; } private function gitInitialCommit(): self { $author = sprintf( '%s <%s>', (string) $this->getAnswers()->authorName, (string) $this->getAnswers()->authorEmail, ); $this ->getEnvironment() ->getProcess(['git', 'commit', '-n', '-m', self::COMMIT_MSG, '--author', $author]) ->mustRun($this->streamProcessOutput()); return $this; } private function setGitBranchName(): self { $this ->getEnvironment() ->getProcess(['git', 'branch', '-M', $this->getDefaultBranch()]) ->mustRun($this->streamProcessOutput()); return $this; } private function gitConfigUser(): self { $userName = $this->getUserName(); $userEmail = $this->getUserEmail(); if ($userName !== $this->getAnswers()->authorName) { $this ->getEnvironment() ->getProcess(['git', 'config', 'user.name', (string) $this->getAnswers()->authorName]) ->mustRun($this->streamProcessOutput()); } if ($userEmail !== $this->getAnswers()->authorEmail) { $this ->getEnvironment() ->getProcess(['git', 'config', 'user.email', (string) $this->getAnswers()->authorEmail]) ->mustRun($this->streamProcessOutput()); } return $this; } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/UpdateChangelog.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Task\Builder; /** * Updates the project's CHANGELOG using the CHANGELOG template */ class UpdateChangelog extends Builder { public function build(): void { $this->getConsole()->section('Updating CHANGELOG.md'); $changelog = $this->getEnvironment()->getTwigEnvironment()->render( 'CHANGELOG.md.twig', $this->getAnswers()->getArrayCopy(), ); $this->getEnvironment()->getFilesystem()->dumpFile( $this->getEnvironment()->path('CHANGELOG.md'), $changelog, ); } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/UpdateCodeOfConduct.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Console\Question\CodeOfConduct; use Ramsey\Dev\LibraryStarterKit\Task\Builder; use const DIRECTORY_SEPARATOR; /** * Updates the project's Code of Conduct using the one selected during setup */ class UpdateCodeOfConduct extends Builder { public function build(): void { if ($this->getAnswers()->codeOfConduct === CodeOfConduct::DEFAULT) { $this->getConsole()->section('Removing CODE_OF_CONDUCT.md'); $this->getEnvironment()->getFilesystem()->remove( $this->getEnvironment()->path('CODE_OF_CONDUCT.md'), ); return; } $this->getConsole()->section('Updating CODE_OF_CONDUCT.md'); $codeOfConductTemplate = 'code-of-conduct' . DIRECTORY_SEPARATOR; $codeOfConductTemplate .= $this->getAnswers()->codeOfConduct; $codeOfConductTemplate .= '.md.twig'; $codeOfConduct = $this->getEnvironment()->getTwigEnvironment()->render( $codeOfConductTemplate, $this->getAnswers()->getArrayCopy(), ); $this->getEnvironment()->getFilesystem()->dumpFile( $this->getEnvironment()->path('CODE_OF_CONDUCT.md'), $codeOfConduct, ); } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/UpdateComposerJson.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Task\Builder; use RuntimeException; use function array_filter; use function in_array; use function json_decode; use function json_encode; use function trim; use const ARRAY_FILTER_USE_KEY; use const JSON_PRETTY_PRINT; use const JSON_UNESCAPED_SLASHES; use const JSON_UNESCAPED_UNICODE; /** * Updates values in the composer.json file * * @psalm-type ComposerAuthorType = array{name: string, email?: string | null, homepage?: string | null} * @psalm-type ComposerAutoloadType = array{"psr-4"?: array} * @psalm-type ComposerType = array{name: string, description: string, type: string, keywords: string[], license: string | null, authors: ComposerAuthorType[], require?: array, require-dev?: array, autoload?: ComposerAutoloadType, autoload-dev?: ComposerAutoloadType, scripts?: array, scripts-descriptions?: array, suggest?: array} */ class UpdateComposerJson extends Builder { private const ALLOWLIST_REQUIRE = [ 'php', ]; private const ALLOWLIST_REQUIRE_DEV = [ 'ramsey/devtools', ]; private const ALLOWLIST_AUTOLOAD = [ 'Vendor\\SubNamespace\\', ]; private const ALLOWLIST_AUTOLOAD_DEV = [ 'Vendor\\Test\\SubNamespace\\', ]; private const JSON_OPTIONS = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; public function build(): void { $this->getConsole()->section('Updating composer.json'); /** * @psalm-var ComposerType|null $composer */ $composer = json_decode($this->getComposerContents(), true); if ($composer === null) { throw new RuntimeException('Unable to decode contents of composer.json'); } $composer['name'] = (string) $this->getAnswers()->packageName; $composer['description'] = (string) $this->getAnswers()->packageDescription; $composer['type'] = 'library'; $composer['keywords'] = $this->getAnswers()->packageKeywords; $composer['license'] = $this->getAnswers()->license; $this->buildAuthors($composer); $this->buildRequire($composer); $this->buildRequireDev($composer); $this->buildAutoload($composer); $this->buildAutoloadDev($composer); unset($composer['scripts']); unset($composer['scripts-descriptions']); unset($composer['suggest']); $this->getEnvironment()->getFilesystem()->dumpFile( $this->getEnvironment()->path('composer.json'), (string) json_encode($composer, self::JSON_OPTIONS) . "\n", ); } /** * @param array $data * @param string[] $allowlist * * @return array */ private function filterPropertiesByAllowlist(array $data, array $allowlist): array { return array_filter($data, fn ($property) => in_array($property, $allowlist), ARRAY_FILTER_USE_KEY); } private function getComposerContents(): string { $finder = $this->getEnvironment()->getFinder(); $finder ->in($this->getEnvironment()->getAppPath()) ->files() ->depth('== 0') ->name('composer.json'); $composerContents = null; foreach ($finder as $file) { $composerContents = $file->getContents(); break; } if ($composerContents === null) { throw new RuntimeException('Unable to get contents of composer.json'); } return $composerContents; } /** * @psalm-param ComposerType $composer */ private function buildAuthors(array &$composer): void { /** @var ComposerAuthorType $author */ $author = ['name' => $this->getAnswers()->authorName]; if (trim((string) $this->getAnswers()->authorEmail) !== '') { $author['email'] = $this->getAnswers()->authorEmail; } if (trim((string) $this->getAnswers()->authorUrl) !== '') { $author['homepage'] = $this->getAnswers()->authorUrl; } $composer['authors'] = [$author]; } /** * @psalm-param ComposerType $composer */ private function buildRequire(array &$composer): void { if (!isset($composer['require'])) { return; } $composer['require'] = $this->filterPropertiesByAllowlist( $composer['require'], self::ALLOWLIST_REQUIRE, ); } /** * @psalm-param ComposerType $composer */ private function buildRequireDev(array &$composer): void { if (!isset($composer['require-dev'])) { return; } $composer['require-dev'] = $this->filterPropertiesByAllowlist( $composer['require-dev'], self::ALLOWLIST_REQUIRE_DEV, ); } /** * @psalm-param ComposerType $composer */ private function buildAutoload(array &$composer): void { if (!isset($composer['autoload']['psr-4'])) { return; } $composer['autoload']['psr-4'] = $this->filterPropertiesByAllowlist( $composer['autoload']['psr-4'], self::ALLOWLIST_AUTOLOAD, ); } /** * @psalm-param ComposerType $composer */ private function buildAutoloadDev(array &$composer): void { if (!isset($composer['autoload-dev']['psr-4'])) { return; } $composer['autoload-dev']['psr-4'] = $this->filterPropertiesByAllowlist( $composer['autoload-dev']['psr-4'], self::ALLOWLIST_AUTOLOAD_DEV, ); } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/UpdateContributing.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Task\Builder; /** * Updates the CONTRIBUTING.md file based on responses to setup questions */ class UpdateContributing extends Builder { public function build(): void { $this->getConsole()->section('Updating CONTRIBUTING.md'); $changelog = $this->getEnvironment()->getTwigEnvironment()->render( 'CONTRIBUTING.md.twig', $this->getAnswers()->getArrayCopy(), ); $this->getEnvironment()->getFilesystem()->dumpFile( $this->getEnvironment()->path('CONTRIBUTING.md'), $changelog, ); } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/UpdateFunding.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Task\Builder; /** * Replaces this project's FUNDING.yml file with an empty one for the new project */ class UpdateFunding extends Builder { public function build(): void { $this->getConsole()->section('Updating .github/FUNDING.yml'); $funding = $this->getEnvironment()->getTwigEnvironment()->render( 'FUNDING.yml.twig', $this->getAnswers()->getArrayCopy(), ); $this->getEnvironment()->getFilesystem()->dumpFile( $this->getEnvironment()->path('.github/FUNDING.yml'), $funding, ); } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/UpdateLicense.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Task\Builder; use function str_starts_with; use const DIRECTORY_SEPARATOR; /** * Updates the license files with those chosen during the project setup */ class UpdateLicense extends Builder { public function build(): void { $this->getConsole()->section('Updating license and copyright information'); $licenseChoice = $this->getAnswers()->license ?? ''; // Remove the existing LICENSE file. $this->getEnvironment()->getFilesystem()->remove('LICENSE'); $this->handleLicenseFile($licenseChoice); if ($this->hasNoticeFile($licenseChoice)) { $this->handleNoticeFile($licenseChoice); } } private function hasNoticeFile(string $license): bool { switch ($license) { case 'AGPL-3.0-or-later': case 'Apache-2.0': case 'GPL-3.0-or-later': case 'LGPL-3.0-or-later': case 'MPL-2.0': return true; default: return false; } } private function getLicenseFilename(string $license): string { switch ($license) { case 'AGPL-3.0-or-later': case 'GPL-3.0-or-later': return 'COPYING'; case 'LGPL-3.0-or-later': return 'COPYING.LESSER'; case 'Proprietary': return 'COPYRIGHT'; case 'Unlicense': return 'UNLICENSE'; default: return 'LICENSE'; } } private function handleLicenseFile(string $license): void { $licenseContents = $this->getEnvironment()->getTwigEnvironment()->render( 'license' . DIRECTORY_SEPARATOR . $license . '.twig', $this->getAnswers()->getArrayCopy(), ); $this->getEnvironment()->getFilesystem()->dumpFile( $this->getEnvironment()->path($this->getLicenseFilename($license)), $licenseContents, ); if (str_starts_with($license, 'LGPL-3.0')) { $this->includeGplWithLesserGpl(); } } private function handleNoticeFile(string $license): void { $noticeContents = $this->getEnvironment()->getTwigEnvironment()->render( 'license' . DIRECTORY_SEPARATOR . $license . '-NOTICE.twig', $this->getAnswers()->getArrayCopy(), ); $this->getEnvironment()->getFilesystem()->dumpFile( $this->getEnvironment()->path('NOTICE'), $noticeContents, ); } private function includeGplWithLesserGpl(): void { $gplContents = $this->getEnvironment()->getTwigEnvironment()->render( 'license' . DIRECTORY_SEPARATOR . 'GPL-3.0-or-later.twig', $this->getAnswers()->getArrayCopy(), ); $this->getEnvironment()->getFilesystem()->dumpFile( $this->getEnvironment()->path('COPYING'), $gplContents, ); } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/UpdateNamespace.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Task\Builder; use Symfony\Component\Finder\SplFileInfo; use function array_filter; use function array_keys; use function array_shift; use function array_values; use function explode; use function implode; use function iterator_to_array; use function str_replace; /** * Updates the namespace according to the one provided during project setup */ class UpdateNamespace extends Builder { public function build(): void { $this->getConsole()->section('Updating namespace'); $packageName = (string) $this->getAnswers()->packageName; $namespaceParts = explode( '\\', (string) $this->getAnswers()->packageNamespace, ); $vendor = array_shift($namespaceParts); $subNamespace = implode('\\', $namespaceParts); $namespace = implode('\\', array_filter([$vendor, $subNamespace])); $testNamespace = implode('\\', array_filter([$vendor, 'Test', $subNamespace])); $replacements = [ 'Vendor\\SubNamespace' => $namespace, 'Vendor\\Test\\SubNamespace' => $testNamespace, 'Vendor\\\\SubNamespace' => str_replace('\\', '\\\\', $namespace), 'Vendor\\\\Test\\\\SubNamespace' => str_replace('\\', '\\\\', $testNamespace), 'ramsey/php-library-starter-kit' => $packageName, ]; foreach ($this->getSourceFiles() as $file) { $this->replaceNamespace($file, $replacements); } } /** * @return SplFileInfo[] */ private function getSourceFiles(): array { $finder = $this->getEnvironment()->getFinder(); $finder ->exclude(['LibraryStarterKit']) ->in([ $this->getEnvironment()->path('bin'), $this->getEnvironment()->path('src'), $this->getEnvironment()->path('tests'), ]) ->files() ->name('*.php'); /** @var SplFileInfo[] $files */ $files = iterator_to_array($finder, false); // Find composer.json and add it to the array of files to return. $composerFinder = $this->getEnvironment()->getFinder(); $composerFinder ->in([$this->getEnvironment()->getAppPath()]) ->files() ->depth('== 0') ->name('composer.json'); foreach ($composerFinder as $file) { $files[] = $file; break; } return $files; } /** * @param array $replacements */ private function replaceNamespace(SplFileInfo $file, array $replacements): void { $path = (string) $file->getRealPath(); $contents = $file->getContents(); $updatedContents = str_replace( array_keys($replacements), array_values($replacements), $contents, ); $this->getEnvironment()->getFilesystem()->dumpFile($path, $updatedContents); } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/UpdateReadme.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Console\Question\CodeOfConduct; use Ramsey\Dev\LibraryStarterKit\Task\Builder; use RuntimeException; use function array_keys; use function array_values; use function preg_replace; /** * Updates the README.md file based on answers obtained during project setup */ class UpdateReadme extends Builder { public function build(): void { $this->getConsole()->section('Updating README.md'); $readmeContents = $this->getReadmeContents(); $replacements = [ '/(.*)/s' => $this->getAnswers()->packageName, '/(.*)/s' => $this->getBadges(), '/(.*)/s' => $this->getDescription(), '/(.*)/s' => $this->getCodeOfConduct(), '/(.*)/s' => $this->getUsage(), '/(.*)/s' => '', '/(.*)/s' => $this->getCopyright(), '/(.*)/s' => $this->getSecurityStatement(), ]; /** @var non-empty-string[] $searches */ $searches = array_keys($replacements); /** @var string[] $replaces */ $replaces = array_values($replacements); $readme = (string) preg_replace( $searches, $replaces, $readmeContents, ); $this->getEnvironment()->getFilesystem()->dumpFile( $this->getEnvironment()->path('README.md'), $readme, ); } private function getReadmeContents(): string { $finder = $this->getEnvironment()->getFinder(); $finder ->in($this->getEnvironment()->getAppPath()) ->files() ->depth('== 0') ->name('README.md'); $readmeContents = null; foreach ($finder as $file) { $readmeContents = $file->getContents(); break; } if ($readmeContents === null) { throw new RuntimeException('Unable to get contents of README.md'); } return $readmeContents; } private function getBadges(): string { return $this->getEnvironment()->getTwigEnvironment()->render( 'readme/badges.md.twig', $this->getAnswers()->getArrayCopy(), ); } private function getDescription(): string { return $this->getEnvironment()->getTwigEnvironment()->render( 'readme/description.md.twig', $this->getAnswers()->getArrayCopy(), ); } private function getCodeOfConduct(): string { if ($this->getAnswers()->codeOfConduct === CodeOfConduct::DEFAULT) { return ''; } return $this->getEnvironment()->getTwigEnvironment()->render( 'readme/code-of-conduct.md.twig', $this->getAnswers()->getArrayCopy(), ); } private function getUsage(): string { return $this->getEnvironment()->getTwigEnvironment()->render( 'readme/usage.md.twig', $this->getAnswers()->getArrayCopy(), ); } private function getCopyright(): string { return $this->getEnvironment()->getTwigEnvironment()->render( 'readme/copyright.md.twig', $this->getAnswers()->getArrayCopy(), ); } private function getSecurityStatement(): string { if ($this->getAnswers()->securityPolicy === false) { return ''; } return $this->getEnvironment()->getTwigEnvironment()->render( 'readme/security.md.twig', $this->getAnswers()->getArrayCopy(), ); } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/UpdateSecurityPolicy.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Task\Builder; use const DIRECTORY_SEPARATOR; /** * Updates the project's security policy using the one selected during setup */ class UpdateSecurityPolicy extends Builder { public function build(): void { if ($this->getAnswers()->securityPolicy === false) { $this->getConsole()->section('Removing SECURITY.md'); $this->getEnvironment()->getFilesystem()->remove( $this->getEnvironment()->path('SECURITY.md'), ); return; } $this->getConsole()->section('Updating SECURITY.md'); $securityPolicyTemplate = 'security-policy' . DIRECTORY_SEPARATOR; $securityPolicyTemplate .= 'HackerOne.md.twig'; $securityPolicy = $this->getEnvironment()->getTwigEnvironment()->render( $securityPolicyTemplate, $this->getAnswers()->getArrayCopy(), ); $this->getEnvironment()->getFilesystem()->dumpFile( $this->getEnvironment()->path('SECURITY.md'), $securityPolicy, ); } } ================================================ FILE: src/LibraryStarterKit/Task/Builder/UpdateSourceFileHeaders.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task\Builder; use Ramsey\Dev\LibraryStarterKit\Task\Builder; use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\SplFileInfo; use function array_filter; use function explode; use function implode; use function preg_replace; /** * Updates the source file headers to include license information, based on * responses received during project setup */ class UpdateSourceFileHeaders extends Builder { private const HEADER_PATTERN = '%/\*\*.* \*/%sU'; public function build(): void { $this->getConsole()->section('Updating source file headers'); $newFileHeader = $this->getEnvironment()->getTwigEnvironment()->render( 'header/source-file-header.twig', $this->getAnswers()->getArrayCopy(), ); $headerLines = explode("\n", $newFileHeader); $headerLines = array_filter($headerLines); $newFileHeader = implode("\n", $headerLines); foreach ($this->getSourceFilesFinder() as $file) { $this->replaceSourceFileHeader($file, $newFileHeader); } } private function getSourceFilesFinder(): Finder { $finder = $this->getEnvironment()->getFinder(); $finder ->exclude(['LibraryStarterKit']) ->in([ $this->getEnvironment()->path('src'), ]) ->files() ->name('*.php'); return $finder; } private function replaceSourceFileHeader(SplFileInfo $file, string $newFileHeader): void { $path = (string) $file->getRealPath(); $contents = $file->getContents(); $updatedContents = (string) preg_replace( self::HEADER_PATTERN, $newFileHeader, $contents, 1, ); $this->getEnvironment()->getFilesystem()->dumpFile($path, $updatedContents); } } ================================================ FILE: src/LibraryStarterKit/Task/Builder.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit\Task; use Ramsey\Dev\LibraryStarterKit\Answers; use Ramsey\Dev\LibraryStarterKit\Setup; use Symfony\Component\Console\Style\SymfonyStyle; /** * Represents a builder that uses user responses to build some part of a library */ abstract class Builder { public function __construct(private readonly Build $buildTask) { } /** * Executes the build action for this particular builder */ abstract public function build(): void; public function getAnswers(): Answers { return $this->buildTask->getAnswers(); } public function getEnvironment(): Setup { return $this->buildTask->getSetup(); } public function getConsole(): SymfonyStyle { return $this->buildTask->getConsole(); } /** * Returns a callback that may be used to stream process output to stdout * * @return callable(string, string): void */ public function streamProcessOutput(): callable { return function (string $_type, string $buffer): void { $this->getConsole()->write($buffer); }; } } ================================================ FILE: src/LibraryStarterKit/Wizard.php ================================================ * @license https://opensource.org/licenses/MIT MIT License */ declare(strict_types=1); namespace Ramsey\Dev\LibraryStarterKit; use Composer\Script\Event; use Ramsey\Dev\LibraryStarterKit\Console\InstallQuestions; use Ramsey\Dev\LibraryStarterKit\Console\Question\SkippableQuestion; use Ramsey\Dev\LibraryStarterKit\Console\Question\StarterKitQuestion; use Ramsey\Dev\LibraryStarterKit\Console\StyleFactory; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Finder\Finder; use Throwable; use function basename; use function dirname; use function getenv; use function preg_replace; use function realpath; use function sprintf; use function strtolower; use function trim; class Wizard extends Command { private const ANSWERS_FILE = '.starter-kit-answers'; public static ?Application $application = null; private Answers $answers; public function __construct( private readonly Setup $setup, private readonly StyleFactory $styleFactory = new StyleFactory(), ) { parent::__construct('starter-kit'); $this->answers = new Answers( $this->getAnswersFile(), $this->setup->getFilesystem(), ); if ($this->answers->projectName === null) { $this->answers->projectName = $this->setup->getProject()->getName(); } if ($this->answers->authorName === null) { $this->answers->authorName = $this->getGitUserName(); } if ($this->answers->authorEmail === null) { $this->answers->authorEmail = $this->getGitUserEmail(); } } public function getSetup(): Setup { return $this->setup; } public function getAnswersFile(): string { /** @psalm-suppress RiskyTruthyFalsyComparison */ return getenv('STARTER_KIT_ANSWERS_FILE') ?: $this->setup->path(self::ANSWERS_FILE); } protected function execute(InputInterface $input, OutputInterface $output): int { $output->setVerbosity($this->getSetup()->getVerbosity()); $console = $this->styleFactory->factory($input, $output); $console->title('Welcome to the PHP Library Starter Kit!'); if ($this->answers->skipPrompts === false) { $console->block( 'I\'ll ask you a series of questions about the library ' . 'you\'re creating. When finished, I\'ll set up a repository with ' . 'an initial set of files that you may customize to suit your ' . 'needs.', ); } else { $console->block( 'You\'ve provided an answers file with \'skipPrompts: true\', ' . 'so I won\'t ask any questions. Instead, I\'ll go ahead and ' . 'start setting up a repository with an initial set of files ' . 'that you may customize to suit your needs.', ); } $this->registerInterruptHandler($console); try { if ($this->answers->skipPrompts === false) { if (!$this->confirmStart($console)) { return 0; } $this->askQuestions($console); } $this->setup->run($console, $this->answers); } catch (Throwable $throwable) { return $this->handleException($throwable, $console); } $console->success([ sprintf('Congratulations! Your project, %s, is ready!', (string) $this->answers->packageName), sprintf('Your project is available at %s.', $this->setup->getProject()->getPath()), ]); return 0; } private function getGitUserName(): ?string { $process = $this->getSetup()->getProcess( ['git', 'config', 'user.name'], ); $process->run(); return trim($process->getOutput()) ?: null; } private function getGitUserEmail(): ?string { $process = $this->getSetup()->getProcess( ['git', 'config', 'user.email'], ); $process->run(); return trim($process->getOutput()) ?: null; } private function confirmStart(SymfonyStyle $console): bool { $getStarted = new ConfirmationQuestion('Are you ready to get started?', false); /** @var bool $confirmStart */ $confirmStart = $console->askQuestion($getStarted); if ($confirmStart) { return true; } $this->exitEarly($console); return false; } private function askQuestions(SymfonyStyle $console): void { /** * @var Question & StarterKitQuestion $question */ foreach ((new InstallQuestions())->getQuestions($this->answers) as $question) { if ($question instanceof SkippableQuestion && $question->shouldSkip()) { $this->answers->{$question->getName()} = $question->getDefault(); continue; } $this->answers->{$question->getName()} = $console->askQuestion($question); } } private function exitEarly(SymfonyStyle $console): void { $this->answers->saveToFile(); $console->block([ 'I\'ve saved your progress. When you\'re ready to return to the ' . 'starter kit wizard, enter:', ]); $console->text([ ' cd ' . $this->setup->getAppPath() . '', ' composer starter-kit', ]); $console->newLine(); } /** * @codeCoverageIgnore */ private function registerInterruptHandler(SymfonyStyle $console): void { $interruptHandler = function () use ($console): void { $this->exitEarly($console); exit(0); }; // phpcs:disable if (\function_exists('pcntl_signal')) { \pcntl_signal(\SIGINT, $interruptHandler); \pcntl_signal(\SIGTERM, $interruptHandler); } elseif (\function_exists('sapi_windows_set_ctrl_handler')) { \sapi_windows_set_ctrl_handler($interruptHandler); } // phpcs:enable } private function handleException(Throwable $throwable, SymfonyStyle $console): int { $errorMessages = [ $throwable->getMessage(), sprintf('At line %d in %s', $throwable->getLine(), $throwable->getFile()), ]; if ($console->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) { $errorMessages[] = $throwable->getTraceAsString(); } $console->error($errorMessages); $console->block([ 'Oops! I encountered an error.', 'Please go here and click the "New issue" button to report this error: ' . 'https://github.com/ramsey/php-library-starter-kit/issues', ]); $console->newLine(); return (int) $throwable->getCode() ?: 1; } public static function newApplication(): Application { return self::$application ?? new Application(); } public static function start(Event $event): void { /** @var string $vendorDir */ $vendorDir = $event->getComposer()->getConfig()->get('vendor-dir'); $appPath = dirname($vendorDir); $projectName = strtolower(basename((string) realpath($appPath))); $projectName = (string) preg_replace('/[^a-z0-9]/', '-', $projectName); $project = new Project($projectName, $appPath); $setup = new Setup($project, $event, new Filesystem(), new Finder(), self::determineVerbosityLevel($event)); $command = new self($setup); $application = self::newApplication(); $application->add($command); $application->setDefaultCommand((string) $command->getName(), true); $application->run(new StringInput('')); } /** * @return OutputInterface::VERBOSITY_* */ public static function determineVerbosityLevel(Event $event): int { if ($event->getIO()->isDebug()) { return OutputInterface::VERBOSITY_DEBUG; } elseif ($event->getIO()->isVeryVerbose()) { return OutputInterface::VERBOSITY_VERY_VERBOSE; } elseif ($event->getIO()->isVerbose()) { return OutputInterface::VERBOSITY_VERBOSE; } return OutputInterface::VERBOSITY_NORMAL; } } ================================================ FILE: tests/ExampleTest.php ================================================ mockery(Example::class); $example->shouldReceive('greet')->passthru(); $this->assertSame('Hello, Friends!', $example->greet('Friends')); } } ================================================ FILE: tests/LibraryStarterKit/AnswersTest.php ================================================ filesystem = $this->mockery(Filesystem::class); } public function testGetTokens(): void { $this->filesystem->expects()->exists('/path/to/file.json')->andReturnFalse(); $answers = new Answers('/path/to/file.json', $this->filesystem); $this->assertSame( [ 'authorEmail', 'authorHoldsCopyright', 'authorName', 'authorUrl', 'codeOfConduct', 'codeOfConductCommittee', 'codeOfConductEmail', 'codeOfConductPoliciesUrl', 'codeOfConductReportingUrl', 'copyrightEmail', 'copyrightHolder', 'copyrightUrl', 'copyrightYear', 'githubUsername', 'license', 'packageDescription', 'packageKeywords', 'packageName', 'packageNamespace', 'projectName', 'securityPolicy', 'securityPolicyContactEmail', 'securityPolicyContactFormUrl', 'skipPrompts', 'vendorName', ], $answers->getTokens(), ); } public function testGetValues(): void { $this->filesystem->expects()->exists('/path/to/file.json')->andReturnFalse(); $answers = new Answers('/path/to/file.json', $this->filesystem); $this->assertSame( [ null, true, null, null, 'None', null, null, null, null, null, null, null, null, null, 'Proprietary', null, [], null, null, null, true, null, null, false, null, ], $answers->getValues(), ); } public function testGetArrayCopy(): void { $this->filesystem->expects()->exists('/path/to/file.json')->andReturnFalse(); $answers = new Answers('/path/to/file.json', $this->filesystem); $this->assertSame( [ 'authorEmail' => null, 'authorHoldsCopyright' => true, 'authorName' => null, 'authorUrl' => null, 'codeOfConduct' => 'None', 'codeOfConductCommittee' => null, 'codeOfConductEmail' => null, 'codeOfConductPoliciesUrl' => null, 'codeOfConductReportingUrl' => null, 'copyrightEmail' => null, 'copyrightHolder' => null, 'copyrightUrl' => null, 'copyrightYear' => null, 'githubUsername' => null, 'license' => 'Proprietary', 'packageDescription' => null, 'packageKeywords' => [], 'packageName' => null, 'packageNamespace' => null, 'projectName' => null, 'securityPolicy' => true, 'securityPolicyContactEmail' => null, 'securityPolicyContactFormUrl' => null, 'skipPrompts' => false, 'vendorName' => null, ], $answers->getArrayCopy(), ); } public function testLoadsExistingFileUponInstantiation(): void { $filesystem = new Filesystem(); $answers = new Answers(__DIR__ . '/answers-test.json', $filesystem); $this->assertSame( [ 'authorEmail' => 'frodo@example.com', 'authorHoldsCopyright' => true, 'authorName' => 'Frodo Baggins', 'authorUrl' => 'https://example.com/the-fellowship/frodo', 'codeOfConduct' => 'Citizen-2.3', 'codeOfConductCommittee' => 'Council of the Wise', 'codeOfConductEmail' => 'council@example.com', 'codeOfConductPoliciesUrl' => 'https://example.com/the-fellowship/conduct-policies', 'codeOfConductReportingUrl' => 'https://example.com/the-fellowship/conduct-reporting', 'copyrightEmail' => 'fellowship@example.com', 'copyrightHolder' => 'The Fellowship', 'copyrightUrl' => 'https://example.com/the-fellowship', 'copyrightYear' => '2021', 'githubUsername' => 'frodo', 'license' => 'BSD-2-Clause', 'packageDescription' => 'A package to help you on your journey.', 'packageKeywords' => ['foo', 'bar'], 'packageName' => 'fellowship/ring', 'packageNamespace' => 'Fellowship\\Ring', 'projectName' => 'The Fellowship of the Ring', 'securityPolicy' => true, 'securityPolicyContactEmail' => 'security@example.com', 'securityPolicyContactFormUrl' => 'https://example.com/security', 'skipPrompts' => true, 'vendorName' => 'fellowship', ], $answers->getArrayCopy(), ); } public function testSaveToFile(): void { $this->filesystem->expects()->exists('/path/to/file.json')->andReturnFalse(); $this->filesystem->shouldReceive('dumpFile')->withArgs( function (string $filename, string $content) { $this->assertSame('/path/to/file.json', $filename); $this->assertJsonStringEqualsJsonString( (string) json_encode([ 'authorEmail' => 'frodo@example.com', 'authorHoldsCopyright' => true, 'authorName' => 'Frodo Baggins', 'authorUrl' => 'https://example.com/the-fellowship/frodo', 'codeOfConduct' => 'Citizen-2.3', 'codeOfConductCommittee' => 'Council of the Wise', 'codeOfConductEmail' => 'council@example.com', 'codeOfConductPoliciesUrl' => 'https://example.com/the-fellowship/conduct-policies', 'codeOfConductReportingUrl' => 'https://example.com/the-fellowship/conduct-reporting', 'copyrightEmail' => 'fellowship@example.com', 'copyrightHolder' => 'The Fellowship', 'copyrightUrl' => 'https://example.com/the-fellowship', 'copyrightYear' => '2021', 'githubUsername' => 'frodo', 'license' => 'BSD-2-Clause', 'packageDescription' => 'A package to help you on your journey.', 'packageKeywords' => ['foo', 'bar'], 'packageName' => 'fellowship/ring', 'packageNamespace' => 'Fellowship\\Ring', 'projectName' => 'The Fellowship of the Ring', 'securityPolicy' => true, 'securityPolicyContactEmail' => 'security@example.com', 'securityPolicyContactFormUrl' => 'https://example.com/security', 'skipPrompts' => false, 'vendorName' => 'fellowship', ]), $content, ); return true; }, ); $answers = new Answers('/path/to/file.json', $this->filesystem); $answers->authorEmail = 'frodo@example.com'; $answers->authorHoldsCopyright = true; $answers->authorName = 'Frodo Baggins'; $answers->authorUrl = 'https://example.com/the-fellowship/frodo'; $answers->codeOfConduct = 'Citizen-2.3'; $answers->codeOfConductCommittee = 'Council of the Wise'; $answers->codeOfConductEmail = 'council@example.com'; $answers->codeOfConductPoliciesUrl = 'https://example.com/the-fellowship/conduct-policies'; $answers->codeOfConductReportingUrl = 'https://example.com/the-fellowship/conduct-reporting'; $answers->copyrightEmail = 'fellowship@example.com'; $answers->copyrightHolder = 'The Fellowship'; $answers->copyrightUrl = 'https://example.com/the-fellowship'; $answers->copyrightYear = '2021'; $answers->githubUsername = 'frodo'; $answers->license = 'BSD-2-Clause'; $answers->packageDescription = 'A package to help you on your journey.'; $answers->packageKeywords = ['foo', 'bar']; $answers->packageName = 'fellowship/ring'; $answers->packageNamespace = 'Fellowship\\Ring'; $answers->projectName = 'The Fellowship of the Ring'; $answers->securityPolicy = true; $answers->securityPolicyContactEmail = 'security@example.com'; $answers->securityPolicyContactFormUrl = 'https://example.com/security'; $answers->vendorName = 'fellowship'; $answers->saveToFile(); } } ================================================ FILE: tests/LibraryStarterKit/Console/InstallQuestionsTest.php ================================================ getQuestions($this->answers); $this->assertContainsOnlyInstancesOf(Question::class, $receivedQuestions); $this->assertContainsOnlyInstancesOf(StarterKitQuestion::class, $receivedQuestions); $this->assertCount(23, $receivedQuestions); } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/AuthorEmailTest.php ================================================ answers->authorHoldsCopyright = false; $question = new AuthorHoldsCopyright($this->answers); $this->assertFalse($question->getDefault()); } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/AuthorNameTest.php ================================================ answers))->getValidator(); $this->assertSame('The Big Committee', $validator('The Big Committee')); $this->assertNull($validator(null)); } #[DataProvider('provideSkipValues')] public function testShouldSkip(string $choice, bool $expected): void { $question = new CodeOfConductCommittee($this->answers); $this->answers->codeOfConduct = $choice; $this->assertSame($expected, $question->shouldSkip()); } /** * @return list */ public static function provideSkipValues(): array { return [ [ 'choice' => 'None', 'expected' => true, ], [ 'choice' => 'Contributor-1.4', 'expected' => true, ], [ 'choice' => 'Contributor-2.0', 'expected' => true, ], [ 'choice' => 'Contributor-2.1', 'expected' => true, ], [ 'choice' => 'Citizen-2.3', 'expected' => false, ], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/CodeOfConductEmailTest.php ================================================ answers); $this->answers->codeOfConduct = $choice; $this->assertSame($expected, $question->shouldSkip()); } /** * @return list */ public static function provideSkipValues(): array { return [ [ 'choice' => 'None', 'expected' => true, ], [ 'choice' => 'Contributor-1.4', 'expected' => false, ], [ 'choice' => 'Contributor-2.0', 'expected' => false, ], [ 'choice' => 'Contributor-2.1', 'expected' => false, ], [ 'choice' => 'Citizen-2.3', 'expected' => false, ], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/CodeOfConductPoliciesUrlTest.php ================================================ answers); $this->answers->codeOfConduct = $choice; $this->assertSame($expected, $question->shouldSkip()); } /** * @return list */ public static function provideSkipValues(): array { return [ [ 'choice' => 'None', 'expected' => true, ], [ 'choice' => 'Contributor-1.4', 'expected' => true, ], [ 'choice' => 'Contributor-2.0', 'expected' => true, ], [ 'choice' => 'Contributor-2.1', 'expected' => true, ], [ 'choice' => 'Citizen-2.3', 'expected' => false, ], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/CodeOfConductReportingUrlTest.php ================================================ answers); $this->answers->codeOfConduct = $choice; $this->assertSame($expected, $question->shouldSkip()); } /** * @return list */ public static function provideSkipValues(): array { return [ [ 'choice' => 'None', 'expected' => true, ], [ 'choice' => 'Contributor-1.4', 'expected' => true, ], [ 'choice' => 'Contributor-2.0', 'expected' => true, ], [ 'choice' => 'Contributor-2.1', 'expected' => true, ], [ 'choice' => 'Citizen-2.3', 'expected' => false, ], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/CodeOfConductTest.php ================================================ answers->codeOfConduct = 'Contributor-2.0'; $question = new CodeOfConduct($this->answers); $this->assertSame(3, $question->getDefault()); } public function testGetChoices(): void { $question = new CodeOfConduct($this->answers); $this->assertSame( [ 1 => 'None', 2 => 'Contributor Covenant Code of Conduct, version 1.4', 3 => 'Contributor Covenant Code of Conduct, version 2.0', 4 => 'Contributor Covenant Code of Conduct, version 2.1', 5 => 'Citizen Code of Conduct, version 2.3', ], $question->getChoices(), ); } #[DataProvider('provideNormalizerTestValues')] public function testNormalizer(?string $value, string $expected): void { $normalizer = (new CodeOfConduct($this->answers))->getNormalizer(); $this->assertSame($expected, $normalizer($value)); } /** * @return list */ public static function provideNormalizerTestValues(): array { return [ ['value' => '1', 'expected' => 'None'], ['value' => '2', 'expected' => 'Contributor-1.4'], ['value' => '3', 'expected' => 'Contributor-2.0'], ['value' => '4', 'expected' => 'Contributor-2.1'], ['value' => '5', 'expected' => 'Citizen-2.3'], ['value' => 'None', 'expected' => 'None'], ['value' => 'Contributor Covenant Code of Conduct, version 1.4', 'expected' => 'Contributor-1.4'], ['value' => 'Contributor Covenant Code of Conduct, version 2.0', 'expected' => 'Contributor-2.0'], ['value' => 'Contributor Covenant Code of Conduct, version 2.1', 'expected' => 'Contributor-2.1'], ['value' => 'Citizen Code of Conduct, version 2.3', 'expected' => 'Citizen-2.3'], ['value' => '6', 'expected' => '6'], ['value' => null, 'expected' => ''], ['value' => 'foo', 'expected' => 'foo'], ]; } #[DataProvider('provideValidValues')] public function testValidator(string $value, ?string $expected): void { $validator = (new CodeOfConduct($this->answers))->getValidator(); $this->assertSame($expected, $validator($value)); } /** * @return list */ public static function provideValidValues(): array { return [ [ 'value' => 'None', 'expected' => 'None', ], [ 'value' => 'Contributor-1.4', 'expected' => 'Contributor-1.4', ], [ 'value' => 'Contributor-2.0', 'expected' => 'Contributor-2.0', ], [ 'value' => 'Contributor-2.1', 'expected' => 'Contributor-2.1', ], [ 'value' => 'Citizen-2.3', 'expected' => 'Citizen-2.3', ], ]; } #[DataProvider('provideInvalidValues')] public function testValidatorThrowsExceptionForInvalidValues(?string $value, string $message): void { $validator = (new CodeOfConduct($this->answers))->getValidator(); $this->expectException(InvalidConsoleInput::class); $this->expectExceptionMessage($message); $validator($value); } /** * @return list */ public static function provideInvalidValues(): array { return [ [ 'value' => null, 'message' => '"" is not a valid code of conduct choice.', ], [ 'value' => ' ', 'message' => '" " is not a valid code of conduct choice.', ], [ 'value' => 'foo', 'message' => '"foo" is not a valid code of conduct choice.', ], [ 'value' => '6', 'message' => '"6" is not a valid code of conduct choice.', ], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/CopyrightEmailTest.php ================================================ answers); $this->answers->authorEmail = 'samwise@example.com'; $this->assertSame('samwise@example.com', $question->getDefault()); } #[DataProvider('provideSkipValues')] public function testShouldSkip(bool $choice, bool $expected): void { $question = new CopyrightEmail($this->answers); $this->answers->authorHoldsCopyright = $choice; $this->assertSame($expected, $question->shouldSkip()); } /** * @return list */ public static function provideSkipValues(): array { return [ [ 'choice' => false, 'expected' => false, ], [ 'choice' => true, 'expected' => true, ], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/CopyrightHolderTest.php ================================================ answers); $this->answers->authorName = 'Samwise Gamgee'; $this->assertSame('Samwise Gamgee', $question->getDefault()); } #[DataProvider('provideSkipValues')] public function testShouldSkip(bool $choice, bool $expected): void { $question = new CopyrightHolder($this->answers); $this->answers->authorHoldsCopyright = $choice; $this->assertSame($expected, $question->shouldSkip()); } /** * @return list */ public static function provideSkipValues(): array { return [ [ 'choice' => false, 'expected' => false, ], [ 'choice' => true, 'expected' => true, ], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/CopyrightUrlTest.php ================================================ answers); $this->answers->authorUrl = 'https://example.com/copyright'; $this->assertSame('https://example.com/copyright', $question->getDefault()); } #[DataProvider('provideSkipValues')] public function testShouldSkip(bool $choice, bool $expected): void { $question = new CopyrightUrl($this->answers); $this->answers->authorHoldsCopyright = $choice; $this->assertSame($expected, $question->shouldSkip()); } /** * @return list */ public static function provideSkipValues(): array { return [ [ 'choice' => false, 'expected' => false, ], [ 'choice' => true, 'expected' => true, ], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/CopyrightYearTest.php ================================================ answers); $this->assertSame($yearNow, $question->getDefault()); } public function testValidatorReturnsValidValue(): void { $validator = (new CopyrightYear($this->answers))->getValidator(); $this->assertSame('2017', $validator('2017')); } #[DataProvider('provideInvalidDateValues')] public function testValidatorThrowsExceptionForInvalidValue(?string $value): void { $validator = (new CopyrightYear($this->answers))->getValidator(); $this->expectException(InvalidConsoleInput::class); $this->expectExceptionMessage('You must enter a valid, 4-digit year.'); $validator($value); } /** * @return list */ public static function provideInvalidDateValues(): array { return [ ['value' => null], ['value' => '19'], ['value' => 'foo'], ['value' => 'YEAR'], ['value' => '997'], ['value' => '21201'], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/EmailValidatorToolTest.php ================================================ isOptional = false; } }; $validator = $question->getValidator(); $this->expectException(InvalidConsoleInput::class); $this->expectExceptionMessage('You must enter a valid email address.'); $validator($value); } #[DataProvider('provideNullableValues')] public function testValidatorReturnsNullWhenQuestionIsOptional(?string $value): void { $question = new class () { use EmailValidatorTool; }; $validator = $question->getValidator(); $this->assertNull($validator($value)); } /** * @return list */ public static function provideNullableValues(): array { return [ ['value' => null], ['value' => ''], ['value' => ' '], ]; } public function testValidatorReturnsValueWhenValid(): void { $question = new class () { use EmailValidatorTool; }; $validator = $question->getValidator(); $this->assertSame('jane@example.com', $validator('jane@example.com')); } public function testValidatorThrowsExceptionWhenNotValid(): void { $question = new class () { use EmailValidatorTool; }; $validator = $question->getValidator(); $this->expectException(InvalidConsoleInput::class); $this->expectExceptionMessage('You must enter a valid email address.'); $validator('not-a-valid-address'); } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/GithubUsernameTest.php ================================================ answers->license = 'MIT-0'; $question = new License($this->answers); $this->assertSame(11, $question->getDefault()); } public function testGetChoices(): void { $question = new License($this->answers); $this->assertSame( [ 1 => 'Proprietary', 2 => 'Apache License 2.0', 3 => 'BSD 2-Clause "Simplified" License', 4 => 'BSD 3-Clause "New" or "Revised" License', 5 => 'Creative Commons Zero v1.0 Universal', 6 => 'GNU Affero General Public License v3.0 or later', 7 => 'GNU General Public License v3.0 or later', 8 => 'GNU Lesser General Public License v3.0 or later', 9 => 'Hippocratic License 2.1', 10 => 'MIT License', 11 => 'MIT No Attribution', 12 => 'Mozilla Public License 2.0', 13 => 'Unlicense', ], $question->getChoices(), ); } #[DataProvider('provideNormalizerTestValues')] public function testNormalizer(?string $value, string $expected): void { $normalizer = (new License($this->answers))->getNormalizer(); $this->assertSame($expected, $normalizer($value)); } /** * @return list */ public static function provideNormalizerTestValues(): array { return [ ['value' => '1', 'expected' => 'Proprietary'], ['value' => '2', 'expected' => 'Apache-2.0'], ['value' => '3', 'expected' => 'BSD-2-Clause'], ['value' => '4', 'expected' => 'BSD-3-Clause'], ['value' => '5', 'expected' => 'CC0-1.0'], ['value' => '6', 'expected' => 'AGPL-3.0-or-later'], ['value' => '7', 'expected' => 'GPL-3.0-or-later'], ['value' => '8', 'expected' => 'LGPL-3.0-or-later'], ['value' => '9', 'expected' => 'Hippocratic-2.1'], ['value' => '10', 'expected' => 'MIT'], ['value' => '11', 'expected' => 'MIT-0'], ['value' => '12', 'expected' => 'MPL-2.0'], ['value' => '13', 'expected' => 'Unlicense'], ['value' => 'Proprietary', 'expected' => 'Proprietary'], ['value' => 'Apache License 2.0', 'expected' => 'Apache-2.0'], ['value' => 'BSD 2-Clause "Simplified" License', 'expected' => 'BSD-2-Clause'], ['value' => 'BSD 3-Clause "New" or "Revised" License', 'expected' => 'BSD-3-Clause'], ['value' => 'Creative Commons Zero v1.0 Universal', 'expected' => 'CC0-1.0'], ['value' => 'GNU Affero General Public License v3.0 or later', 'expected' => 'AGPL-3.0-or-later'], ['value' => 'GNU General Public License v3.0 or later', 'expected' => 'GPL-3.0-or-later'], ['value' => 'GNU Lesser General Public License v3.0 or later', 'expected' => 'LGPL-3.0-or-later'], ['value' => 'Hippocratic License 2.1', 'expected' => 'Hippocratic-2.1'], ['value' => 'MIT License', 'expected' => 'MIT'], ['value' => 'MIT No Attribution', 'expected' => 'MIT-0'], ['value' => 'Mozilla Public License 2.0', 'expected' => 'MPL-2.0'], ['value' => 'Unlicense', 'expected' => 'Unlicense'], ['value' => '14', 'expected' => '14'], ['value' => null, 'expected' => ''], ['value' => 'foo', 'expected' => 'foo'], ]; } #[DataProvider('provideValidValues')] public function testValidator(string $value): void { $validator = (new License($this->answers))->getValidator(); $this->assertSame($value, $validator($value)); } /** * @return array */ public static function provideValidValues(): array { return array_map(fn (string $v): array => [$v], License::CHOICE_IDENTIFIER_MAP); } #[DataProvider('provideInvalidValues')] public function testValidatorThrowsExceptionForInvalidValues(?string $value, string $message): void { $validator = (new License($this->answers))->getValidator(); $this->expectException(InvalidConsoleInput::class); $this->expectExceptionMessage($message); $validator($value); } /** * @return array */ public static function provideInvalidValues(): array { return [ [ 'value' => null, 'message' => '"" is not a valid license choice.', ], [ 'value' => ' ', 'message' => '" " is not a valid license choice.', ], [ 'value' => 'foo', 'message' => '"foo" is not a valid license choice.', ], [ 'value' => '14', 'message' => '"14" is not a valid license choice.', ], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/PackageDescriptionTest.php ================================================ answers))->getValidator(); $this->assertSame( 'A brief description of my library.', $validator('A brief description of my library.'), ); $this->assertNull($validator(null)); } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/PackageKeywordsTest.php ================================================ answers->packageKeywords = ['foo', 'bar', 'baz']; $question = new PackageKeywords($this->answers); $this->assertSame('foo,bar,baz', $question->getDefault()); } /** * @param string[] $expected */ #[DataProvider('provideNormalizerTestValues')] public function testNormalizer(?string $value, array $expected): void { $normalizer = (new PackageKeywords($this->answers))->getNormalizer(); $this->assertSame($expected, $normalizer($value)); } /** * @return list */ public static function provideNormalizerTestValues(): array { return [ [ 'value' => null, 'expected' => [], ], [ 'value' => ' ', 'expected' => [], ], [ 'value' => 'foo, bar , , ,,,, ,baz ,,quux,,', 'expected' => [ 'foo', 'bar', 'baz', 'quux', ], ], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/PackageNameTest.php ================================================ answers); $this->answers->vendorName = 'frodo'; $this->answers->projectName = 'fellowship'; $this->assertSame('frodo/fellowship', $question->getDefault()); } public function testValidator(): void { $validator = (new PackageName($this->answers))->getValidator(); $this->assertSame('foo/bar', $validator('foo/bar')); } public function testValidatorWithVendorPrefix(): void { $validator = (new PackageName($this->answers))->getValidator(); $this->answers->vendorName = 'frodo'; $this->assertSame('frodo/fellowship-of-the-ring', $validator('frodo/fellowship-of-the-ring')); } public function testValidatorWithoutVendorPrefix(): void { $validator = (new PackageName($this->answers))->getValidator(); $this->answers->vendorName = 'frodo'; $this->assertSame('frodo/fellowship_ring', $validator('fellowship_ring')); } #[DataProvider('provideInvalidPackageNames')] public function testValidatorThrowsExceptionForInvalidPackageNames(?string $value, ?string $vendorName): void { $validator = (new PackageName($this->answers))->getValidator(); $this->answers->vendorName = $vendorName; $this->expectException(InvalidConsoleInput::class); $this->expectExceptionMessage('You must enter a valid package name.'); $validator($value); } /** * @return list */ public static function provideInvalidPackageNames(): array { return [ [ 'value' => null, 'vendorName' => null, ], [ 'value' => ' ', 'vendorName' => null, ], [ 'value' => 'foo/bar/baz', 'vendorName' => null, ], [ 'value' => null, 'vendorName' => 'foo', ], [ 'value' => 'bar/baz', 'vendorName' => 'foo', ], [ 'value' => 'bar---baz', 'vendorName' => 'foo', ], [ 'value' => '_bar', 'vendorName' => 'foo', ], [ 'value' => 'bar', 'vendorName' => '-foo', ], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/PackageNamespaceTest.php ================================================ answers); $this->answers->packageName = ' '; $this->assertNull($question->getDefault()); } public function testDefaultWithPackageName(): void { $question = new PackageNamespace($this->answers); $this->answers->packageName = 'frodo/fellowship-of-the-ring'; $this->assertSame('Frodo\\Fellowship\\Of\\The\\Ring', $question->getDefault()); $this->assertSame('What is the library\'s root namespace?', $question->getQuestion()); } public function testDefaultWithOddlyNamedPackageName(): void { $question = new PackageNamespace($this->answers); $this->answers->packageName = 'foo/1bar-2baz'; $this->assertSame('Foo\\Bar\\Baz', $question->getDefault()); $this->assertSame('What is the library\'s root namespace?', $question->getQuestion()); } public function testValidator(): void { $validator = (new PackageNamespace($this->answers))->getValidator(); $this->assertSame('Foo\\Bar\\Baz\\Quux', $validator('Foo\\Bar\\Baz\\Quux')); } public function testValidatorThrowsExceptionForInvalidNamespaceName(): void { $validator = (new PackageNamespace($this->answers))->getValidator(); $this->expectException(InvalidConsoleInput::class); $this->expectExceptionMessage('You must enter a valid library namespace.'); $validator('1Foo'); } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/QuestionTestCase.php ================================================ */ abstract protected function getTestClass(): string; abstract protected function getQuestionName(): string; abstract protected function getQuestionText(): string; protected function getQuestionDefault(): mixed { return null; } public function testGetName(): void { $questionClass = $this->getTestClass(); /** @phpstan-ignore-next-line */ $question = new $questionClass($this->answers); $this->assertSame($this->getQuestionName(), $question->getName()); } public function testGetQuestion(): void { $questionClass = $this->getTestClass(); /** @phpstan-ignore-next-line */ $question = new $questionClass($this->answers); $this->assertSame($this->getQuestionText(), $question->getQuestion()); } public function testGetAnswers(): void { $questionClass = $this->getTestClass(); /** @phpstan-ignore-next-line */ $question = new $questionClass($this->answers); $this->assertSame($this->answers, $question->getAnswers()); } public function testGetDefault(): void { $questionClass = $this->getTestClass(); /** @phpstan-ignore-next-line */ $question = new $questionClass($this->answers); $this->assertSame($this->getQuestionDefault(), $question->getDefault()); } public function testGetDefaultWhenAnswerAlreadySet(): void { $this->answers->{$this->getQuestionName()} = 'foobar'; $questionClass = $this->getTestClass(); /** @phpstan-ignore-next-line */ $question = new $questionClass($this->answers); $this->assertSame('foobar', $question->getDefault()); } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/SecurityPolicyContactEmailTest.php ================================================ answers); $this->answers->securityPolicy = $choice; $this->assertSame($expected, $question->shouldSkip()); } /** * @return list */ public static function provideSkipValues(): array { return [ [ 'choice' => false, 'expected' => true, ], [ 'choice' => true, 'expected' => false, ], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/SecurityPolicyContactFormUrlTest.php ================================================ answers); $this->answers->securityPolicy = $choice; $this->assertSame($expected, $question->shouldSkip()); } /** * @return list */ public static function provideSkipValues(): array { return [ [ 'choice' => false, 'expected' => true, ], [ 'choice' => true, 'expected' => false, ], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/SecurityPolicyTest.php ================================================ answers->securityPolicy = false; $question = new SecurityPolicy($this->answers); $this->assertFalse($question->getDefault()); } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/UrlValidatorToolTest.php ================================================ isOptional = false; } }; $validator = $question->getValidator(); $this->expectException(InvalidConsoleInput::class); $this->expectExceptionMessage('You must enter a valid URL, beginning with "http://" or "https://".'); $validator($value); } #[DataProvider('provideNullableValues')] public function testValidatorReturnsNullWhenQuestionIsOptional(?string $value): void { $question = new class () { use UrlValidatorTool; }; $validator = $question->getValidator(); $this->assertNull($validator($value)); } /** * @return list */ public static function provideNullableValues(): array { return [ ['value' => null], ['value' => ''], ['value' => ' '], ]; } public function testValidatorReturnsValueWhenValid(): void { $question = new class () { use UrlValidatorTool; }; $validator = $question->getValidator(); $this->assertSame('https://example.com', $validator('https://example.com')); } public function testValidatorThrowsExceptionWhenNotValid(): void { $question = new class () { use UrlValidatorTool; }; $validator = $question->getValidator(); $this->expectException(InvalidConsoleInput::class); $this->expectExceptionMessage('You must enter a valid URL, beginning with "http://" or "https://".'); $validator('ftp://example.com'); } } ================================================ FILE: tests/LibraryStarterKit/Console/Question/VendorNameTest.php ================================================ answers); $this->answers->githubUsername = 'foobar'; $this->assertSame('foobar', $question->getDefault()); } public function testValidatorReturnsValidValue(): void { $validator = (new VendorName($this->answers))->getValidator(); $this->assertSame('foo-bar-baz', $validator('foo-bar-baz')); } #[DataProvider('provideInvalidValues')] public function testValidatorThrowsExceptionForInvalidValue(?string $value): void { $validator = (new VendorName($this->answers))->getValidator(); $this->expectException(InvalidConsoleInput::class); $this->expectExceptionMessage('You must enter a valid vendor name.'); $validator($value); } /** * @return list */ public static function provideInvalidValues(): array { return [ ['value' => null], ['value' => ' '], ['value' => 'foo---bar'], ['value' => 'foo/bar'], ]; } } ================================================ FILE: tests/LibraryStarterKit/Console/StyleFactoryTest.php ================================================ factory($input, $output); /** @phpstan-ignore-next-line */ $this->assertInstanceOf(SymfonyStyle::class, $style); } } ================================================ FILE: tests/LibraryStarterKit/FilesystemTest.php ================================================ getFile(__FILE__); /** @phpstan-ignore-next-line */ $this->assertInstanceOf(SplFileInfo::class, $file); } } ================================================ FILE: tests/LibraryStarterKit/ProjectTest.php ================================================ assertSame('project-name', $project->getName()); $this->assertSame('/path/to/project', $project->getPath()); } } ================================================ FILE: tests/LibraryStarterKit/SetupTest.php ================================================ appPath = dirname(__FILE__, 3); /** @var Event & MockInterface $event */ $event = $this->mockery(Event::class, [ 'getIO' => $this->mockery(IOInterface::class), ]); /** @var Filesystem & MockInterface $filesystem */ $filesystem = $this->mockery(Filesystem::class); /** @var Finder & MockInterface $finder */ $finder = $this->mockery(Finder::class); $finder->shouldReceive('create')->andReturn(clone $finder); $project = new Project('a-project-name', $this->appPath); $this->setup = new Setup( $project, $event, $filesystem, $finder, OutputInterface::VERBOSITY_NORMAL, ); } public function testGetAppPath(): void { $this->assertIsString($this->setup->getAppPath()); } public function testGetEvent(): void { /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Event::class, $this->setup->getEvent()); } public function testGetFilesystem(): void { /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Filesystem::class, $this->setup->getFilesystem()); } public function testGetFinder(): void { /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Finder::class, $this->setup->getFinder()); } public function testGetProjectName(): void { $this->assertSame('a-project-name', $this->setup->getProjectName()); } public function testGetVerbosity(): void { $this->assertSame(OutputInterface::VERBOSITY_NORMAL, $this->setup->getVerbosity()); } public function testGetBuild(): void { /** @var SymfonyStyle & MockInterface $console */ $console = $this->mockery(SymfonyStyle::class); $build = $this->setup->getBuild($console, $this->answers); $this->assertSame($this->answers, $build->getAnswers()); $this->assertSame($console, $build->getConsole()); $this->assertSame($this->setup, $build->getSetup()); } public function testGetTwigEnvironment(): void { /** @phpstan-ignore-next-line */ $this->assertInstanceOf(TwigEnvironment::class, $this->setup->getTwigEnvironment()); } public function testRun(): void { /** @var SymfonyStyle & MockInterface $console */ $console = $this->mockery(SymfonyStyle::class); $build = $this->mockery(Build::class); $build->expects()->run(); /** @var Setup & MockInterface $setup */ $setup = $this->mockery(Setup::class, [ 'getBuild' => $build, ]); $setup->shouldReceive('run')->passthru(); $setup->run($console, $this->answers); } public function testGetProcessForCommand(): void { $process = $this->setup->getProcess(['ls', '-la']); /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Process::class, $process); } public function testPath(): void { $this->assertSame( $this->appPath . DIRECTORY_SEPARATOR . 'foobar', $this->setup->path('foobar'), ); } } ================================================ FILE: tests/LibraryStarterKit/SnapshotsTool.php ================================================ getShortName() . '__' . $this->nameWithDataSet() . '__' . $this->snapshotIncrementor; return (string) preg_replace('/[^0-9a-z]/i', '_', $snapshotId); } } ================================================ FILE: tests/LibraryStarterKit/Task/BuildTest.php ================================================ mockery(Setup::class); /** @var SymfonyStyle & MockInterface $console */ $console = $this->mockery(SymfonyStyle::class); $build = new Build($setup, $console, $this->answers); $this->assertSame($this->answers, $build->getAnswers()); } public function testGetSetup(): void { /** @var Setup & MockInterface $setup */ $setup = $this->mockery(Setup::class); /** @var SymfonyStyle & MockInterface $console */ $console = $this->mockery(SymfonyStyle::class); $build = new Build($setup, $console, $this->answers); $this->assertSame($setup, $build->getSetup()); } public function testGetConsole(): void { /** @var Setup & MockInterface $setup */ $setup = $this->mockery(Setup::class); /** @var SymfonyStyle & MockInterface $console */ $console = $this->mockery(SymfonyStyle::class); $build = new Build($setup, $console, $this->answers); $this->assertSame($console, $build->getConsole()); } public function testGetBuilders(): void { /** @var Setup & MockInterface $setup */ $setup = $this->mockery(Setup::class); /** @var SymfonyStyle & MockInterface $console */ $console = $this->mockery(SymfonyStyle::class); $build = new Build($setup, $console, $this->answers); $builders = $build->getBuilders(); $this->assertContainsOnlyInstancesOf(Builder::class, $builders); $this->assertCount(16, $builders); } public function testRun(): void { $builder1 = $this->mockery(Builder::class); $builder1->expects()->build(); $builder2 = $this->mockery(Builder::class); $builder2->expects()->build(); $builder3 = $this->mockery(Builder::class); $builder3->expects()->build(); $build = $this->mockery(Build::class, [ 'getBuilders' => [ $builder1, $builder2, $builder3, ], ]); $build->shouldReceive('run')->passthru(); $build->run(); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/CleanupTest.php ================================================ mockery(SymfonyStyle::class); $console->expects()->section('Cleaning up...'); $console->expects()->text( ' - Deleted \'/path/to/app/resources' . DIRECTORY_SEPARATOR . 'templates\'.', ); $console->expects()->text( ' - Deleted \'/path/to/app/src' . DIRECTORY_SEPARATOR . 'LibraryStarterKit\'.', ); $console->expects()->text( ' - Deleted \'/path/to/app/tests' . DIRECTORY_SEPARATOR . 'LibraryStarterKit\'.', ); $console->expects()->text( ' - Deleted \'/path/to/app/.git\'.', ); $console->expects()->text( ' - Deleted \'/path/to/app/.starter-kit-answers\'.', ); $filesystem = $this->mockery(Filesystem::class); $filesystem->expects()->remove('/path/to/app/resources' . DIRECTORY_SEPARATOR . 'templates'); $filesystem->expects()->remove('/path/to/app/src' . DIRECTORY_SEPARATOR . 'LibraryStarterKit'); $filesystem->expects()->remove('/path/to/app/tests' . DIRECTORY_SEPARATOR . 'LibraryStarterKit'); $filesystem->expects()->remove('/path/to/app/.git'); $filesystem->expects()->remove('/path/to/app/.starter-kit-answers'); $environment = $this->mockery(Setup::class, [ 'getFilesystem' => $filesystem, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getSetup' => $environment, 'getConsole' => $console, ]); $builder = new Cleanup($build); $builder->build(); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/FixStyleTest.php ================================================ mockery(SymfonyStyle::class); $console->expects()->section('Fixing style issues...'); $process = $this->mockery(Process::class); $process->expects()->mustRun(new IsCallable()); $environment = $this->mockery(Setup::class); $environment ->expects() ->getProcess(['composer', 'dev:lint:fix']) ->andReturn($process); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new FixStyle($build); $builder->build(); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/InstallDependenciesTest.php ================================================ mockery(SymfonyStyle::class); $console->expects()->section('Installing dependencies'); $filesystem = $this->mockery(Filesystem::class); $filesystem->expects()->remove([ '/path/to/app' . DIRECTORY_SEPARATOR . 'composer.lock', '/path/to/app' . DIRECTORY_SEPARATOR . 'vendor', ]); $process = $this->mockery(Process::class); $process->expects()->mustRun(new IsCallable()); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFileSystem' => $filesystem, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app' . DIRECTORY_SEPARATOR . $path); $environment ->expects() ->getProcess([ 'composer', 'update', '--no-interaction', '--ansi', '--no-progress', ]) ->andReturn($process); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getSetup' => $environment, 'getConsole' => $console, ]); $builder = new InstallDependencies($build); $builder->build(); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/RenameTemplatesTest.php ================================================ mockery(SymfonyStyle::class); $console->expects()->section('Renaming template files'); $console->expects()->text(" - Renaming '{$path}' to '{$expectedPath}'."); $filesystem = $this->mockery(Filesystem::class); $filesystem->expects()->rename($path, $expectedPath); $file1 = $this->mockery(SplFileInfo::class, [ 'getRealPath' => $path, ]); $finder = $this->mockery(Finder::class, [ 'getIterator' => (new ArrayObject([$file1]))->getIterator(), ]); $finder->expects()->ignoreDotFiles(false)->andReturnSelf(); $finder->expects()->exclude(['build', 'vendor'])->andReturnSelf(); $finder->expects()->in('/path/to/app')->andReturnSelf(); $finder->expects()->name('*.template')->andReturnSelf(); $finder->expects()->name('.*.template'); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFileSystem' => $filesystem, 'getFinder' => $finder, ]); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getSetup' => $environment, 'getConsole' => $console, ]); $renameTemplates = new RenameTemplates($build); $renameTemplates->build(); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/RunTestsTest.php ================================================ mockery(SymfonyStyle::class); $console->expects()->section('Running project tests...'); $process = $this->mockery(Process::class); $process->expects()->mustRun(new IsCallable()); $environment = $this->mockery(Setup::class); $environment ->expects() ->getProcess(['composer', 'dev:test:all']) ->andReturn($process); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new RunTests($build); $builder->build(); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/SetupRepositoryTest.php ================================================ */ public static function buildProvider(): array { return [ [ 'configUserName' => 'Jane Doe', 'configUserEmail' => 'jdoe@example.com', 'configDefaultBranch' => '', 'authorName' => 'Jane Doe', 'authorEmail' => 'jdoe@example.com', 'expectedName' => 'Jane Doe', 'expectedEmail' => 'jdoe@example.com', 'expectedDefaultBranch' => 'main', ], [ 'configUserName' => '', 'configUserEmail' => '', 'configDefaultBranch' => 'my-custom-branch-name', 'authorName' => 'Jane Doe', 'authorEmail' => 'jdoe@example.com', 'expectedName' => 'Jane Doe', 'expectedEmail' => 'jdoe@example.com', 'expectedDefaultBranch' => 'my-custom-branch-name', ], [ 'configUserName' => 'Frodo Baggins', 'configUserEmail' => '', 'configDefaultBranch' => '', 'authorName' => 'Jane Doe', 'authorEmail' => 'jdoe@example.com', 'expectedName' => 'Jane Doe', 'expectedEmail' => 'jdoe@example.com', 'expectedDefaultBranch' => 'main', ], [ 'configUserName' => '', 'configUserEmail' => 'frodo@example.com', 'configDefaultBranch' => '', 'authorName' => 'Jane Doe', 'authorEmail' => 'jdoe@example.com', 'expectedName' => 'Jane Doe', 'expectedEmail' => 'jdoe@example.com', 'expectedDefaultBranch' => 'main', ], [ 'configUserName' => 'Samwise Gamgee', 'configUserEmail' => 'samwise@example.com', 'configDefaultBranch' => 'default', 'authorName' => 'Jane Doe', 'authorEmail' => 'jdoe@example.com', 'expectedName' => 'Jane Doe', 'expectedEmail' => 'jdoe@example.com', 'expectedDefaultBranch' => 'default', ], ]; } #[DataProvider('buildProvider')] public function testBuild( string $configUserName, string $configUserEmail, string $configDefaultBranch, string $authorName, string $authorEmail, string $expectedName, string $expectedEmail, string $expectedDefaultBranch, ): void { $this->answers->authorName = $authorName; $this->answers->authorEmail = $authorEmail; $console = $this->mockery(SymfonyStyle::class); $console->expects()->section('Setting up Git repository'); $console->expects()->write('a string to write to the console'); $processConfigUserName = $this->mockery(Process::class); $processConfigUserName->expects()->run()->andReturn($configUserName ? 0 : 1); $processConfigUserName->expects()->getOutput()->andReturn($configUserName); $processConfigUserEmail = $this->mockery(Process::class); $processConfigUserEmail->expects()->run()->andReturn($configUserEmail ? 0 : 1); $processConfigUserEmail->expects()->getOutput()->andReturn($configUserEmail); $processDefaultBranch = $this->mockery(Process::class); $processDefaultBranch->expects()->run()->andReturn($configDefaultBranch ? 0 : 1); $processDefaultBranch->expects()->getOutput()->andReturn($configDefaultBranch); $processMustRun = $this->mockery(Process::class); $processMustRun->expects()->mustRun(); $processMustRunWithCallable = $this->mockery(Process::class); $processMustRunWithCallable->shouldReceive('mustRun')->with(new IsCallable())->atLeast()->times(4); $environment = $this->mockery(Setup::class); $environment ->expects() ->path('vendor') ->andReturn('/path/to/vendor'); $environment ->expects() ->getProcess(['git', 'config', 'user.name']) ->andReturn($processConfigUserName); $environment ->expects() ->getProcess(['git', 'config', 'user.email']) ->andReturn($processConfigUserEmail); $environment ->expects() ->getProcess(['git', 'config', 'init.defaultBranch']) ->andReturn($processDefaultBranch); $processMustRunWritesOutput = $this->mockery(Process::class); $processMustRunWritesOutput ->shouldReceive('mustRun') ->once() ->withArgs(function (Closure $consoleWriter): bool { $consoleWriter('out', 'a string to write to the console'); return true; }); $environment ->expects() ->getProcess(['git', 'init']) ->andReturn($processMustRunWritesOutput); if ($configUserName !== $authorName) { $environment ->expects() ->getProcess(['git', 'config', 'user.name', $expectedName]) ->andReturn($processMustRunWithCallable); } if ($configUserEmail !== $authorEmail) { $environment ->expects() ->getProcess(['git', 'config', 'user.email', $expectedEmail]) ->andReturn($processMustRunWithCallable); } $environment ->expects() ->getProcess(['git', 'branch', '-M', $expectedDefaultBranch]) ->andReturn($processMustRunWithCallable); $environment ->expects() ->getProcess(['/path/to/vendor/bin/captainhook', 'install', '--force', '--skip-existing']) ->andReturn($processMustRunWithCallable); $environment ->expects() ->getProcess(['composer', 'dev:build:clean']) ->andReturn($processMustRun); $environment ->expects() ->getProcess(['git', 'add', '--all']) ->andReturn($processMustRunWithCallable); $environment ->expects() ->getProcess([ 'git', 'commit', '-n', '-m', 'chore: initialize project using ramsey/php-library-starter-kit', '--author', sprintf('%s <%s>', $expectedName, $expectedEmail), ]) ->andReturn($processMustRunWithCallable); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new SetupRepository($build); $builder->build(); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/UpdateChangelogTest.php ================================================ mockery(SymfonyStyle::class); $console->expects()->section('Updating CHANGELOG.md'); $filesystem = $this->mockery(Filesystem::class); $filesystem ->shouldReceive('dumpFile') ->once() ->withArgs(function (string $path, string $contents) { $this->assertSame('/path/to/app/CHANGELOG.md', $path); $this->assertSame('changelogContents', $contents); return true; }); $twig = $this->mockery(TwigEnvironment::class); $twig ->expects() ->render('CHANGELOG.md.twig', $this->answers->getArrayCopy()) ->andReturn('changelogContents'); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFilesystem' => $filesystem, 'getTwigEnvironment' => $twig, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateChangelog($build); $builder->build(); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/UpdateCodeOfConductTest.php ================================================ mockery(SymfonyStyle::class); $console->expects()->section('Updating CODE_OF_CONDUCT.md'); $filesystem = $this->mockery(Filesystem::class); $filesystem ->shouldReceive('dumpFile') ->once() ->withArgs(function (string $path, string $contents) { $this->assertSame( '/path/to/app/CODE_OF_CONDUCT.md', $path, ); $this->assertSame('codeOfConductContents', $contents); return true; }); $this->answers->codeOfConduct = 'Contributor-1.4'; $twig = $this->mockery(TwigEnvironment::class); $twig ->expects() ->render( 'code-of-conduct' . DIRECTORY_SEPARATOR . 'Contributor-1.4.md.twig', $this->answers->getArrayCopy(), ) ->andReturn('codeOfConductContents'); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFilesystem' => $filesystem, 'getTwigEnvironment' => $twig, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateCodeOfConduct($build); $builder->build(); } public function testBuildRemovesCodeOfConductFile(): void { $console = $this->mockery(SymfonyStyle::class); $console->expects()->section('Removing CODE_OF_CONDUCT.md'); $filesystem = $this->mockery(Filesystem::class); $filesystem->shouldReceive('dumpFile')->never(); $filesystem->expects()->remove('/path/to/app/CODE_OF_CONDUCT.md'); $twig = $this->mockery(TwigEnvironment::class); $twig->shouldReceive('render')->never(); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFilesystem' => $filesystem, 'getTwigEnvironment' => $twig, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateCodeOfConduct($build); $builder->build(); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/UpdateComposerJsonTest.php ================================================ mockery(SymfonyStyle::class); $console->expects()->section('Updating composer.json'); $filesystem = $this->mockery(Filesystem::class); $filesystem ->shouldReceive('dumpFile') ->once() ->withArgs(function (string $path, string $contents) { $this->assertSame('/path/to/app/composer.json', $path); $this->assertMatchesSnapshot($contents, new WindowsSafeTextDriver()); return true; }); $finder = $this->mockery(Finder::class, [ 'getIterator' => (new ArrayObject( [ $this->mockery(SplFileInfo::class, ['getContents' => $this->composerContentsOriginal()]), $this->mockery(SplFileInfo::class, ['getContents' => '']), ], ))->getIterator(), ]); $finder->expects()->in('/path/to/app')->andReturnSelf(); $finder->expects()->files()->andReturnSelf(); $finder->expects()->depth('== 0')->andReturnSelf(); $finder->expects()->name('composer.json'); $this->answers->packageName = 'a-vendor/package-name'; $this->answers->packageDescription = 'This is a test package.'; $this->answers->packageKeywords = ['test', 'package']; $this->answers->authorName = 'Jane Doe'; $this->answers->authorEmail = 'jdoe@example.com'; $this->answers->authorUrl = 'https://example.com/jane'; $this->answers->license = 'Apache-2.0'; $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFilesystem' => $filesystem, 'getFinder' => $finder, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateComposerJson($build); $builder->build(); } public function testBuildThrowsExceptionWhenComposerContentsContainInvalidJson(): void { $console = $this->mockery(SymfonyStyle::class); $console->expects()->section('Updating composer.json'); $finder = $this->mockery(Finder::class, [ 'getIterator' => (new ArrayObject( [ $this->mockery(SplFileInfo::class, ['getContents' => 'null']), ], ))->getIterator(), ]); $finder->expects()->in('/path/to/app')->andReturnSelf(); $finder->expects()->files()->andReturnSelf(); $finder->expects()->depth('== 0')->andReturnSelf(); $finder->expects()->name('composer.json'); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFinder' => $finder, ]); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getSetup' => $environment, 'getConsole' => $console, ]); $builder = new UpdateComposerJson($build); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Unable to decode contents of composer.json'); $builder->build(); } public function testBuildThrowsExceptionWhenComposerJsonCannotBeFound(): void { $console = $this->mockery(SymfonyStyle::class); $console->expects()->section('Updating composer.json'); $finder = $this->mockery(Finder::class, [ 'getIterator' => (new ArrayObject())->getIterator(), ]); $finder->expects()->in('/path/to/app')->andReturnSelf(); $finder->expects()->files()->andReturnSelf(); $finder->expects()->depth('== 0')->andReturnSelf(); $finder->expects()->name('composer.json'); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFinder' => $finder, ]); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateComposerJson($build); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Unable to get contents of composer.json'); $builder->build(); } public function testBuildWithMinimalComposerJson(): void { $console = $this->mockery(SymfonyStyle::class); $console->expects()->section('Updating composer.json'); $filesystem = $this->mockery(Filesystem::class); $filesystem ->shouldReceive('dumpFile') ->once() ->withArgs(function (string $path, string $contents) { $this->assertSame('/path/to/app/composer.json', $path); $this->assertMatchesSnapshot($contents, new WindowsSafeTextDriver()); return true; }); $finder = $this->mockery(Finder::class, [ 'getIterator' => (new ArrayObject([ $this->mockery(SplFileInfo::class, [ 'getContents' => $this->composerContentsOriginalMinimal(), ]), ]))->getIterator(), ]); $finder->expects()->in('/path/to/app')->andReturnSelf(); $finder->expects()->files()->andReturnSelf(); $finder->expects()->depth('== 0')->andReturnSelf(); $finder->expects()->name('composer.json'); $this->answers->packageName = 'a-vendor/package-name'; $this->answers->packageDescription = 'This is a test package.'; $this->answers->authorName = 'Jane Doe'; $this->answers->license = 'MPL-2.0'; $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFilesystem' => $filesystem, 'getFinder' => $finder, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateComposerJson($build); $builder->build(); } private function composerContentsOriginal(): string { return (string) file_get_contents(__DIR__ . '/fixtures/composer-full.json'); } private function composerContentsOriginalMinimal(): string { return (string) file_get_contents(__DIR__ . '/fixtures/composer-minimal.json'); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/UpdateContributingTest.php ================================================ mockery(SymfonyStyle::class); $console->expects()->section('Updating CONTRIBUTING.md'); $filesystem = $this->mockery(Filesystem::class); $filesystem ->shouldReceive('dumpFile') ->once() ->withArgs(function (string $path, string $contents) { $this->assertSame('/path/to/app/CONTRIBUTING.md', $path); $this->assertSame('contributingContents', $contents); return true; }); $twig = $this->mockery(TwigEnvironment::class); $twig ->expects() ->render('CONTRIBUTING.md.twig', $this->answers->getArrayCopy()) ->andReturn('contributingContents'); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFilesystem' => $filesystem, 'getTwigEnvironment' => $twig, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); /** @var Build & MockInterface $task */ $task = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateContributing($task); $builder->build(); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/UpdateFundingTest.php ================================================ mockery(SymfonyStyle::class); $console->expects()->section('Updating .github/FUNDING.yml'); $filesystem = $this->mockery(Filesystem::class); $filesystem ->shouldReceive('dumpFile') ->once() ->withArgs(function (string $path, string $contents) { $this->assertSame('/path/to/app/.github/FUNDING.yml', $path); $this->assertSame('fundingContents', $contents); return true; }); $twig = $this->mockery(TwigEnvironment::class); $twig ->expects() ->render('FUNDING.yml.twig', $this->answers->getArrayCopy()) ->andReturn('fundingContents'); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFilesystem' => $filesystem, 'getTwigEnvironment' => $twig, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); /** @var Build & MockInterface $task */ $task = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateFunding($task); $builder->build(); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/UpdateLicenseTest.php ================================================ answers->license = $license; $console = $this->mockery(SymfonyStyle::class); $console->expects()->section('Updating license and copyright information'); $filesystem = $this->mockery(Filesystem::class); $filesystem->expects()->remove('LICENSE'); $filesystem->expects()->dumpFile('/path/to/app/' . $filename, $contents); $twigEnvironment = $this->mockery(TwigEnvironment::class); $twigEnvironment ->expects('render') ->with( 'license' . DIRECTORY_SEPARATOR . $license . '.twig', $this->answers->getArrayCopy(), ) ->andReturns($contents); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFilesystem' => $filesystem, 'getTwigEnvironment' => $twigEnvironment, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); /** @var Build & MockInterface $task */ $task = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $additionalChecks($twigEnvironment, $filesystem, $this->answers); $builder = new UpdateLicense($task); $builder->build(); } /** * @return list */ public static function provideLicensesForTesting(): array { return [ [ 'license' => 'AGPL-3.0-or-later', 'filename' => 'COPYING', 'contents' => 'AGPL-3.0-or-later license contents', 'additionalChecks' => function ( TwigEnvironment & MockInterface $twig, Filesystem & MockInterface $filesystem, Answers $answers, ): void { $twig ->expects('render') ->with( 'license' . DIRECTORY_SEPARATOR . 'AGPL-3.0-or-later-NOTICE.twig', $answers->getArrayCopy(), ) ->andReturns('AGPL-3.0-or-later notice contents'); $filesystem->expects('dumpFile')->with( '/path/to/app/NOTICE', 'AGPL-3.0-or-later notice contents', ); }, ], [ 'license' => 'BSD-2', 'filename' => 'LICENSE', 'contents' => 'BSD-2 license contents', 'additionalChecks' => fn () => null, ], [ 'license' => 'BSD-3', 'filename' => 'LICENSE', 'contents' => 'BSD-3 license contents', 'additionalChecks' => fn () => null, ], [ 'license' => 'GPL-3.0-or-later', 'filename' => 'COPYING', 'contents' => 'GPL-3.0-or-later license contents', 'additionalChecks' => function ( TwigEnvironment & MockInterface $twig, Filesystem & MockInterface $filesystem, Answers $answers, ): void { $twig ->expects('render') ->with( 'license' . DIRECTORY_SEPARATOR . 'GPL-3.0-or-later-NOTICE.twig', $answers->getArrayCopy(), ) ->andReturns('GPL-3.0-or-later notice contents'); $filesystem->expects('dumpFile')->with( '/path/to/app/NOTICE', 'GPL-3.0-or-later notice contents', ); }, ], [ 'license' => 'LGPL-3.0-or-later', 'filename' => 'COPYING.LESSER', 'contents' => 'LGPL-3.0-or-later license contents', 'additionalChecks' => function ( TwigEnvironment & MockInterface $twig, Filesystem & MockInterface $filesystem, Answers $answers, ): void { $twig ->expects('render') ->with( 'license' . DIRECTORY_SEPARATOR . 'LGPL-3.0-or-later-NOTICE.twig', $answers->getArrayCopy(), ) ->andReturns('LGPL-3.0-or-later notice contents'); $filesystem->expects('dumpFile')->with( '/path/to/app/NOTICE', 'LGPL-3.0-or-later notice contents', ); $twig ->expects('render') ->with( 'license' . DIRECTORY_SEPARATOR . 'GPL-3.0-or-later.twig', $answers->getArrayCopy(), ) ->andReturns('GPL-3.0-or-later license contents'); $filesystem->expects('dumpFile')->with( '/path/to/app/COPYING', 'GPL-3.0-or-later license contents', ); }, ], [ 'license' => 'MIT', 'filename' => 'LICENSE', 'contents' => 'MIT license contents', 'additionalChecks' => fn () => null, ], [ 'license' => 'MIT-0', 'filename' => 'LICENSE', 'contents' => 'MIT-0 license contents', 'additionalChecks' => fn () => null, ], [ 'license' => 'MPL-2.0', 'filename' => 'LICENSE', 'contents' => 'MPL-2.0 license contents', 'additionalChecks' => function ( TwigEnvironment & MockInterface $twig, Filesystem & MockInterface $filesystem, Answers $answers, ): void { $twig ->expects('render') ->with( 'license' . DIRECTORY_SEPARATOR . 'MPL-2.0-NOTICE.twig', $answers->getArrayCopy(), ) ->andReturns('MPL-2.0 notice contents'); $filesystem->expects('dumpFile')->with( '/path/to/app/NOTICE', 'MPL-2.0 notice contents', ); }, ], [ 'license' => 'Proprietary', 'filename' => 'COPYRIGHT', 'contents' => 'proprietary license contents', 'additionalChecks' => fn () => null, ], [ 'license' => 'Unlicense', 'filename' => 'UNLICENSE', 'contents' => 'unlicense contents', 'additionalChecks' => fn () => null, ], ]; } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/UpdateNamespaceTest.php ================================================ mockery(SymfonyStyle::class); $console->expects()->section('Updating namespace'); $this->answers->packageName = $packageName; $this->answers->packageNamespace = $namespace; $file1 = $this->mockery(SplFileInfo::class, [ 'getRealPath' => '/path/to/app/src/Foo.php', 'getContents' => $this->getFileContents(), ]); $file2 = $this->mockery(SplFileInfo::class, [ 'getRealPath' => '/path/to/app/src/Bar.php', 'getContents' => $this->getFileContents(), ]); $file3 = $this->mockery(SplFileInfo::class, [ 'getRealPath' => '/path/to/app/composer.json', 'getContents' => $this->getFileContents(), ]); $finder1 = $this->mockery(Finder::class, [ 'getIterator' => (new ArrayObject([$file1, $file2]))->getIterator(), ]); $finder1->expects()->exclude(['LibraryStarterKit'])->andReturnSelf(); $finder1->expects()->in( [ '/path/to/app/bin', '/path/to/app/src', '/path/to/app/tests', ], )->andReturnSelf(); $finder1->expects()->files()->andReturnSelf(); $finder1->expects()->name('*.php')->andReturnSelf(); $finder2 = $this->mockery(Finder::class, [ 'getIterator' => (new ArrayObject([$file3]))->getIterator(), ]); $finder2->expects()->in(['/path/to/app'])->andReturnSelf(); $finder2->expects()->files()->andReturnSelf(); $finder2->expects()->depth('== 0')->andReturnSelf(); $finder2->expects()->name('composer.json')->andReturnSelf(); $filesystem = $this->mockery(Filesystem::class); $filesystem ->shouldReceive('dumpFile') ->times(3) ->withArgs(function (string $path, string $contents) { $this->assertMatchesSnapshot($path, new WindowsSafeTextDriver()); $this->assertMatchesSnapshot($contents, new WindowsSafeTextDriver()); return true; }); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFilesystem' => $filesystem, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); $environment ->shouldReceive('getFinder') ->twice() ->andReturn($finder1, $finder2); /** @var Build & MockInterface $task */ $task = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateNamespace($task); $builder->build(); } /** * @return list */ public static function provideNamespaceTestValues(): array { return [ [ 'packageName' => 'acme/foo-bar', 'namespace' => 'Acme\\Foo\\Bar', 'testNamespace' => 'Acme\\Test\\Foo\\Bar', ], [ 'packageName' => 'acme/foo', 'namespace' => 'Acme', 'testNamespace' => 'Acme\\Test', ], [ 'packageName' => 'another/package', 'namespace' => 'Another\\Package\\With\\Long\\Namespace', 'testNamespace' => 'Another\\Test\\Package\\With\\Long\\Namespace', ], ]; } private function getFileContents(): string { return (string) file_get_contents(__DIR__ . '/fixtures/update-namespace-test.php'); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/UpdateReadmeTest.php ================================================ mockery(SymfonyStyle::class); $console->expects()->section('Updating README.md'); $filesystem = $this->mockery(Filesystem::class); $filesystem ->shouldReceive('dumpFile') ->once() ->withArgs(function (string $path, string $contents) { $this->assertSame('/path/to/app/README.md', $path); $this->assertMatchesSnapshot($contents, new WindowsSafeTextDriver()); return true; }); $finder = $this->mockery(Finder::class, [ 'getIterator' => (new ArrayObject( [ $this->mockery(SplFileInfo::class, ['getContents' => $this->readmeContentsOriginal()]), $this->mockery(SplFileInfo::class, ['getContents' => '']), ], ))->getIterator(), ]); $finder->expects()->in('/path/to/app')->andReturnSelf(); $finder->expects()->files()->andReturnSelf(); $finder->expects()->depth('== 0')->andReturnSelf(); $finder->expects()->name('README.md'); $this->answers->codeOfConduct = 'Contributor-1.4'; $this->answers->packageName = 'a-vendor/package-name'; $this->answers->packageDescription = 'This is a test package.'; $twig = $this->mockery(TwigEnvironment::class); $twig ->expects() ->render('readme/badges.md.twig', $this->answers->getArrayCopy()) ->andReturn('badges info'); $twig ->expects() ->render('readme/description.md.twig', $this->answers->getArrayCopy()) ->andReturn('description info'); $twig ->expects() ->render('readme/code-of-conduct.md.twig', $this->answers->getArrayCopy()) ->andReturn('code of conduct info'); $twig ->expects() ->render('readme/usage.md.twig', $this->answers->getArrayCopy()) ->andReturn('usage info'); $twig ->expects() ->render('readme/copyright.md.twig', $this->answers->getArrayCopy()) ->andReturn('copyright info'); $twig ->expects() ->render('readme/security.md.twig', $this->answers->getArrayCopy()) ->andReturn('security info'); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFilesystem' => $filesystem, 'getFinder' => $finder, 'getTwigEnvironment' => $twig, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); /** @var Build & MockInterface $task */ $task = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateReadme($task); $builder->build(); } public function testBuildWhenCodeOfConductIsNullAndSecurityPolicyIsFalse(): void { $console = $this->mockery(SymfonyStyle::class); $console->expects()->section('Updating README.md'); $filesystem = $this->mockery(Filesystem::class); $filesystem ->shouldReceive('dumpFile') ->once() ->withArgs(function (string $path, string $contents) { $this->assertSame('/path/to/app/README.md', $path); $this->assertMatchesSnapshot($contents, new WindowsSafeTextDriver()); return true; }); $finder = $this->mockery(Finder::class, [ 'getIterator' => (new ArrayObject( [ $this->mockery(SplFileInfo::class, ['getContents' => $this->readmeContentsOriginal()]), $this->mockery(SplFileInfo::class, ['getContents' => '']), ], ))->getIterator(), ]); $finder->expects()->in('/path/to/app')->andReturnSelf(); $finder->expects()->files()->andReturnSelf(); $finder->expects()->depth('== 0')->andReturnSelf(); $finder->expects()->name('README.md'); $this->answers->codeOfConduct = CodeOfConduct::DEFAULT; $this->answers->securityPolicy = false; $this->answers->packageName = 'a-vendor/package-name'; $this->answers->packageDescription = 'This is a test package.'; $twig = $this->mockery(TwigEnvironment::class); $twig ->expects() ->render('readme/badges.md.twig', $this->answers->getArrayCopy()) ->andReturn('badges info'); $twig ->expects() ->render('readme/description.md.twig', $this->answers->getArrayCopy()) ->andReturn('description info'); $twig ->expects() ->render('readme/code-of-conduct.md.twig', $this->answers->getArrayCopy()) ->never(); $twig ->expects() ->render('readme/usage.md.twig', $this->answers->getArrayCopy()) ->andReturn('usage info'); $twig ->expects() ->render('readme/copyright.md.twig', $this->answers->getArrayCopy()) ->andReturn('copyright info'); $twig ->expects() ->render('readme/security.md.twig', $this->answers->getArrayCopy()) ->never(); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFilesystem' => $filesystem, 'getFinder' => $finder, 'getTwigEnvironment' => $twig, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); /** @var Build & MockInterface $task */ $task = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateReadme($task); $builder->build(); } public function testBuildThrowsExceptionWhenReadmeCannotBeFound(): void { $console = $this->mockery(SymfonyStyle::class); $console->expects()->section('Updating README.md'); $finder = $this->mockery(Finder::class, [ 'getIterator' => (new ArrayObject([]))->getIterator(), ]); $finder->expects()->in('/path/to/app')->andReturnSelf(); $finder->expects()->files()->andReturnSelf(); $finder->expects()->depth('== 0')->andReturnSelf(); $finder->expects()->name('README.md'); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFinder' => $finder, ]); /** @var Build & MockInterface $task */ $task = $this->mockery(Build::class, [ 'getAppPath' => '/path/to/app', 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateReadme($task); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Unable to get contents of README.md'); $builder->build(); } private function readmeContentsOriginal(): string { return (string) file_get_contents(__DIR__ . '/fixtures/readme-full.md'); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/UpdateSecurityPolicyTest.php ================================================ mockery(SymfonyStyle::class); $console->expects()->section('Updating SECURITY.md'); $filesystem = $this->mockery(Filesystem::class); $filesystem ->shouldReceive('dumpFile') ->once() ->withArgs(function (string $path, string $contents) { $this->assertSame( '/path/to/app/SECURITY.md', $path, ); $this->assertSame('securityPolicyContents', $contents); return true; }); $twig = $this->mockery(TwigEnvironment::class); $twig ->expects() ->render( 'security-policy' . DIRECTORY_SEPARATOR . 'HackerOne.md.twig', $this->answers->getArrayCopy(), ) ->andReturn('securityPolicyContents'); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFilesystem' => $filesystem, 'getTwigEnvironment' => $twig, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateSecurityPolicy($build); $builder->build(); } public function testBuildRemovesSecurityPolicyFile(): void { $this->answers->securityPolicy = false; $console = $this->mockery(SymfonyStyle::class); $console->expects()->section('Removing SECURITY.md'); $filesystem = $this->mockery(Filesystem::class); $filesystem->shouldReceive('dumpFile')->never(); $filesystem->expects()->remove('/path/to/app/SECURITY.md'); $twig = $this->mockery(TwigEnvironment::class); $twig->shouldReceive('render')->never(); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFilesystem' => $filesystem, 'getTwigEnvironment' => $twig, ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); /** @var Build & MockInterface $build */ $build = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateSecurityPolicy($build); $builder->build(); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/UpdateSourceFileHeadersTest.php ================================================ answers->packageName = 'fellowship/one-ring'; $this->answers->copyrightHolder = 'Samwise Gamgee'; $this->answers->license = $license; $this->answers->copyrightEmail = $copyrightEmail; $this->answers->copyrightUrl = $copyrightUrl; $console = $this->mockery(SymfonyStyle::class); $console->expects()->section('Updating source file headers'); $realSetup = new Setup( $this->mockery(Project::class, [ 'getPath' => __DIR__ . '/../../../../.', ]), $this->mockery(Event::class), $this->mockery(Filesystem::class), $this->mockery(Finder::class), OutputInterface::VERBOSITY_NORMAL, ); $file1 = $this->mockery(SplFileInfo::class, [ 'getRealPath' => '/path/to/app/src/SomeClass.php', 'getContents' => $this->getFile1OriginalContents(), ]); $file2 = $this->mockery(SplFileInfo::class, [ 'getRealPath' => '/path/to/app/src/foo/AnotherClass.php', 'getContents' => $this->getFile2OriginalContents(), ]); $finder = $this->mockery(Finder::class, [ 'getIterator' => (new ArrayObject([$file1, $file2]))->getIterator(), ]); $finder->expects()->exclude(['LibraryStarterKit'])->andReturnSelf(); $finder->expects()->in(['/path/to/app/src'])->andReturnSelf(); $finder->expects()->files()->andReturnSelf(); $finder->expects()->name('*.php')->andReturnSelf(); $filesystem = $this->mockery(Filesystem::class); $filesystem ->shouldReceive('dumpFile') ->times(2) ->withArgs(function (string $path, string $contents) { $this->assertMatchesSnapshot($contents, new WindowsSafeTextDriver()); return true; }); $environment = $this->mockery(Setup::class, [ 'getAppPath' => '/path/to/app', 'getFilesystem' => $filesystem, 'getFinder' => $finder, 'getTwigEnvironment' => $realSetup->getTwigEnvironment(), ]); $environment ->shouldReceive('path') ->andReturnUsing(fn (string $path): string => '/path/to/app/' . $path); /** @var Build & MockInterface $task */ $task = $this->mockery(Build::class, [ 'getAnswers' => $this->answers, 'getConsole' => $console, 'getSetup' => $environment, ]); $builder = new UpdateSourceFileHeaders($task); $builder->build(); } /** * @return list */ public static function licenseProvider(): array { return [ ['license' => 'AGPL-3.0-or-later'], ['license' => 'Apache-2.0'], [ 'license' => 'BSD-2-Clause', 'copyrightEmail' => 'samwise@example.com', ], ['license' => 'BSD-3-Clause'], ['license' => 'GPL-3.0-or-later'], ['license' => 'Hippocratic-2.1'], ['license' => 'LGPL-3.0-or-later'], [ 'license' => 'MIT', 'copyrightEmail' => null, 'copyrightUrl' => 'https://example.com/fellowship', ], ['license' => 'MIT-0'], ['license' => 'MPL-2.0'], [ 'license' => 'Proprietary', 'copyrightEmail' => 'fellowship@example.com', 'copyrightUrl' => 'https://example.com/fellowship', ], ['license' => 'Unlicense'], ]; } private function getFile1OriginalContents(): string { return (string) file_get_contents(__DIR__ . '/fixtures/update-source-file-headers-test-1.php'); } private function getFile2OriginalContents(): string { return (string) file_get_contents(__DIR__ . '/fixtures/update-source-file-headers-test-2.php'); } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateComposerJsonTest__testBuildWithMinimalComposerJson__1.txt ================================================ { "name": "a-vendor/package-name", "type": "library", "description": "This is a test package.", "keywords": [], "license": "MPL-2.0", "authors": [ { "name": "Jane Doe" } ] } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateComposerJsonTest__testBuild__1.txt ================================================ { "name": "a-vendor/package-name", "type": "library", "description": "This is a test package.", "keywords": [ "test", "package" ], "license": "Apache-2.0", "authors": [ { "name": "Jane Doe", "email": "jdoe@example.com", "homepage": "https://example.com/jane" } ], "require": { "php": "^7.4 || ^8" }, "require-dev": { "ramsey/devtools": "^1.5" }, "config": { "sort-packages": true }, "extra": { "ramsey/conventional-commits": { "configFile": "conventional-commits.json" }, "ramsey/devtools": { "command-prefix": "dev" } }, "autoload": { "psr-4": { "Vendor\\SubNamespace\\": "src/" } }, "autoload-dev": { "psr-4": { "Vendor\\Test\\SubNamespace\\": "tests/" } }, "minimum-stability": "dev", "prefer-stable": true } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateNamespaceTest__testBuild_with_data_set__0__1.txt ================================================ /path/to/app/src/Foo.php ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateNamespaceTest__testBuild_with_data_set__0__2.txt ================================================ . * * @copyright Copyright (c) Samwise Gamgee * @license https://opensource.org/license/agpl-v3/ GNU Affero General Public License version 3 or later */ declare(strict_types=1); namespace Foo; /** * Class description */ class Bar { } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateSourceFileHeadersTest__testBuild_with_data_set__0__2.txt ================================================ . * * @copyright Copyright (c) Samwise Gamgee * @license https://opensource.org/license/agpl-v3/ GNU Affero General Public License version 3 or later */ declare(strict_types=1); namespace Foo; /** * Class description */ class Baz { /** * Method description */ public function __construct() { } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateSourceFileHeadersTest__testBuild_with_data_set__10__1.txt ================================================ . All rights reserved. */ declare(strict_types=1); namespace Foo; /** * Class description */ class Bar { } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateSourceFileHeadersTest__testBuild_with_data_set__10__2.txt ================================================ . All rights reserved. */ declare(strict_types=1); namespace Foo; /** * Class description */ class Baz { /** * Method description */ public function __construct() { } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateSourceFileHeadersTest__testBuild_with_data_set__11__1.txt ================================================ * @license https://opensource.org/license/bsd-2-clause/ BSD 2-Clause "Simplified" License */ declare(strict_types=1); namespace Foo; /** * Class description */ class Bar { } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateSourceFileHeadersTest__testBuild_with_data_set__2__2.txt ================================================ * @license https://opensource.org/license/bsd-2-clause/ BSD 2-Clause "Simplified" License */ declare(strict_types=1); namespace Foo; /** * Class description */ class Baz { /** * Method description */ public function __construct() { } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateSourceFileHeadersTest__testBuild_with_data_set__3__1.txt ================================================ . * * @copyright Copyright (c) Samwise Gamgee * @license https://opensource.org/license/gpl-3-0/ GNU General Public License version 3 or later */ declare(strict_types=1); namespace Foo; /** * Class description */ class Bar { } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateSourceFileHeadersTest__testBuild_with_data_set__4__2.txt ================================================ . * * @copyright Copyright (c) Samwise Gamgee * @license https://opensource.org/license/gpl-3-0/ GNU General Public License version 3 or later */ declare(strict_types=1); namespace Foo; /** * Class description */ class Baz { /** * Method description */ public function __construct() { } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateSourceFileHeadersTest__testBuild_with_data_set__5__1.txt ================================================ . * * @copyright Copyright (c) Samwise Gamgee * @license https://opensource.org/license/lgpl-3-0/ GNU Lesser General Public License version 3 or later */ declare(strict_types=1); namespace Foo; /** * Class description */ class Bar { } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateSourceFileHeadersTest__testBuild_with_data_set__6__2.txt ================================================ . * * @copyright Copyright (c) Samwise Gamgee * @license https://opensource.org/license/lgpl-3-0/ GNU Lesser General Public License version 3 or later */ declare(strict_types=1); namespace Foo; /** * Class description */ class Baz { /** * Method description */ public function __construct() { } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateSourceFileHeadersTest__testBuild_with_data_set__7__1.txt ================================================ * @license https://opensource.org/license/mit/ MIT License */ declare(strict_types=1); namespace Foo; /** * Class description */ class Bar { } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateSourceFileHeadersTest__testBuild_with_data_set__7__2.txt ================================================ * @license https://opensource.org/license/mit/ MIT License */ declare(strict_types=1); namespace Foo; /** * Class description */ class Baz { /** * Method description */ public function __construct() { } } ================================================ FILE: tests/LibraryStarterKit/Task/Builder/__snapshots__/UpdateSourceFileHeadersTest__testBuild_with_data_set__8__1.txt ================================================ ramsey/php-library-starter-kit [![Source Code][badge-source]][source] [badge-source]: http://img.shields.io/badge/source-ramsey/php--library--starter--kit-blue.svg?style=flat-square [source]: https://github.com/ramsey/php-library-starter-kit ramsey/php-library-starter-kit is a package that may be used to generate a basic PHP library project directory structure, complete with many of the starting files (i.e. README, LICENSE, GitHub issue templates, PHPUnit configuration, etc.) that are commonly found in PHP libraries. You may use the project directory that's created as a starting point for creating your own PHP libraries. This project adheres to a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project and its community, you are expected to uphold this code. ## Usage ``` bash composer create-project ramsey/php-library-starter-kit YOUR-PROJECT-NAME ``` ## Contributing Contributions are welcome! Before contributing to this project, familiarize yourself with [CONTRIBUTING.md](CONTRIBUTING.md). ## FAQs ### Wait, what, why? Because. ## Copyright and License The ramsey/php-library-starter-kit library is copyright © [Ben Ramsey](https://benramsey.com) and licensed for use under the MIT License (MIT). Please see [LICENSE](LICENSE) for more information. ================================================ FILE: tests/LibraryStarterKit/Task/Builder/fixtures/update-namespace-test.php ================================================ setup = $this->mockery(Setup::class); $this->console = $this->mockery(SymfonyStyle::class); $build = new Build($this->setup, $this->console, $this->answers); $this->builder = new class ($build) extends Builder { public function build(): void { } }; } public function testGetAnswers(): void { $this->assertSame($this->answers, $this->builder->getAnswers()); } public function testGetEnvironment(): void { $this->assertSame($this->setup, $this->builder->getEnvironment()); } public function testGetConsole(): void { $this->assertSame($this->console, $this->builder->getConsole()); } public function testStreamProcessOutput(): void { $streamProcessOutput = $this->builder->streamProcessOutput(); $this->console->expects()->write('writes a message to output'); $streamProcessOutput('foo', 'writes a message to output'); } } ================================================ FILE: tests/LibraryStarterKit/TestCase.php ================================================ mockery(Filesystem::class); $filesystem->expects()->exists('/path/to/answers.json')->andReturnFalse(); $this->answers = new Answers('/path/to/answers.json', $filesystem); } } ================================================ FILE: tests/LibraryStarterKit/WindowsSafeTextDriver.php ================================================ serialize($actual)); } } ================================================ FILE: tests/LibraryStarterKit/WizardTest.php ================================================ mockery(Setup::class); $setup->shouldReceive('getProject->getName')->andReturn('foo-project'); $setup ->expects() ->path('.starter-kit-answers') ->andReturn('/path/to/.starter-kit-answers'); $nullProcess = $this->mockery(Process::class); $nullProcess->expects()->run()->twice(); $nullProcess->expects()->getOutput()->twice()->andReturn(''); $setup->expects()->getProcess(['git', 'config', 'user.name'])->andReturn($nullProcess); $setup->expects()->getProcess(['git', 'config', 'user.email'])->andReturn($nullProcess); $filesystem = $this->mockery(Filesystem::class); $filesystem->expects()->exists('/path/to/.starter-kit-answers')->andReturnFalse(); $setup->expects()->getFilesystem()->andReturn($filesystem); $wizard = new Wizard($setup); $this->assertSame($setup, $wizard->getSetup()); } public function testGetAnswersFileReturnsPathToLocalAnswersFile(): void { /** @var Setup & MockInterface $setup */ $setup = $this->mockery(Setup::class); $setup->shouldReceive('getProject->getName')->andReturn('foo-project'); $setup ->expects() ->path('.starter-kit-answers') ->twice() ->andReturn('/path/to/.starter-kit-answers'); $nullProcess = $this->mockery(Process::class); $nullProcess->expects()->run()->twice(); $nullProcess->expects()->getOutput()->twice()->andReturn(''); $setup->expects()->getProcess(['git', 'config', 'user.name'])->andReturn($nullProcess); $setup->expects()->getProcess(['git', 'config', 'user.email'])->andReturn($nullProcess); $filesystem = $this->mockery(Filesystem::class); $filesystem->expects()->exists('/path/to/.starter-kit-answers')->andReturnFalse(); $setup->expects()->getFilesystem()->andReturn($filesystem); $wizard = new Wizard($setup); $this->assertSame('/path/to/.starter-kit-answers', $wizard->getAnswersFile()); } public function testGetAnswersFileReturnsPathToEnvironmentAnswersFile(): void { $answersFile = __DIR__ . '/answers-test.json'; putenv('STARTER_KIT_ANSWERS_FILE=' . $answersFile); $filesystem = new Filesystem(); /** @var Setup & MockInterface $setup */ $setup = $this->mockery(Setup::class); $setup->expects()->getFilesystem()->andReturn($filesystem); $wizard = new Wizard($setup); $this->assertSame($answersFile, $wizard->getAnswersFile()); // Remove the environment variable to avoid affecting other tests. putenv('STARTER_KIT_ANSWERS_FILE'); } public function testRunWhenUserChoosesNotToStart(): void { /** @var InputInterface & MockInterface $input */ $input = $this->mockery(InputInterface::class)->shouldIgnoreMissing(); /** @var OutputInterface & MockInterface $output */ $output = $this->mockery(OutputInterface::class); $output->expects()->setVerbosity(OutputInterface::VERBOSITY_NORMAL); /** @var Style & MockInterface $console */ $console = $this->mockery(Style::class); /** @var Setup & MockInterface $setup */ $setup = $this->mockery(Setup::class); $setup->expects()->getAppPath()->andReturn('/path/to/app'); $setup->shouldReceive('getProject->getName')->andReturn('foo-project'); $setup->expects()->getVerbosity()->andReturn(OutputInterface::VERBOSITY_NORMAL); $setup ->expects() ->path('.starter-kit-answers') ->andReturn('/path/to/app/.starter-kit-answers'); $nullProcess = $this->mockery(Process::class); $nullProcess->expects()->run()->twice(); $nullProcess->expects()->getOutput()->twice()->andReturn(''); $setup->expects()->getProcess(['git', 'config', 'user.name'])->andReturn($nullProcess); $setup->expects()->getProcess(['git', 'config', 'user.email'])->andReturn($nullProcess); $filesystem = $this->mockery(Filesystem::class); $filesystem->expects()->exists('/path/to/app/.starter-kit-answers')->andReturnFalse(); $filesystem->expects()->dumpFile('/path/to/app/.starter-kit-answers', new IsTypeOf('string')); $setup->expects()->getFilesystem()->andReturn($filesystem); /** @var StyleFactory & MockInterface $styleFactory */ $styleFactory = $this->mockery(StyleFactory::class); $styleFactory->expects()->factory($input, $output)->andReturn($console); $console->shouldReceive('title')->once(); $console->shouldReceive('block'); $console->shouldReceive('text'); $console->shouldReceive('newLine'); $console->shouldReceive('success')->never(); $console ->shouldReceive('askQuestion') ->with(new IsInstanceOf(ConfirmationQuestion::class)) ->andReturnFalse(); $wizard = new Wizard($setup, $styleFactory); $this->assertSame(0, $wizard->run($input, $output)); } public function testRunWhenUserConfirmsStart(): void { /** @var InputInterface & MockInterface $input */ $input = $this->mockery(InputInterface::class)->shouldIgnoreMissing(); /** @var OutputInterface & MockInterface $output */ $output = $this->mockery(OutputInterface::class); $output->expects()->setVerbosity(OutputInterface::VERBOSITY_NORMAL); /** @var Style & MockInterface $console */ $console = $this->mockery(Style::class); $project = new Project('my-project', '/my/project/path'); /** @var Setup & MockInterface $setup */ $setup = $this->mockery(Setup::class, [ 'getProject' => $project, ]); $setup->expects()->getVerbosity()->andReturn(OutputInterface::VERBOSITY_NORMAL); $setup ->shouldReceive('run') ->once() ->withArgs(function (Style $style, Answers $answers) use ($console): bool { $answers->packageName = 'my-package/name'; $this->assertSame($console, $style); return true; }); $setup ->expects() ->path('.starter-kit-answers') ->andReturn('/path/to/.starter-kit-answers'); $nullProcess = $this->mockery(Process::class); $nullProcess->expects()->run()->twice(); $nullProcess->expects()->getOutput()->twice()->andReturn(''); $setup->expects()->getProcess(['git', 'config', 'user.name'])->andReturn($nullProcess); $setup->expects()->getProcess(['git', 'config', 'user.email'])->andReturn($nullProcess); $filesystem = $this->mockery(Filesystem::class); $filesystem->expects()->exists('/path/to/.starter-kit-answers')->andReturnFalse(); $setup->expects()->getFilesystem()->andReturn($filesystem); /** @var StyleFactory & MockInterface $styleFactory */ $styleFactory = $this->mockery(StyleFactory::class); $styleFactory->expects()->factory($input, $output)->andReturn($console); $console->shouldReceive('title')->once(); $console->shouldReceive('block'); $console->expects()->success([ 'Congratulations! Your project, my-package/name, is ready!', 'Your project is available at /my/project/path.', ]); $console ->expects() ->askQuestion(new IsInstanceOf(ConfirmationQuestion::class)) ->andReturnTrue(); $defaultAnswers = $this->answers; /** @var Question & StarterKitQuestion $question */ foreach ((new InstallQuestions())->getQuestions($defaultAnswers) as $question) { if ($question instanceof SkippableQuestion && $question->shouldSkip()) { continue; } $console ->expects() ->askQuestion(new IsInstanceOf(get_class($question))) // phpcs:ignore ->andReturn($defaultAnswers->{$question->getName()}); } $wizard = new Wizard($setup, $styleFactory); $this->assertSame(0, $wizard->run($input, $output)); } public function testRunWhenUsingAnswersFileWhenSkipPromptsIsTrue(): void { $answersFile = __DIR__ . '/answers-test.json'; putenv('STARTER_KIT_ANSWERS_FILE=' . $answersFile); /** @var InputInterface & MockInterface $input */ $input = $this->mockery(InputInterface::class)->shouldIgnoreMissing(); /** @var OutputInterface & MockInterface $output */ $output = $this->mockery(OutputInterface::class); $output->expects()->setVerbosity(OutputInterface::VERBOSITY_NORMAL); /** @var Style & MockInterface $console */ $console = $this->mockery(Style::class); $project = new Project('my-project', '/my/project/path'); /** @var Setup & MockInterface $setup */ $setup = $this->mockery(Setup::class, [ 'getProject' => $project, ]); $setup->expects()->getVerbosity()->andReturn(OutputInterface::VERBOSITY_NORMAL); $setup ->shouldReceive('run') ->once() ->withArgs(function (Style $style, Answers $answers) use ($console): bool { $this->assertSame($console, $style); return true; }); $setup->expects()->getFilesystem()->andReturn(new Filesystem()); /** @var StyleFactory & MockInterface $styleFactory */ $styleFactory = $this->mockery(StyleFactory::class); $styleFactory->expects()->factory($input, $output)->andReturn($console); $console->shouldReceive('title')->once(); $console->shouldReceive('block'); $console->expects()->success([ 'Congratulations! Your project, fellowship/ring, is ready!', 'Your project is available at /my/project/path.', ]); $console->shouldNotReceive('askQuestion'); $wizard = new Wizard($setup, $styleFactory); $this->assertSame(0, $wizard->run($input, $output)); // Remove the environment variable to avoid affecting other tests. putenv('STARTER_KIT_ANSWERS_FILE'); } public function testNewApplicationReturnsAnInstanceOfApplication(): void { /** @phpstan-ignore-next-line */ $this->assertInstanceOf(Application::class, Wizard::newApplication()); } public function testStart(): void { $vendorDir = (string) realpath(__DIR__ . '/../../vendor'); /** @var Event & MockInterface $event */ $event = $this->mockery(Event::class, [ 'getIO->isDebug' => false, 'getIO->isVeryVerbose' => false, 'getIO->isVerbose' => false, ]); $event ->shouldReceive('getComposer->getConfig->get') ->with('vendor-dir') ->once() ->andReturn($vendorDir); /** @var Application & MockInterface $application */ $application = $this->mockery(Application::class); $application ->shouldReceive('add') ->once() ->withArgs(function (Wizard $command) use ($vendorDir): bool { $this->assertSame('php-library-starter-kit', $command->getSetup()->getProject()->getName()); $this->assertSame(dirname($vendorDir), $command->getSetup()->getProject()->getPath()); return true; }); $application->expects()->setDefaultCommand('starter-kit', true); $application->expects()->run(new IsInstanceOf(StringInput::class)); Wizard::$application = $application; Wizard::start($event); // Restore static property to null to avoid conflicts with other tests. Wizard::$application = null; } #[DataProvider('runWhenExceptionIsThrownWithVerbosityProvider')] public function testRunWhenExceptionIsThrownWithVerbosity( int $verbosity, int $exceptionCode, int $expectedReturn, ): void { /** @var InputInterface & MockInterface $input */ $input = $this->mockery(InputInterface::class)->shouldIgnoreMissing(); /** @var OutputInterface & MockInterface $output */ $output = $this->mockery(OutputInterface::class); $output->expects()->setVerbosity($verbosity); /** @var Style & MockInterface $console */ $console = $this->mockery(Style::class); $project = new Project('my-project', '/my/project/path'); // phpcs:disable $exceptionLine = __LINE__; $exception = new RuntimeException('a test exception message', $exceptionCode); // phpcs:enable /** @var Setup & MockInterface $setup */ $setup = $this->mockery(Setup::class, ['getProject' => $project]); $setup->expects()->getVerbosity()->andReturn($verbosity); $setup->shouldReceive('run')->once()->andThrow($exception); $setup->expects()->path('.starter-kit-answers')->andReturn('/path/to/.starter-kit-answers'); $nullProcess = $this->mockery(Process::class); $nullProcess->expects()->run()->twice(); $nullProcess->expects()->getOutput()->twice()->andReturn(''); $setup->expects()->getProcess(['git', 'config', 'user.name'])->andReturn($nullProcess); $setup->expects()->getProcess(['git', 'config', 'user.email'])->andReturn($nullProcess); $filesystem = $this->mockery(Filesystem::class); $filesystem->expects()->exists('/path/to/.starter-kit-answers')->andReturnFalse(); $setup->expects()->getFilesystem()->andReturn($filesystem); /** @var StyleFactory & MockInterface $styleFactory */ $styleFactory = $this->mockery(StyleFactory::class); $styleFactory->expects()->factory($input, $output)->andReturn($console); $console->shouldReceive('block'); $console->shouldReceive('newLine'); $console->shouldReceive('title')->once(); $console->shouldReceive('success')->never(); $console->shouldReceive('getVerbosity')->andReturn($verbosity); $console ->expects() ->askQuestion(new IsInstanceOf(ConfirmationQuestion::class)) ->andReturnTrue(); $defaultAnswers = $this->answers; /** @var Question & StarterKitQuestion $question */ foreach ((new InstallQuestions())->getQuestions($defaultAnswers) as $question) { if ($question instanceof SkippableQuestion && $question->shouldSkip()) { continue; } $console ->expects() ->askQuestion(new IsInstanceOf(get_class($question))) // phpcs:ignore ->andReturn($defaultAnswers->{$question->getName()}); } $expectedErrorMessages = [ 'a test exception message', 'At line ' . $exceptionLine . ' in ' . __FILE__, ]; if ($verbosity === OutputInterface::VERBOSITY_DEBUG) { $expectedErrorMessages[] = $exception->getTraceAsString(); } $console->expects()->error($expectedErrorMessages); $wizard = new Wizard($setup, $styleFactory); $this->assertSame($expectedReturn, $wizard->run($input, $output)); } /** * @return list */ public static function runWhenExceptionIsThrownWithVerbosityProvider(): array { return [ [ 'verbosity' => OutputInterface::VERBOSITY_NORMAL, 'exceptionCode' => 0, 'expectedReturn' => 1, ], [ 'verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'exceptionCode' => 2, 'expectedReturn' => 2, ], [ 'verbosity' => OutputInterface::VERBOSITY_VERY_VERBOSE, 'exceptionCode' => 3, 'expectedReturn' => 3, ], [ 'verbosity' => OutputInterface::VERBOSITY_DEBUG, 'exceptionCode' => 4, 'expectedReturn' => 4, ], ]; } #[DataProvider('determineVerbosityLevelProvider')] public function testDetermineVerbosityLevel( bool $isDebug, bool $isVeryVerbose, bool $isVerbose, int $expectedVerbosity, ): void { /** @var Event & MockInterface $event */ $event = $this->mockery(Event::class, [ 'getIO->isDebug' => $isDebug, 'getIO->isVeryVerbose' => $isVeryVerbose, 'getIO->isVerbose' => $isVerbose, ]); $this->assertSame($expectedVerbosity, Wizard::determineVerbosityLevel($event)); } /** * @return list */ public static function determineVerbosityLevelProvider(): array { return [ [ 'isDebug' => false, 'isVeryVerbose' => false, 'isVerbose' => false, 'expectedVerbosity' => OutputInterface::VERBOSITY_NORMAL, ], [ 'isDebug' => true, 'isVeryVerbose' => false, 'isVerbose' => false, 'expectedVerbosity' => OutputInterface::VERBOSITY_DEBUG, ], [ 'isDebug' => false, 'isVeryVerbose' => true, 'isVerbose' => false, 'expectedVerbosity' => OutputInterface::VERBOSITY_VERY_VERBOSE, ], [ 'isDebug' => false, 'isVeryVerbose' => false, 'isVerbose' => true, 'expectedVerbosity' => OutputInterface::VERBOSITY_VERBOSE, ], ]; } } ================================================ FILE: tests/LibraryStarterKit/answers-test.json ================================================ { "authorHoldsCopyright": true, "authorEmail": "frodo@example.com", "unknownProperty": "foobar", "authorUrl": "https://example.com/the-fellowship/frodo", "packageDescription": "A package to help you on your journey.", "codeOfConduct": "Citizen-2.3", "codeOfConductEmail": "council@example.com", "projectName": "The Fellowship of the Ring", "codeOfConductPoliciesUrl": "https://example.com/the-fellowship/conduct-policies", "securityPolicyContactFormUrl": "https://example.com/security", "codeOfConductReportingUrl": "https://example.com/the-fellowship/conduct-reporting", "authorName": "Frodo Baggins", "copyrightEmail": "fellowship@example.com", "copyrightHolder": "The Fellowship", "copyrightUrl": "https://example.com/the-fellowship", "packageName": "fellowship/ring", "securityPolicy": true, "anotherUnknownProperty": "baz", "copyrightYear": "2021", "codeOfConductCommittee": "Council of the Wise", "githubUsername": "frodo", "securityPolicyContactEmail": "security@example.com", "vendorName": "fellowship", "license": "BSD-2-Clause", "packageKeywords": [ "foo", "bar" ], "packageNamespace": "Fellowship\\Ring", "skipPrompts": true } ================================================ FILE: tests/TestCase.php ================================================