diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index df037f4..0000000 --- a/.editorconfig +++ /dev/null @@ -1,24 +0,0 @@ -# For more information about the properties used in -# this file, please see the EditorConfig documentation: -# http://editorconfig.org/ - -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_size = 4 -indent_style = space -insert_final_newline = true -trim_trailing_whitespace = true - -[*.md] -trim_trailing_whitespace = false - -[*.yml] -indent_size = 2 - -[{.travis.yml,package.json}] -# The indent size used in the `package.json` file cannot be changed -# https://github.com/npm/npm/pull/3180#issuecomment-16336516 -indent_size = 2 diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index b5989f4..0000000 --- a/.gitattributes +++ /dev/null @@ -1,9 +0,0 @@ -# Auto-detect text files, ensure they use LF. -* text=auto eol=lf - -# These files are always considered text and should use LF. -# See core.whitespace @ http://git-scm.com/docs/git-config for whitespace flags. -*.php text eol=lf whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4 diff=php -*.json text eol=lf whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4 -*.test text eol=lf whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4 -*.yml text eol=lf whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=2 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..4d7ea1e --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @Novusvetus diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md deleted file mode 100644 index 89cba32..0000000 --- a/.github/CONTRIBUTING.md +++ /dev/null @@ -1,29 +0,0 @@ -Contributing to AutoGitIgnore -======================== - -Please note that this project is released with a -[Contributor Code of Conduct](http://contributor-covenant.org/version/1/4/). -By participating in this project you agree to abide by its terms. - -Reporting Issues ----------------- - -When reporting issues, please try to be as descriptive as possible, and include -as much relevant information as you can. A step by step guide on how to -reproduce the issue will greatly increase the chances of your issue being -resolved in a timely manner. - -Security Reports ----------------- - -Please send any sensitive issue to [development@novusvetus.de](mailto:development@novusvetus.de). Thanks! - -Contributing policy -------------------- - -Fork the project, create a feature branch, and send us a pull request. - -To ensure a consistent code base, you should make sure the code follows -the [PSR-2 Coding Standards](http://www.php-fig.org/psr/psr-2/). You can also -run [php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) with the -configuration file that can be found in the project root directory. diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..e88d6b9 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,5 @@ +# These are supported funding model platforms + +github: [novusvetus] +ko_fi: novusvetus +custom: ["https://www.paypal.me/marcelru"] diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 87ee3ab..0000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,17 +0,0 @@ -Describe the steps to reproduce your issue. - -``` -...replace me... -``` - -Describe the expected and the actual outcome. - -``` -...replace me... -``` - -Describe your environment as detailed as possible. - -``` -...replace me... -``` \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..4f3bb7f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,31 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "[BUG]" +labels: bug +assignees: Novusvetus + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information, if relevant):** +- OS: [e.g. Linux] +- Version: [e.g. 22] +- Browser: [e.g. Chrome] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md new file mode 100644 index 0000000..5a38738 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/custom.md @@ -0,0 +1,10 @@ +--- +name: Custom issue template +about: Describe this issue template's purpose here. +title: "[ISSUE]" +labels: '' +assignees: Novusvetus + +--- + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..93c2363 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "[FEATURE]" +labels: enhancement +assignees: Novusvetus + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ca0f5c4 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,40 @@ + + +## Pull request type + + + +Please check the type of change your PR introduces: + +- [ ] Bugfix +- [ ] Feature +- [ ] Code style update (formatting, renaming) +- [ ] Refactoring (no functional changes, no api changes) +- [ ] Build related changes +- [ ] Documentation content changes +- [ ] Other (please describe): + +## What is the current behavior? + + + +Issue Number: N/A + +## What is the new behavior? + + + +- +- +- + +## Does this introduce a breaking change? + +- [ ] Yes +- [ ] No + + + +## Other information + + diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..2551fdc --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,92 @@ +--- +- name: "breaking change" + color: ee0701 + description: "A breaking change for existing users." +- name: "bug" + color: ee0701 + description: "Inconsistencies or issues which will cause a problem for users or implementors." +- name: "documentation" + color: 0052cc + description: "Solely about the documentation of the project." +- name: "enhancement" + color: 1d76db + description: "Enhancement of the code, not introducing new features." +- name: "refactor" + color: 1d76db + description: "Improvement of existing code, not introducing new features." +- name: "performance" + color: 1d76db + description: "Improving performance, not introducing new features." +- name: "new feature" + color: 0e8a16 + description: "New features or options." +- name: "maintenance" + color: 2af79e + description: "Generic maintenance tasks." +- name: "ci" + color: 1d76db + description: "Work that improves the continue integration." +- name: "dependencies" + color: 1d76db + description: "Upgrade or downgrade of project dependencies." +- name: "question" + color: d876e3 + description: "Further information is requested." + +- name: "in progress" + color: fbca04 + description: "Issue is currently being resolved by a developer." +- name: "stale" + color: fef2c0 + description: "There has not been activity on this issue or PR for quite some time." +- name: "no stale" + color: fef2c0 + description: "This issue or PR is exempted from the stable bot." +- name: "wontfix" + color: ffffff + description: "Further information is requested." + +- name: "security" + color: ee0701 + description: "Marks a security issue that needs to be resolved ASAP." +- name: "incomplete" + color: fef2c0 + description: "Marks a PR or issue that is missing information." +- name: "invalid" + color: fef2c0 + description: "Marks a PR or issue that is missing information." + +- name: "good first issue" + color: 0e8a16 + description: "Good first issue for people wanting to contribute to the project." +- name: "help wanted" + color: 0e8a16 + description: "We need some extra helping hands or expertise in order to resolve this." + +- name: "priority critical" + color: ee0701 + description: "This should be dealt with ASAP. Not fixing this issue would be a serious error." +- name: "priority high" + color: b60205 + description: "After critical issues are fixed, these should be dealt with before any further issues." +- name: "priority medium" + color: 0e8a16 + description: "This issue may be useful, and needs some attention." +- name: "priority low" + color: e4ea8a + description: "Nice addition, maybe... someday..." + +- name: "major" + color: b60205 + description: "This PR causes a major version bump in the version number." +- name: "minor" + color: 0e8a16 + description: "This PR causes a minor version bump in the version number." + +- name: "duplicate" + color: cfd3d7 + description: "This issue or pull request already exists." + +- name: "hacktoberfest" + color: ea0192 + description: "Takes part in Hacktoberfest." diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..b9657e1 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,19 @@ +name: CodeQL + +on: + push: + pull_request: + schedule: + - cron: "30 1 * * 0" + +jobs: + codeql: + name: ๐Ÿญ Scanning + runs-on: ubuntu-latest + steps: + - name: โคต๏ธ Check out code from GitHub + uses: actions/checkout@v2 + - name: ๐Ÿ— Initialize CodeQL + uses: github/codeql-action/init@v1 + - name: ๐Ÿš€ Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml new file mode 100644 index 0000000..7741f8e --- /dev/null +++ b/.github/workflows/labels.yml @@ -0,0 +1,20 @@ +name: Sync labels + +on: + push: + branches: + - main + paths: + - .github/labels.yml + +jobs: + labels: + name: โ™ป๏ธ Sync labels + runs-on: ubuntu-latest + steps: + - name: โคต๏ธ Check out code from GitHub + uses: actions/checkout@v2 + - name: ๐Ÿš€ Run Label Syncer + uses: micnncim/action-label-syncer@v1.3.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml new file mode 100644 index 0000000..d17a5f0 --- /dev/null +++ b/.github/workflows/lock.yml @@ -0,0 +1,19 @@ +name: Lock + +on: + schedule: + - cron: "0 9 * * *" + workflow_dispatch: + +jobs: + lock: + name: ๐Ÿ”’ Lock closed issues and PRs + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@v2.1.2 + with: + github-token: ${{ github.token }} + issue-lock-inactive-days: "7" + issue-lock-reason: "" + pr-lock-inactive-days: "7" + pr-lock-reason: "" diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml new file mode 100644 index 0000000..5038842 --- /dev/null +++ b/.github/workflows/phpcs.yml @@ -0,0 +1,32 @@ +name: "CI" + +on: + push: + paths: + - "**.php" + - "phpcs.xml" + - ".github/workflows/phpcs.yml" + pull_request: + paths: + - "**.php" + - "phpcs.xml" + - ".github/workflows/phpcs.yml" + +jobs: + phpcs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # important! + + - name: Install PHP_CodeSniffer + run: | + curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar + php phpcs.phar --version + + - uses: Novusvetus/action-php_codesniffer@1.1.0 + with: + files: "**.php" + phpcs_path: php phpcs.phar + standard: phpcs.xml diff --git a/.github/workflows/pr-labels.yml b/.github/workflows/pr-labels.yml new file mode 100644 index 0000000..af8791e --- /dev/null +++ b/.github/workflows/pr-labels.yml @@ -0,0 +1,19 @@ +name: PR Labels + +on: + pull_request: + types: [opened, labeled, unlabeled, synchronize] + +jobs: + pr_labels: + name: ๐Ÿญ Verify + runs-on: ubuntu-latest + steps: + - name: ๐Ÿท Verify PR has a valid label + uses: jesusvasquez333/verify-pr-label-action@v1.4.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + valid-labels: >- + breaking change, bug, documentation, enhancement, + refactor, performance, new feature, maintenance, ci, dependencies, question + disable-reviews: true diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..a86501b --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,36 @@ +name: Stale + +on: + schedule: + - cron: "0 8 * * *" + workflow_dispatch: + +jobs: + stale: + name: ๐Ÿงน Clean up stale issues and PRs + runs-on: ubuntu-latest + steps: + - name: ๐Ÿš€ Run stale + uses: actions/stale@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + days-before-stale: 180 + days-before-close: 7 + remove-stale-when-updated: true + stale-issue-label: "stale" + exempt-issue-labels: "no stale,help wanted" + stale-issue-message: > + There hasn't been any activity on this issue recently, so we + clean up some of the older and inactive issues. + Please make sure to update to the latest version and + check if that solves the issue. Let us know if that works for you + by leaving a comment ๐Ÿ‘. + This issue has now been marked as stale and will be closed if no + further activity occurs. Thanks! + stale-pr-label: "stale" + exempt-pr-labels: "no stale" + stale-pr-message: > + There hasn't been any activity on this pull request recently. This + pull request has been automatically marked as stale because of that + and will be closed if no further activity occurs within 7 days. + Thank you for your contributions. diff --git a/.gitignore b/.gitignore index a7987af..9eb75da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,29 @@ -.idea +# Ignore temporary files (left by editors and OS) +.DS_Store +*._* +*.AppleDouble +*.bak +*.swp +*~ +composer.lock +.env + +# Ignore by common IDEs used directories/files +.buildpath +.settings +.TemporaryItems +.webprj +*.idea +*.project +nbproject + +# Temporary files and folders +.cache +.php_cs.cache +.sass-cache +.session +*.log + +# Files by Build tool .vagrant -/.buildpath -/.project -/.settings -/nbproject -/vendor -Vagrantfile \ No newline at end of file +Vagrantfile diff --git a/.php_cs b/.php_cs deleted file mode 100644 index db8790e..0000000 --- a/.php_cs +++ /dev/null @@ -1,26 +0,0 @@ - - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. -EOF; - -$finder = PhpCsFixer\Finder::create() - ->files() - ->name('*.php') - ->in(__DIR__) -; - -return PhpCsFixer\Config::create() - ->setUsingCache(false) - ->setRiskyAllowed(true) - ->setRules(array( - '@PSR2' => true, - 'header_comment' => array('header' => $header) - )) - ->setFinder($finder) -; diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..b734a20 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1 @@ +This file is not actively maintained. Instead, see the official version control system. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..0af111f --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# 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 +development@novusvetus.de. +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. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..ac670ec --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,13 @@ +## Bugtracker ## +Bugs are tracked in the issues section of this repository on GitHub. +Please read over existing issues before submitting an issue to ensure yours is unique. + +[Create a new issue](../../issues/new) + - Describe the steps to reproduce your issue. + - Describe the expected and the actual outcome. + - Describe your environment as detailed as possible. + + +## Development and contribution ## +Feature requests can also be made by [creating a new issue](../../issues/new). +If you would like to make contributions to this repository, feel free to [create a fork](../../fork) and submit a pull request. diff --git a/LICENSE b/LICENSE index 7664ff8..b1bf368 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ BSD 3-Clause License -Copyright (c) 2018, Novusvetus / Marcel Rudolf, Germany +Copyright (c) 2021, Novusvetus / Marcel Rudolf, Germany All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -* 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. +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. -* 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. +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 diff --git a/README.md b/README.md index 7febc58..3d9647d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A post-update-cmd script to automatically add Composer managed packages to .giti ### Add the following to your composer.json ```json "scripts": { - "post-update-cmd": "Novusvetus\\AutoGitIgnore\\GitIgnoreBuilder::Go" + "post-update-cmd": "Novusvetus\\AutoGitIgnore\\GitIgnoreBuilder::go" } ``` ### Add it to your project with: diff --git a/composer.json b/composer.json index 51f03ad..34c319b 100644 --- a/composer.json +++ b/composer.json @@ -1,19 +1,25 @@ { - "name": "novusvetus/autogitignore", - "description": "A post-update-cmd script to automatically add Composer managed packages to .gitignore", - "authors": [ - { - "name": "Novusvetus / Marcel Rudolf, Germany", - "email": "development@novusvetus.de" - } - ], - "require": { - "composer/composer": "*", - "novusvetus/classhelper": "1.*" - }, - "autoload": { - "psr-4": { - "Novusvetus\\AutoGitIgnore\\": "src/" - } + "name": "novusvetus/autogitignore", + "description": "A post-update-cmd script to automatically add Composer managed packages to .gitignore", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Novusvetus / Marcel Rudolf, Germany", + "email": "development@novusvetus.de" } -} + ], + "autoload": { + "psr-4": { + "Novusvetus\\AutoGitIgnore\\": "src/" + } + }, + "require": { + "composer/composer": "*", + "novusvetus/classhelper": "1.* || 2.*", + "php": "^7.1 || ^8" + }, + "config": { + "process-timeout": 600, + "sort-packages": true + } +} \ No newline at end of file diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..58aa91e --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,219 @@ + + + The PSR-2 coding standard. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + 0 + + + 0 + + + + + + + + + + + + + 0 + + + 0 + + + + + + + 0 + + + + + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + diff --git a/src/Exception/AutoGitIgnoreParserException.php b/src/Exception/AutoGitIgnoreParserException.php index e5574f6..ec2f9a8 100644 --- a/src/Exception/AutoGitIgnoreParserException.php +++ b/src/Exception/AutoGitIgnoreParserException.php @@ -1,4 +1,4 @@ -getIO()->writeError('Updating .gitignore: ', false); @@ -68,11 +68,19 @@ public static function Go(Event $event) // the package is not in the list of require-dev // OR is set in the list of require packages // before skipping. - if ($devRequires && (!in_array($package->getName(), $devRequires) || in_array($package->getName(), $requires))) { + if ( + $devRequires && ( + !in_array($package->getName(), $devRequires) || + in_array($package->getName(), $requires) + ) + ) { continue; } $path = $installManager->getInstallPath($package); - $packages[] = '/' . preg_replace('~^' . preg_quote(str_replace('\\', '/', getcwd()) . '/') . '~', '', str_replace('\\', '/', realpath($path))) . '/'; + $packages[] = '/' . preg_replace( + '~^' . preg_quote(str_replace('\\', '/', getcwd()) . '/') . '~', + '', str_replace('\\', '/', realpath($path)) + ) . '/'; } $packages = array_unique($packages); diff --git a/src/GitIgnoreFile.php b/src/GitIgnoreFile.php index 7d361f5..d5d2e88 100644 --- a/src/GitIgnoreFile.php +++ b/src/GitIgnoreFile.php @@ -1,4 +1,4 @@ -fileContent = array(); $this->afterLine = null; $this->filePath = $filePath; $this->checkPermissions(); $this->parse(); - } - /** - * Gets the file path - * - * @return string - */ - public function getFile() - { - return $this->filePath; + return $this; } /** * Permission check * + * @return self * @throws AutoGitIgnorePermissionException * - * @return self */ - protected function checkPermissions() + protected function checkPermissions(): GitIgnoreFile { $file = $this->getFile(); if (!file_exists($file)) { if (!is_writable(dirname($file))) { - throw ClassHelper::create('AutoGitIgnorePermissionException', 'You don\'t have the permissions to create ' . $file . '.'); + throw ClassHelper::create( + AutoGitIgnorePermissionException::class, + 'You don\'t have the permissions to create ' . $file . '.' + ); } touch($file); } elseif (!is_writable($file)) { - throw ClassHelper::create('AutoGitIgnorePermissionException', 'You don\'t have the permissions to edit ' . $file . '.'); + throw ClassHelper::create( + AutoGitIgnorePermissionException::class, + 'You don\'t have the permissions to edit ' . $file . '.' + ); } return $this; } + /** + * Gets the file path + * + * @return string + */ + public function getFile(): string + { + return $this->filePath; + } + /** * Loads the .gitignore file and parses it. * + * @return self * @throws AutoGitIgnoreParseException * - * @return self */ - protected function parse() + protected function parse(): GitIgnoreFile { $fileContent = file($this->getFile(), FILE_IGNORE_NEW_LINES); @@ -137,17 +140,26 @@ protected function parse() foreach ($fileContent as $line) { if ($line == $this->startMarker) { if ($open) { - throw ClassHelper::create('AutoGitIgnoreParserException', 'There are two openings in this file.'); + throw ClassHelper::create( + AutoGitIgnoreParserException::class, + 'There are two openings in this file.' + ); } else { if ($found) { - throw ClassHelper::create('AutoGitIgnoreParserException', 'There are two blocks in this file.'); + throw ClassHelper::create( + AutoGitIgnoreParserException::class, + 'There are two blocks in this file.' + ); } else { $open = true; } } } elseif ($line == $this->endMarker) { if (!$open) { - throw ClassHelper::create('AutoGitIgnoreParserException', 'The line ending is before the start.'); + throw ClassHelper::create( + AutoGitIgnoreParserException::class, + 'The line ending is before the start.' + ); } else { $found = true; $open = false; @@ -174,7 +186,7 @@ protected function parse() * * @return self */ - public function setLines($lines) + public function setLines($lines): GitIgnoreFile { if (!is_array($lines)) { $this->lines = array( @@ -190,14 +202,17 @@ public function setLines($lines) /** * Save to the .gitinore file * + * @return self * @throws AutoGitIgnoreSaveException * - * @return self */ - public function save() + public function save(): GitIgnoreFile { if ($this->afterLine === null) { - throw ClassHelper::create('AutoGitIgnoreSaveException', 'No file loaded.'); + throw ClassHelper::create( + AutoGitIgnoreSaveException::class, + 'No file loaded.' + ); } $output = array(); @@ -223,7 +238,10 @@ public function save() } if (!file_put_contents($this->getFile(), implode(PHP_EOL, $output))) { - throw ClassHelper::create('AutoGitIgnoreSaveException', 'Saving to ' . $this->getFile() . ' failed.'); + throw ClassHelper::create( + AutoGitIgnoreSaveException::class, + 'Saving to ' . $this->getFile() . ' failed.' + ); } return $this;