Skip to content

Commit d8b5e5f

Browse files
committed
init
0 parents  commit d8b5e5f

109 files changed

Lines changed: 2321 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 4

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.github export-ignore
2+
/tests export-ignore
3+
/stubs export-ignore
4+
.gitattributes export-ignore
5+
.gitignore export-ignore
6+
.travis.yml export-
7+
composer-dependency-analyser.php export-ignore
8+
phpunit.xml export-ignore
9+
*.md export-ignore

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
github: tomasvotruba
3+
custom: https://www.paypal.me/rectorphp

.github/workflows/bare_run.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Bare Run on various PHP versions
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
bare_run:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
php_version: ['7.4', '8.2']
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
-
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php_version }}
24+
coverage: none
25+
26+
- run: mkdir nested-dir
27+
28+
- run: composer require rector/mockstan --dev --ansi
29+
working-directory: nested-dir
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Code Analysis
2+
3+
on:
4+
pull_request: null
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
code_analysis:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
actions:
15+
-
16+
name: 'PHPStan'
17+
run: composer phpstan --ansi
18+
19+
-
20+
name: 'Composer Validate'
21+
run: composer validate --ansi
22+
23+
-
24+
name: 'Rector'
25+
run: composer rector --ansi
26+
27+
-
28+
name: 'Coding Standard'
29+
run: composer fix-cs --ansi
30+
31+
-
32+
name: 'Tests'
33+
run: vendor/bin/phpunit
34+
35+
-
36+
name: 'Composer Dependency Analysis'
37+
run: vendor/bin/composer-dependency-analyser
38+
39+
-
40+
name: 'Check Active Classes'
41+
run: vendor/bin/class-leak check src --ansi
42+
43+
name: ${{ matrix.actions.name }}
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- uses: actions/checkout@v3
48+
# see https://github.com/shivammathur/setup-php
49+
- uses: shivammathur/setup-php@v2
50+
with:
51+
php-version: 8.3
52+
coverage: none
53+
54+
# composer install cache - https://github.com/ramsey/composer-install
55+
- uses: "ramsey/composer-install@v2"
56+
57+
- run: ${{ matrix.actions.run }}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Downgraded Release
2+
3+
on:
4+
push:
5+
tags:
6+
# avoid infinite looping, skip tags that ends with ".74"
7+
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-branches
8+
- '*'
9+
- '!**.74'
10+
11+
jobs:
12+
downgrade_release:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: "actions/checkout@v3"
17+
with:
18+
token: ${{ secrets.WORKFLOWS_TOKEN }}
19+
20+
-
21+
uses: "shivammathur/setup-php@v2"
22+
with:
23+
php-version: 8.3
24+
coverage: none
25+
26+
# invoke patches
27+
- run: composer install --ansi
28+
29+
# but no dev packages
30+
- run: composer update --no-dev --ansi
31+
32+
# get rector to "rector-local" directory, to avoid downgrading itself in the /vendor
33+
- run: mkdir rector-local
34+
- run: composer require rector/rector:^2.0 --working-dir rector-local --ansi
35+
36+
# downgrade to PHP 7.4
37+
- run: rector-local/vendor/bin/rector process src config --config build/rector-downgrade-php.php --ansi
38+
39+
# clear the dev files
40+
- run: rm -rf tests rector-local ecs.php phpstan.neon phpunit.xml .editorconfig stubs
41+
42+
# copy PHP 7.4 composer + workflows
43+
- run: cp -r build/target-repository/. .
44+
45+
# clear the dev files
46+
- run: rm -rf build rector.php phpstan-for-tests.neon tests stubs
47+
48+
# setup git user
49+
-
50+
run: |
51+
git config user.email "action@github.com"
52+
git config user.name "GitHub Action"
53+
# publish to the same repository with a new tag
54+
# see https://tomasvotruba.com/blog/how-to-release-php-81-and-72-package-in-the-same-repository/
55+
-
56+
name: "Tag Downgraded Code"
57+
run: |
58+
# separate a "git add" to add untracked (new) files too
59+
git add --all
60+
git commit -m "release PHP 7.4 downgraded"
61+
62+
# force push tag, so there is only 1 version
63+
git tag "${GITHUB_REF#refs/tags/}" --force
64+
git push origin "${GITHUB_REF#refs/tags/}" --force

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor
2+
composer.lock
3+
4+
.phpunit.cache

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
The MIT License
2+
---------------
3+
4+
Copyright (c) 2020 Tomas Votruba (https://tomasvotruba.com)
5+
6+
Permission is hereby granted, free of charge, to any person
7+
obtaining a copy of this software and associated documentation
8+
files (the "Software"), to deal in the Software without
9+
restriction, including without limitation the rights to use,
10+
copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the
12+
Software is furnished to do so, subject to the following
13+
conditions:
14+
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25+
OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# PHPUnit Mocks Rules
2+
3+
[![Downloads](https://img.shields.io/packagist/dt/rector/mockstan.svg?style=flat-square)](https://packagist.org/packages/rector/mockstan/stats)
4+
5+
Set of x+ PHPStan fun and practical rules that check:
6+
7+
@todo
8+
9+
Useful for any type of PHP project, from legacy to modern stack.
10+
11+
<br>
12+
13+
## Install
14+
15+
```bash
16+
composer require rector/mockstan --dev
17+
```
18+
19+
*Note: Make sure you use [`phpstan/extension-installer`](https://github.com/phpstan/extension-installer#usage) to load necessary service configs.*
20+
21+
<br>
22+
23+
@todo rules docs here
24+
25+
### ParamNameToTypeConventionRule
26+
27+
Interface must be located in "Contract" or "Contracts" namespace
28+
29+
```yaml
30+
rules:
31+
- Rector\Mockstan\Rules\CheckRequiredInterfaceInContractNamespaceRule
32+
```
33+
34+
```php
35+
namespace App\Repository;
36+
37+
interface ProductRepositoryInterface
38+
{
39+
}
40+
```
41+
42+
:x:
43+
44+
<br>
45+
46+
```php
47+
namespace App\Contract\Repository;
48+
49+
interface ProductRepositoryInterface
50+
{
51+
}
52+
```
53+
54+
:+1:
55+
56+
<br>
57+
58+
Happy coding!

build/rector-downgrade-php.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withDowngradeSets(php74: true)
9+
->withSkip(['*/Tests/*', '*/tests/*', __DIR__ . '/../tests']);

0 commit comments

Comments
 (0)