Skip to content

Commit 6b0b678

Browse files
committed
Initial commit
0 parents  commit 6b0b678

35 files changed

+3147
-0
lines changed

.github/workflows/full-checks.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: "Full checks"
2+
3+
on:
4+
schedule:
5+
- cron: '0 10 * * *'
6+
pull_request:
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
full-checks:
13+
name: "PHP version ${{ matrix.php-version }}"
14+
15+
runs-on: ${{ matrix.operating-system }}
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
php-version:
21+
- "8.2"
22+
- "8.3"
23+
- "8.4"
24+
operating-system:
25+
- "ubuntu-22.04"
26+
27+
steps:
28+
- name: "Checkout"
29+
uses: "actions/checkout@v2"
30+
31+
- name: "Install PHP"
32+
uses: "shivammathur/setup-php@v2"
33+
with:
34+
php-version: "${{ matrix.php-version }}"
35+
tools: composer
36+
37+
- name: Get composer cache directory
38+
id: composercache
39+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
40+
41+
- name: Cache dependencies
42+
uses: actions/cache@v4
43+
with:
44+
path: ${{ steps.composercache.outputs.dir }}
45+
key: "php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}"
46+
restore-keys: "php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}"
47+
48+
- name: "Install dependencies"
49+
run: "composer install --no-interaction --no-progress"
50+
51+
- name: "Full CI"
52+
run: "composer all-checks"
53+

.gitignore

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

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
ARG PHP_VERSION
2+
FROM php:${PHP_VERSION}cli
3+
4+
# Increase memory limit
5+
RUN echo 'memory_limit = -1' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini
6+
7+
# install Composer
8+
COPY ./docker/composer.sh /root/
9+
10+
RUN <<EOF
11+
set -eux;
12+
apt-get update;
13+
apt-get install -y \
14+
git \
15+
zip;
16+
rm -rf /var/lib/apt/lists/*;
17+
cd /root/;
18+
chmod 755 composer.sh;
19+
/root/composer.sh;
20+
mv /root/composer.phar /usr/local/bin/composer;
21+
rm /root/composer.sh;
22+
EOF
23+
24+
# install Xdebug
25+
ARG XDEBUG_ENABLED=1
26+
27+
RUN <<EOF
28+
if [ $XDEBUG_ENABLED -eq 1 ]; then
29+
pecl install xdebug;
30+
docker-php-ext-enable xdebug;
31+
fi
32+
EOF
33+
34+
WORKDIR /app/

LICENSE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# The MIT License (MIT)
2+
3+
Copyright (c) 2024 Dave Liddament
4+
5+
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:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
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.

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Rector custom rules tutorial
2+
3+
This repository contains the code to support [Dave Liddament](https://twitter.com/daveliddament)'s Rector custom rules tutorial.
4+
5+
6+
## Pre tutorial setup
7+
8+
1. Set up an environment with either PHP 8.2 or 8.3.
9+
1. Clone this repository.
10+
1. Run: `composer install`
11+
1. Run all the checks. There is a composer script for this: `composer run-script all-checks`
12+
13+
You should see something similar to this:
14+
15+
```
16+
$ composer run-script all-checks
17+
> composer validate --strict
18+
./composer.json is valid
19+
> vendor/bin/phpunit
20+
PHPUnit 11.4.1 by Sebastian Bergmann and contributors.
21+
22+
Runtime: PHP 8.2.24
23+
Configuration: /home/dave/LampBristol/personal/rector-course/phpunit.xml
24+
25+
. 1 / 1 (100%)
26+
27+
Time: 00:00.002, Memory: 8.00 MB
28+
29+
OK (1 test, 1 assertion)
30+
```
31+
32+
You're all good to go!
33+
34+
## Docker images
35+
36+
There are docker files that have been tested on docker for [MacOS](https://docs.docker.com/desktop/install/mac-install/).
37+
38+
### Build the container
39+
40+
```shell
41+
docker compose build
42+
```
43+
44+
45+
### Start the container
46+
47+
```shell
48+
docker compose up -d
49+
```
50+
51+
52+
### Run docker commands
53+
54+
```shell
55+
docker compose exec php82 <command>
56+
```
57+
58+
E.g.
59+
60+
```shell
61+
# Composer install
62+
docker compose exec php82 composer install
63+
64+
# Run all CI checks
65+
docker compose exec php82 composer all-checks
66+
67+
# Run the tests
68+
docker compose exec php82 vendor/bin/phpunit
69+
70+
# Run rector
71+
docker compose exec php82 vendor/bin/rector
72+
```

composer.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "dave-liddament/rector-custom-rules-workshop",
3+
"description": "Repo to support the rector custom rules workshop",
4+
"type": "project",
5+
"require": {
6+
"php": ">=8.2 <8.5"
7+
},
8+
"require-dev": {
9+
"phpunit/phpunit": "^11.4",
10+
"rector/rector": "^2.0.16"
11+
},
12+
"license": "MIT",
13+
"autoload": {
14+
"psr-4": {
15+
"DaveLiddament\\RectorCustomRulesWorkshop\\": "src/"
16+
}
17+
},
18+
"autoload-dev": {
19+
"psr-4": {
20+
"DaveLiddament\\RectorCustomRulesWorkshop\\Test\\": "tests/",
21+
"Utils\\Rector\\": "utils/rector/src",
22+
"Utils\\Rector\\Tests\\": "utils/rector/tests"
23+
}
24+
},
25+
"authors": [
26+
{
27+
"name": "Dave Liddament",
28+
"email": "[email protected]"
29+
}
30+
],
31+
"scripts": {
32+
"all-checks": [
33+
"composer validate --strict",
34+
"@test"
35+
],
36+
"test": [
37+
"vendor/bin/phpunit"
38+
]
39+
}
40+
}

0 commit comments

Comments
 (0)