Skip to content

Commit

Permalink
Initial package
Browse files Browse the repository at this point in the history
  • Loading branch information
ddevsr committed Apr 1, 2024
0 parents commit b7cff46
Show file tree
Hide file tree
Showing 32 changed files with 1,178 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
phpstan.neon export-ignore
phpunit.xml export-ignore
tests export-ignore
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#example-of-a-codeowners-file
* @ddevsr
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2

updates:
- package-ecosystem: 'composer'
directory: '/'
schedule:
interval: 'daily'

- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'daily'
ignore:
- dependency-name: '*'
update-types:
- 'version-update:semver-minor'
- 'version-update:semver-patch'
50 changes: 50 additions & 0 deletions .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Code Analysis

on:
pull_request:
branches:
- main
push:
branches:
- main

env:
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
COMPOSER_ROOT_VERSION: "dev-main"

jobs:
code_analysis:
runs-on: ubuntu-latest

strategy:
matrix:
actions:
-
name: 'Composer Validate'
run: composer validate

-
name: 'PHP-CS-Fixer'
run: composer lint

-
name: 'Rector Dry Run'
run: composer rector

-
name: 'PHPStan'
run: composer phpstan

name: ${{ matrix.actions.name }}

steps:
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none

- uses: ramsey/composer-install@v2

- run: ${{ matrix.actions.run }}
51 changes: 51 additions & 0 deletions .github/workflows/downgraded_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Downgraded Release

# https://tomasvotruba.com/blog/how-to-release-php-81-and-72-package-in-the-same-repository/
# https://github.com/TomasVotruba/cognitive-complexity/blob/main/.github/workflows/downgraded_release.yaml
# https://github.com/symplify/config-transformer/blob/main/.github/workflows/downgraded_release.yaml

on:
push:
tags:
- '*'

jobs:
downgrade_release:
runs-on: ubuntu-latest

steps:
-
uses: "actions/checkout@v4"

-
uses: "shivammathur/setup-php@v2"
with:
php-version: 8.2
coverage: none

- uses: "ramsey/composer-install@v2"

# downgrade /src to PHP 7.2
- run: vendor/bin/rector process src config --config build/rector-downgrade-php-72.php --ansi

# copy PHP 7.2 composer
- run: cp build/composer-php-72.json composer.json

# clear the dev files
- run: rm -rf build .github tests phpstan.neon phpunit.xml

# setup git user
-
run: |
git config user.email "[email protected]"
git config user.name "GitHub Action"
# publish to the same repository with a new tag
-
name: "Tag Downgraded Code"
run: |
git commit -a -m "release PHP 7.2 downgraded ${GITHUB_REF#refs/tags/}"
# force push tag, so there is only 1 version
git tag "${GITHUB_REF#refs/tags/}" --force
git push origin "${GITHUB_REF#refs/tags/}" --force
28 changes: 28 additions & 0 deletions .github/workflows/label-conflict.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Check conflict branch in PR
on:
schedule:
- cron: '*/780 * * * *' # Run at every 240 minutes / 4 hour

jobs:
build:
name: Check conflict branch in PR
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check conflict branch in PR
uses: PHPDevsr/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
label: stale
comment: |
:wave: Hi, @authorTarget!
We detected conflicts in your PR against the base branch :speak_no_evil:
You may want to sync :arrows_counterclockwise: your branch with upstream!
Ref: [Syncing Your Branch](https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/workflow.md#pushing-your-branch)
31 changes: 31 additions & 0 deletions .github/workflows/label-signing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Check Signed PR
on:
pull_request:
branches:
- 'main'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read
pull-requests: write

jobs:
build:
name: Check Signed Commit
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check signed commits in PR
uses: 1Password/[email protected]
with:
comment: |
You must GPG-sign your work, certifying that you either wrote the work or otherwise have the right to pass it on to an open-source project. See Developer's Certificate of Origin. See [signing][1].
**Note that all your commits must be signed.** If you have an unsigned commit, you can sign the previous commits by referring to [gpg-signing-old-commits][2].
[1]: https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/pull_request.md#signing
[2]: https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/workflow.md#gpg-signing-old-commits
31 changes: 31 additions & 0 deletions .github/workflows/test-phpunit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Tests

on:
pull_request:
branches:
- main
push:
branches:
- main

env:
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
COMPOSER_ROOT_VERSION: "dev-main"

jobs:
tests:
runs-on: ubuntu-latest

name: Tests
steps:
- uses: actions/checkout@v4

-
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none

- uses: "ramsey/composer-install@v1"

- run: vendor/bin/phpunit
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/vendor
composer.lock

# PHPStorm meta files
.idea/

.phpunit.result.cache
.phpunit.cache
.php-cs-fixer.cache
44 changes: 44 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

/**
* This file is part of CodeIgniter Rector.
*
* (c) CodeIgniter Foundation <[email protected]>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

use CodeIgniter\CodingStandard\CodeIgniter4;
use Nexus\CsConfig\Factory;
use PhpCsFixer\Finder;

$finder = Finder::create()
->files()
->in([
__DIR__ . '/src/',
__DIR__ . '/tests/',
__DIR__ . '/config/',
])
->append([
__FILE__,
__DIR__ . '/rector.php',
]);

$overrides = [
'declare_strict_types' => true,
'void_return' => true,
];

$options = [
'finder' => $finder,
'cacheFile' => '.php-cs-fixer.cache',
];

return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary(
'CodeIgniter Rector',
'PHPDevsr',
'[email protected]'
);
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
The MIT License
---------------

Copyright (c) 2017-present Tomáš Votruba (https://tomasvotruba.cz)

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.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Rector Rules for Laravel
[![Tests](https://github.com/driftingly/rector-laravel/actions/workflows/tests.yaml/badge.svg)](https://github.com/driftingly/rector-laravel/actions/workflows/tests.yaml)
[![Code Analysis](https://github.com/driftingly/rector-laravel/actions/workflows/code_analysis.yaml/badge.svg)](https://github.com/driftingly/rector-laravel/actions/workflows/code_analysis.yaml)
[![Packagist Downloads](https://img.shields.io/packagist/dm/driftingly/rector-laravel)](https://packagist.org/packages/driftingly/rector-laravel/stats)
[![Packagist Version](https://img.shields.io/packagist/v/driftingly/rector-laravel)](https://packagist.org/packages/driftingly/rector-laravel)

See available [Laravel rules](/docs/rector_rules_overview.md)

## Install

This package is a [Rector](https://github.com/rectorphp/rector) extension developed by the Laravel community.

Install the `RectorLaravel` package as dependency:

```bash
composer require driftingly/rector-laravel --dev
```

## Use Sets

To add a set to your config, use `RectorLaravel\Set\LaravelSetList` class and pick one of the constants:

```php
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use RectorLaravel\Set\LaravelSetList;

return RectorConfig::configure()
->withSets([
LaravelSetList::LARAVEL_110
]);
```

## Learn Rector Faster

Rector is a tool that [we develop](https://getrector.org/) and share for free, so anyone can save hundreds of hours on refactoring.
But not everyone has time to understand Rector and AST complexity. You have 2 ways to speed this process up:

* Read the book - <a href="https://leanpub.com/rector-the-power-of-automated-refactoring">The Power of Automated Refactoring</a>
* Hire our experienced team to <a href="https://getrector.org/contact">improve your codebase</a>

Both ways support us to and improve Rector in sustainable way by learning from practical projects.
21 changes: 21 additions & 0 deletions build/composer-php-72.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "phpdevsr/rector-codeigniter4",
"type": "rector-extension",
"license": "MIT",
"description": "Rector upgrades rules for Codeigniter4",
"require": {
"php": "^7.2 || ^8.0",
"rector/rector": "^1.0"
},
"autoload": {
"psr-4": {
"PHPDevsr\\Rector\\Codeigniter4\\": "src"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"optimize-autoloader": true,
"sort-packages": true
}
}
10 changes: 10 additions & 0 deletions build/rector-downgrade-php-72.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_72]);
};
Loading

0 comments on commit b7cff46

Please sign in to comment.