mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit dedd4b55fe
dedd4b55fe
make node_helper.php safe for similar names
This commit is contained in:
parent
dd41106ee4
commit
d56e7982d0
|
@ -0,0 +1,27 @@
|
|||
################################################
|
||||
## Docker image used for profiling Rector ##
|
||||
################################################
|
||||
|
||||
ARG PHP_VERSION=8.0
|
||||
|
||||
FROM rector/rector:php${PHP_VERSION}
|
||||
|
||||
# Install php extensions
|
||||
RUN apt-get update && apt-get install -y \
|
||||
wget \
|
||||
gnupg2
|
||||
|
||||
# Setup blackfire repo
|
||||
RUN wget -q -O - https://packages.blackfire.io/gpg.key | apt-key add -
|
||||
RUN echo "deb http://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list
|
||||
|
||||
# Install blackfire php extensions
|
||||
RUN apt-get update && apt-get install -y \
|
||||
blackfire-php
|
||||
|
||||
# Install blackfire cli tool
|
||||
RUN mkdir -p /tmp/blackfire \
|
||||
&& architecture=$(case $(uname -m) in i386 | i686 | x86) echo "i386" ;; x86_64 | amd64) echo "amd64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "amd64" ;; esac) \
|
||||
&& curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux/$architecture | tar zxp -C /tmp/blackfire \
|
||||
&& mv /tmp/blackfire/blackfire /usr/bin/blackfire \
|
||||
&& rm -Rf /tmp/blackfire
|
|
@ -0,0 +1,34 @@
|
|||
## Docker image for Blackfire profiling
|
||||
|
||||
### Build
|
||||
|
||||
Builds image with `rector-blackfire` tag.
|
||||
|
||||
```
|
||||
docker build . --tag rector-blackfire --file .docker/php-blackfire/Dockerfile
|
||||
```
|
||||
|
||||
You can use `--build-arg PHP_VERSION=7.4` to build with specific PHP version. Supported versions are: 7.3, 7.4, 8.0
|
||||
|
||||
|
||||
### Prepare
|
||||
|
||||
These variables must be set on host to pass them into container (obtain values at [blackfire.io](https://blackfire.io)):
|
||||
```
|
||||
export BLACKFIRE_CLIENT_ID=""
|
||||
export BLACKFIRE_CLIENT_TOKEN=""
|
||||
```
|
||||
|
||||
|
||||
### Usage
|
||||
|
||||
Get into container:
|
||||
|
||||
```
|
||||
docker run --entrypoint="" -it --rm -e BLACKFIRE_CLIENT_ID -e BLACKFIRE_CLIENT_TOKEN -v $(pwd):/rector rector-blackfire bash
|
||||
```
|
||||
|
||||
Once in container, you can start profiling:
|
||||
```
|
||||
blackfire run php bin/rector <args..>
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
################################################
|
||||
## Docker image used for debugging Rector ##
|
||||
################################################
|
||||
|
||||
ARG PHP_VERSION=8.0
|
||||
|
||||
FROM rector/rector:php${PHP_VERSION}
|
||||
|
||||
RUN pecl install xdebug
|
||||
|
||||
COPY .docker/php-xdebug/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
|
|
@ -0,0 +1,26 @@
|
|||
## Docker image for Xdebug debugging
|
||||
|
||||
### Build
|
||||
|
||||
Builds image with `rector-xdebug` tag.
|
||||
|
||||
```shell
|
||||
docker build . --tag rector-xdebug --file .docker/php-xdebug/Dockerfile
|
||||
```
|
||||
|
||||
You can use `--build-arg PHP_VERSION=7.4` to build with specific PHP version. Supported versions are: 7.3, 7.4, 8.0
|
||||
|
||||
### Usage
|
||||
|
||||
Get into container (change ip address):
|
||||
|
||||
```shell
|
||||
docker run -it --rm \
|
||||
--entrypoint="" \
|
||||
--volume $(pwd):/rector \
|
||||
--env XDEBUG_CONFIG="client_host=172.16.165.1" \
|
||||
--env PHP_IDE_CONFIG="serverName=rector" \
|
||||
rector-xdebug bash
|
||||
```
|
||||
|
||||
**Do not forget to run rector binary with `--xdebug` option.**
|
|
@ -0,0 +1,5 @@
|
|||
[xdebug]
|
||||
zend_extension = "/usr/local/lib/php/extensions/no-debug-non-zts-20200930/xdebug.so"
|
||||
xdebug.mode = debug
|
||||
xdebug.client_port = 9003
|
||||
xdebug.start_with_request = yes
|
|
@ -0,0 +1,10 @@
|
|||
[opcache]
|
||||
opcache.memory_consumption=128
|
||||
opcache.interned_strings_buffer=8
|
||||
opcache.max_accelerated_files=4000
|
||||
opcache.revalidate_freq=60
|
||||
opcache.fast_shutdown=1
|
||||
opcache.enable_cli=1
|
||||
opcache.enable=1
|
||||
opcache.file_cache='/tmp/opcache'
|
||||
opcache.file_update_protection=0
|
|
@ -0,0 +1,28 @@
|
|||
*~
|
||||
.DS_Store
|
||||
.idea/
|
||||
|
||||
.env
|
||||
.editorconfig
|
||||
.phpstorm.meta.php
|
||||
|
||||
phpstan.neon
|
||||
rector.php
|
||||
phpunit.xml
|
||||
ecs.php
|
||||
|
||||
LICENSE
|
||||
|
||||
.gitattributes
|
||||
.gitignore
|
||||
|
||||
*.md
|
||||
|
||||
.dockerignore
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
docker-compose.dist.yml
|
||||
|
||||
/docs
|
||||
|
||||
*.phar
|
|
@ -1,24 +0,0 @@
|
|||
---
|
||||
name: Bug Report
|
||||
labels: bug
|
||||
about: Report errors and problems
|
||||
---
|
||||
|
||||
# Bug Report
|
||||
|
||||
<!-- First, thank you for reporting a bug. That takes time and we appreciate that! -->
|
||||
|
||||
| Subject | Details |
|
||||
| :------------- | :---------------------------------------------------------------|
|
||||
| Rector version | e.g. v0.9.5 (invoke `vendor/bin/rector --version`) |
|
||||
| Installed as | composer dependency / prefixed Rector |
|
||||
|
||||
<!-- Please describe your problem here. -->
|
||||
|
||||
## Minimal PHP Code Causing Issue
|
||||
|
||||
<!-- Reproduce the issue using https://getrector.org/demo/ and post the URL here. -->
|
||||
|
||||
## Expected Behaviour
|
||||
|
||||
<!-- How should Rector change the code? Or should Rector skip it? -->
|
|
@ -1,18 +0,0 @@
|
|||
---
|
||||
name: Feature Request
|
||||
labels: feature
|
||||
about: RFC and ideas for new features and improvements
|
||||
---
|
||||
|
||||
# Feature Request
|
||||
|
||||
<!-- First, thank you for making a request. That takes time and we appreciate that! -->
|
||||
|
||||
## Diff
|
||||
|
||||
<!-- Use diff here in Markdown: https://stackoverflow.com/a/40883538/1348344 -->
|
||||
|
||||
```diff
|
||||
-$value = $value + 5;
|
||||
+$value += 5;
|
||||
```
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
name: Support Question
|
||||
labels: support
|
||||
about: Questions about using this library
|
||||
---
|
||||
|
||||
# Question
|
|
@ -1,16 +0,0 @@
|
|||
version: 2
|
||||
|
||||
updates:
|
||||
-
|
||||
package-ecosystem: composer
|
||||
directory: "/"
|
||||
open-pull-requests-limit: 5
|
||||
schedule:
|
||||
interval: weekly
|
||||
|
||||
-
|
||||
package-ecosystem: github-actions
|
||||
directory: "/"
|
||||
open-pull-requests-limit: 5
|
||||
schedule:
|
||||
interval: monthly
|
|
@ -0,0 +1,29 @@
|
|||
name: Bare Run
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
bare_run:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php_version: ['7.1', '7.2', '7.3', '7.4', '8.0']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php_version }}
|
||||
coverage: none
|
||||
|
||||
- run: php bin/rector --version --ansi
|
||||
|
||||
- run: php bin/rector list --ansi
|
|
@ -1,108 +0,0 @@
|
|||
# builds the content of https://github.com/rectorphp/rector-prefixed
|
||||
# inspiration from https://github.com/phpstan/phpstan-src/blob/master/.github/workflows/phar.yml
|
||||
name: Build Scoped Rector
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
|
||||
COMPOSER_ROOT_VERSION: "dev-main"
|
||||
|
||||
jobs:
|
||||
build_scoped_rector:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 8.0
|
||||
coverage: none
|
||||
|
||||
# fixes https://github.com/rectorphp/rector/pull/4559/checks?check_run_id=1359814403, see https://github.com/shivammathur/setup-php#composer-github-oauth
|
||||
env:
|
||||
COMPOSER_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
|
||||
# install only prod dependencies - do not use ramsey, it uses cache including "dev", we want to avoid it here
|
||||
- run: composer install --no-dev --ansi
|
||||
|
||||
# 1. copy files to $NESTED_DIRECTORY directory Exclude the scoped/nested directories to prevent rsync from copying in a loop
|
||||
- run: rsync --exclude rector-build -av * rector-build --quiet
|
||||
- run: rm -rf rector-build/packages-tests rector-build/rules-tests rector-build/tests
|
||||
|
||||
# 2. downgrade rector
|
||||
- run: sh build/downgrade-rector.sh rector-build
|
||||
|
||||
# 3. prefix classes
|
||||
- run: sh build/build-rector-scoped.sh rector-build rector-prefixed-downgraded
|
||||
|
||||
# 4. lint the code for PHP 7.1 - this must happen here, as setup-php allows only one PHP version switch: https://github.com/shivammathur/setup-php/issues/434
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.1
|
||||
coverage: none
|
||||
- run: composer create-project php-parallel-lint/php-parallel-lint php-parallel-lint --ansi
|
||||
- run: php-parallel-lint/parallel-lint rector-prefixed-downgraded --exclude rector-prefixed-downgraded/stubs --exclude rector-prefixed-downgraded/vendor/symfony/error-handler/Resources --exclude rector-prefixed-downgraded/vendor/symfony/http-kernel/Resources --exclude rector-prefixed-downgraded/vendor/rector/rector-nette/tests --exclude rector-prefixed-downgraded/vendor/symfony/polyfill-mbstring/bootstrap80.php --exclude rector-prefixed-downgraded/vendor/tracy/tracy/examples
|
||||
|
||||
# 5. copy repository meta files
|
||||
- run: |
|
||||
cp -R build/target-repository/. rector-prefixed-downgraded
|
||||
cp -R templates rector-prefixed-downgraded/
|
||||
|
||||
# 6. clone remote repository, so we can push it
|
||||
-
|
||||
uses: "actions/checkout@v2"
|
||||
with:
|
||||
repository: rectorphp/rector-prefixed
|
||||
path: remote-repository
|
||||
token: ${{ secrets.ACCESS_TOKEN }}
|
||||
|
||||
# remove remote files, to avoid piling up dead code in remote repository
|
||||
- run: rm -rf remote-repository/.github remote-repository/config remote-repository/src remote-repository/rules remote-repository/packages remote-repository/upgrade remote-repository/vendor
|
||||
|
||||
- run: cp -a rector-prefixed-downgraded/. remote-repository
|
||||
|
||||
# 7. setup git
|
||||
-
|
||||
working-directory: remote-repository
|
||||
run: |
|
||||
git config user.email "tomas.vot@gmail.com"
|
||||
git config user.name "Tomas Votruba"
|
||||
|
||||
# commit metadata
|
||||
-
|
||||
name: "Get Git log"
|
||||
id: git-log
|
||||
run: echo ::set-output name=log::$(git log ${{ github.event.before }}..${{ github.event.after }} --reverse --pretty='%H %s' | sed -e 's/^/https:\/\/github.com\/rectorphp\/rector\/commit\//')
|
||||
|
||||
# 8.A publish it to remote repository without tag
|
||||
-
|
||||
name: "Commit Prefixed - main"
|
||||
working-directory: remote-repository
|
||||
if: "!startsWith(github.ref, 'refs/tags/')"
|
||||
run: |
|
||||
git add --all
|
||||
git commit -m "Updated Rector to commit ${{ github.event.after }}" -m "${{ steps.git-log.outputs.log }}"
|
||||
git push --quiet origin main
|
||||
|
||||
# 8.B publish it to remote repository with tag
|
||||
-
|
||||
name: "Commit Prefixed - tag"
|
||||
working-directory: remote-repository
|
||||
if: "startsWith(github.ref, 'refs/tags/')"
|
||||
run: |
|
||||
git add --all
|
||||
git commit -m "Rector ${GITHUB_REF#refs/tags/}" -m "${{ steps.git-log.outputs.log }}"
|
||||
git push --quiet origin main
|
||||
git tag ${GITHUB_REF#refs/tags/} -m "${GITHUB_REF#refs/tags/}"
|
||||
git push --quiet origin ${GITHUB_REF#refs/tags/}
|
|
@ -1,130 +0,0 @@
|
|||
# builds the content of https://github.com/rectorphp/rector-prefixed-php70
|
||||
# inspiration from https://github.com/phpstan/phpstan-src/blob/master/.github/workflows/phar.yml
|
||||
name: Build Scoped Rector PHP 7.0
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
|
||||
COMPOSER_ROOT_VERSION: "dev-main"
|
||||
|
||||
jobs:
|
||||
build_scoped_rector_php70:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.4
|
||||
coverage: none
|
||||
|
||||
# fixes https://github.com/rectorphp/rector/pull/4559/checks?check_run_id=1359814403, see https://github.com/shivammathur/setup-php#composer-github-oauth
|
||||
env:
|
||||
COMPOSER_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
|
||||
# install only prod dependencies - do not use ramsey, it uses cache including "dev", we want to avoid it here
|
||||
- run: composer install --no-dev --ansi
|
||||
|
||||
- run: wget https://github.com/box-project/box/releases/download/3.12.2/box.phar -N --no-verbose
|
||||
|
||||
# extra content of phpstan.phar to vendor/phpstan/phpstan-extracted
|
||||
- run: php box.phar extract vendor/phpstan/phpstan/phpstan.phar vendor/phpstan/phpstan-extracted
|
||||
|
||||
# "composer remove phpstan/phpstan" original phpstan/phpstan is now duplicated, we don't need it now -required by phpstan extensions, cannot be removed like this
|
||||
|
||||
# to avoid double packing the same code
|
||||
- run: rm -rf vendor/bin/phpstan vendor/phpstan/phpstan/bootstrap.php
|
||||
# the vendor/phpstan/phpstan/bootstrap.php is statically included by composer, so better add empty file
|
||||
- run: echo "<?php " > vendor/phpstan/phpstan/bootstrap.php
|
||||
- run: rm -rf vendor/phpstan/phpstan/phpstan.phar
|
||||
- run: rm -rf phpstan-for-rector.neon
|
||||
|
||||
# 1. copy files to $NESTED_DIRECTORY directory Exclude the scoped/nested directories to prevent rsync from copying in a loop
|
||||
- run: rsync --exclude rector-build-php70 -av * rector-build-php70 --quiet
|
||||
- run: rm -rf rector-build-php70/packages-tests rector-build-php70/rules-tests rector-build-php70/tests
|
||||
|
||||
# this must run
|
||||
- run: bin/rector list --debug
|
||||
|
||||
# 2. downgrade rector
|
||||
- run: sh build/downgrade-rector-php70.sh rector-build-php70
|
||||
|
||||
# 3. prefix classes
|
||||
- run: sh build/build-rector-scoped-php70.sh rector-build-php70 rector-prefixed-downgraded-php70
|
||||
|
||||
# 4. lint the code for PHP 7.0 - this must happen here, as setup-php allows only one PHP version switch: https://github.com/shivammathur/setup-php/issues/434
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.0
|
||||
coverage: none
|
||||
- run: |
|
||||
rm -rf vendor && mkdir -p vendor
|
||||
cp -R rector-prefixed-downgraded-php70/vendor/* vendor/
|
||||
rm -rf php-parallel-lint
|
||||
composer create-project php-parallel-lint/php-parallel-lint php-parallel-lint --ansi
|
||||
|
||||
- run: php-parallel-lint/parallel-lint rector-prefixed-downgraded-php70 --exclude rector-prefixed-downgraded-php70/stubs --exclude rector-prefixed-downgraded-php70/vendor/symfony/error-handler/Resources --exclude rector-prefixed-downgraded-php70/vendor/symfony/http-kernel/Resources --exclude rector-prefixed-downgraded-php70/vendor/rector/rector-nette/tests --exclude rector-prefixed-downgraded-php70/vendor/symfony/polyfill-mbstring/bootstrap80.php --exclude rector-prefixed-downgraded-php70/vendor/tracy/tracy/examples --exclude rector-prefixed-downgraded-php70/vendor/rector/rector-installer/tests --exclude rector-prefixed-downgraded-php70/vendor/symplify/smart-file-system/tests --exclude rector-prefixed-downgraded-php70/vendor/symfony/http-foundation/Session --exclude rector-prefixed-downgraded-php70/vendor/symfony/var-dumper --exclude rector-prefixed-downgraded-php70/vendor/nette/caching --exclude rector-prefixed-downgraded-php70/vendor/rector/rector-nette/src/Rector/LNumber --exclude rector-prefixed-downgraded-php70/vendor/symfony/http-foundation/Test --exclude rector-prefixed-downgraded-php70/vendor/symplify/simple-php-doc-parser/tests --exclude rector-prefixed-downgraded-php70/vendor/tracy/tracy/src/Tracy/Bar/panels/info.panel.phtml --exclude rector-prefixed-downgraded-php70/vendor/symfony/string/Slugger/AsciiSlugger.php
|
||||
|
||||
# 5. copy repository meta files
|
||||
- run: |
|
||||
cp -R build/target-repository-php70/. rector-prefixed-downgraded-php70
|
||||
cp -R templates rector-prefixed-downgraded-php70/
|
||||
|
||||
# 6. clone remote repository, so we can push it
|
||||
-
|
||||
uses: "actions/checkout@v2"
|
||||
with:
|
||||
repository: rectorphp/rector-prefixed-php70
|
||||
path: remote-repository-php70
|
||||
token: ${{ secrets.ACCESS_TOKEN }}
|
||||
|
||||
# remove remote files, to avoid piling up dead code in remote repository
|
||||
- run: rm -rf remote-repository-php70/config remote-repository-php70/src remote-repository-php70/rules remote-repository-php70/packages remote-repository-php70/upgrade remote-repository-php70/vendor
|
||||
|
||||
- run: cp -a rector-prefixed-downgraded-php70/. remote-repository-php70
|
||||
|
||||
# 7. setup git
|
||||
-
|
||||
working-directory: remote-repository-php70
|
||||
run: |
|
||||
git config user.email "tomas.vot@gmail.com"
|
||||
git config user.name "Tomas Votruba"
|
||||
|
||||
# commit metadata
|
||||
-
|
||||
name: "Get Git log"
|
||||
id: git-log
|
||||
run: echo ::set-output name=log::$(git log ${{ github.event.before }}..${{ github.event.after }} --reverse --pretty='%H %s' | sed -e 's/^/https:\/\/github.com\/rectorphp\/rector\/commit\//')
|
||||
|
||||
# 8.A publish it to remote repository without tag
|
||||
-
|
||||
name: "Commit Prefixed - main"
|
||||
working-directory: remote-repository-php70
|
||||
if: "!startsWith(github.ref, 'refs/tags/')"
|
||||
run: |
|
||||
git add --all
|
||||
git commit -m "Updated Rector to commit ${{ github.event.after }}" -m "${{ steps.git-log.outputs.log }}"
|
||||
git push --quiet origin main
|
||||
|
||||
# 8.B publish it to remote repository with tag
|
||||
-
|
||||
name: "Commit Prefixed - tag"
|
||||
working-directory: remote-repository-php70
|
||||
if: "startsWith(github.ref, 'refs/tags/')"
|
||||
run: |
|
||||
git add --all
|
||||
git commit -m "Rector ${GITHUB_REF#refs/tags/}" -m "${{ steps.git-log.outputs.log }}"
|
||||
git push --quiet origin main
|
||||
git tag ${GITHUB_REF#refs/tags/} -m "${GITHUB_REF#refs/tags/}"
|
||||
git push --quiet origin ${GITHUB_REF#refs/tags/}
|
|
@ -1,54 +0,0 @@
|
|||
name: Code Analysis
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
|
||||
env:
|
||||
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
|
||||
COMPOSER_ROOT_VERSION: "dev-main"
|
||||
|
||||
jobs:
|
||||
code_analysis:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
actions:
|
||||
-
|
||||
name: 'Composer Validate'
|
||||
run: composer validate --ansi
|
||||
|
||||
-
|
||||
name: 'Validate Max File Length'
|
||||
run: vendor/bin/easy-ci validate-file-length packages rules src tests
|
||||
|
||||
-
|
||||
name: 'PHPStan'
|
||||
run: vendor/bin/phpstan analyse --ansi --error-format symplify
|
||||
|
||||
-
|
||||
name: 'PHPStan for config'
|
||||
run: composer phpstan-config
|
||||
|
||||
# see https://github.com/rectorphp/rector-generator
|
||||
-
|
||||
name: 'Rector Generate From Recipe'
|
||||
run: |
|
||||
bin/rector init-recipe --ansi
|
||||
bin/rector generate --ansi
|
||||
|
||||
name: ${{ matrix.actions.name }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
# see https://github.com/shivammathur/setup-php
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 8.0
|
||||
coverage: none
|
||||
|
||||
- uses: "ramsey/composer-install@v1"
|
||||
|
||||
- run: ${{ matrix.actions.run }}
|
|
@ -1,40 +0,0 @@
|
|||
name: Code Analysis [no dev]
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
|
||||
env:
|
||||
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
|
||||
COMPOSER_ROOT_VERSION: "dev-main"
|
||||
|
||||
jobs:
|
||||
matrix:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
actions:
|
||||
-
|
||||
name: 'Rector List'
|
||||
run: bin/rector list
|
||||
|
||||
-
|
||||
name: 'Show command'
|
||||
run: bin/rector show --ansi
|
||||
|
||||
name: ${{ matrix.actions.name }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
# see https://github.com/shivammathur/setup-php
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.4
|
||||
coverage: none
|
||||
|
||||
# must be removed, as local config is missing dev dependencies
|
||||
- run: rm phpstan-for-rector.neon
|
||||
|
||||
- run: composer install --no-progress --ansi --no-dev
|
||||
|
||||
- run: ${{ matrix.actions.run }}
|
|
@ -1,46 +0,0 @@
|
|||
# builds the content of https://github.com/rectorphp/rector-prefixed
|
||||
# inspiration from https://github.com/phpstan/phpstan-src/blob/master/.github/workflows/phar.yml
|
||||
name: Packages Tests
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
|
||||
COMPOSER_ROOT_VERSION: "dev-main"
|
||||
|
||||
jobs:
|
||||
packages_tests:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
package_name:
|
||||
- rector-nette
|
||||
- rector-symfony
|
||||
- rector-laravel
|
||||
- rector-phpunit
|
||||
- rector-cakephp
|
||||
- rector-doctrine
|
||||
|
||||
steps:
|
||||
-
|
||||
uses: "actions/checkout@v2"
|
||||
with:
|
||||
repository: rectorphp/${{ matrix.package_name }}
|
||||
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 8.0
|
||||
coverage: none
|
||||
|
||||
-
|
||||
run: composer install --ansi
|
||||
|
||||
-
|
||||
run: vendor/bin/phpunit
|
|
@ -0,0 +1,21 @@
|
|||
name: PHP 8 Attributes
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
php8_attributes:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.0'
|
||||
coverage: none
|
||||
|
||||
- run: bin/rector process tests/fixture-php8-attributes --config ci/rector-attributes.php --ansi
|
|
@ -1,25 +0,0 @@
|
|||
name: PHP Linter
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
|
||||
env:
|
||||
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
|
||||
COMPOSER_ROOT_VERSION: "dev-main"
|
||||
|
||||
jobs:
|
||||
php_linter:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 8.0
|
||||
coverage: none
|
||||
|
||||
- run: composer create-project php-parallel-lint/php-parallel-lint php-parallel-lint
|
||||
|
||||
- run: php-parallel-lint/parallel-lint src bin/rector config tests packages rules --colors --exclude rules/psr4/tests/Rector/Namespace_/MultipleClassFileToPsr4ClassesRector/Source --exclude rules/autodiscovery/tests/Rector/FileNode/MoveInterfacesToContractNamespaceDirectoryRector/Expected --exclude packages/node-type-resolver/tests/PerNodeTypeResolver/PropertyFetchTypeResolver/Source --exclude rules/nette-kdyby/tests/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector/Source/ExpectedSomeClassCopyEvent.php --exclude rules/nette-kdyby/tests/Rector/MethodCall/ReplaceMagicPropertyEventWithEventClassRector/Source --exclude rules/type-declaration/tests/Rector/ClassMethod/ParamTypeFromStrictTypedPropertyRector/Source
|
|
@ -0,0 +1,25 @@
|
|||
name: PHP Parser 3
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
php_parser_3:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.1
|
||||
coverage: none
|
||||
|
||||
# wait for deploy to packagist
|
||||
- run: sleep 70
|
||||
|
||||
- run: composer require nikic/php-parser:^3.1 --ansi
|
||||
- run: composer require rector/rector:dev-main --dev --ansi
|
||||
- run: vendor/bin/rector list --ansi
|
|
@ -0,0 +1,64 @@
|
|||
name: Build docker images
|
||||
on:
|
||||
push:
|
||||
# Publish `main` as Docker `latest` image.
|
||||
branches:
|
||||
- main
|
||||
|
||||
# Publish `v1.2.3` tags as releases.
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
|
||||
COMPOSER_ROOT_VERSION: "dev-main"
|
||||
|
||||
jobs:
|
||||
publish_images:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build images
|
||||
run: |
|
||||
DOCKER_TAGS=""
|
||||
|
||||
# Pull tag and branch from github.ref, which is either refs/heads/... or refs/tags/...
|
||||
TAG=$(echo "${{ github.ref }}" | sed -e '/refs\/tags\//!d; s,refs/.*/v\?\(.*\),\1,')
|
||||
BRANCH=$(echo "${{ github.ref }}" | sed -e '/refs\/heads\//!d; s,refs/.*/\(.*\),\1,')
|
||||
|
||||
if [ "main" == "$BRANCH" ]; then
|
||||
DOCKER_TAGS="$DOCKER_TAGS latest"
|
||||
fi
|
||||
|
||||
if [ ! -z "$TAG" ]; then
|
||||
DOCKER_TAGS="$DOCKER_TAGS $TAG"
|
||||
fi
|
||||
|
||||
echo "Image will be tagged with: $DOCKER_TAGS"
|
||||
|
||||
DOCKER_TAG_ARG=""
|
||||
for ARG in $DOCKER_TAGS; do
|
||||
DOCKER_TAG_ARG="$DOCKER_TAG_ARG --tag rector/rector:$ARG"
|
||||
done
|
||||
|
||||
docker buildx create --name builder-php8 --use
|
||||
docker buildx build \
|
||||
--progress plain \
|
||||
--cache-from=rector/rector:build-cache-php8 \
|
||||
--cache-to=type=registry,ref=rector/rector:build-cache-php8,mode=max,push=true \
|
||||
--target rector \
|
||||
--push \
|
||||
$DOCKER_TAG_ARG \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--build-arg PHP_VERSION=8 .
|
|
@ -1,74 +0,0 @@
|
|||
####
|
||||
# Due to some Github Actions limitations, we are running realtime fixes (commits) only for self-owned-pr
|
||||
#
|
||||
# Current limitations:
|
||||
# - Secrets (ACCESS_TOKEN) are not available in PRs from forks
|
||||
# - Github Token has Read-only access (can not commit), Personal Access Token must be used instead
|
||||
# - Github Token does not trigger workflows after push
|
||||
#
|
||||
# So we basically have chicken-egg problem here
|
||||
#
|
||||
# https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token
|
||||
####
|
||||
name: Rector
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
|
||||
env:
|
||||
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
|
||||
COMPOSER_ROOT_VERSION: "dev-main"
|
||||
|
||||
jobs:
|
||||
rector:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
directories:
|
||||
- src tests rules-tests packages packages-tests
|
||||
- rules
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# workaround for missing secret in fork PRs - see https://github.com/actions/checkout/issues/298
|
||||
# see https://github.com/rectorphp/rector/commit/d395e1c28b8e6a56711dcc2e10490a82965850e4
|
||||
-
|
||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# Must be used to trigger workflow after push
|
||||
token: ${{ secrets.ACCESS_TOKEN }}
|
||||
|
||||
# in forks, the token is not available - so we cannot us eit
|
||||
-
|
||||
if: github.event.pull_request.head.repo.full_name != github.repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
# PHP 7.3 is required, so Rector's code is PHP 7.3 compatible even after refactoring
|
||||
php-version: 8.0
|
||||
coverage: none
|
||||
|
||||
- run: composer install --no-progress --ansi
|
||||
|
||||
## First run Rector - here can't be --dry-run !!! it would stop the job with it and not commit anything in the future
|
||||
- run: bin/rector process ${{ matrix.directories }} --ansi --no-progress-bar
|
||||
|
||||
- run: vendor/bin/ecs check --match-git-diff --fix --ansi
|
||||
|
||||
# see https://github.com/EndBug/add-and-commit
|
||||
-
|
||||
# commit only to core contributors who have repository access
|
||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||
uses: EndBug/add-and-commit@v7.2.0
|
||||
with:
|
||||
# The arguments for the `git add` command (see the paragraph below for more info)
|
||||
add: .
|
||||
message: "[ci-review] Rector Rectify"
|
||||
author_name: "kaizen-ci"
|
||||
author_email: "info@kaizen-ci.org"
|
||||
env:
|
||||
# to get push access
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
|
@ -0,0 +1,60 @@
|
|||
name: Rector Run
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
rector_run:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php_version: ['7.1', '7.2', '7.3', '7.4', '8.0']
|
||||
commands:
|
||||
-
|
||||
name: 'Finalize Entity'
|
||||
install: composer require doctrine/orm
|
||||
run: vendor/bin/rector process ../tests/fixture-finalize --config ../ci/rector-finalize.php --ansi
|
||||
|
||||
-
|
||||
name: 'Composer Dependency'
|
||||
install: composer require symfony/console 2.8
|
||||
run: vendor/bin/rector list --debug --ansi
|
||||
|
||||
-
|
||||
name: 'Along PHPStan'
|
||||
install: composer require phpstan/phpstan:0.12.85 --dev --ansi
|
||||
run: |
|
||||
vendor/bin/rector list --ansi
|
||||
vendor/bin/phpstan -h --ansi
|
||||
|
||||
name: "PHP ${{ matrix.php_version }}"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php_version }}
|
||||
coverage: none
|
||||
|
||||
- run: |
|
||||
mkdir standalone
|
||||
cd standalone
|
||||
# wait for deploy to packagist
|
||||
sleep 70
|
||||
|
||||
- run: |
|
||||
cd standalone
|
||||
# run
|
||||
composer require rector/rector:dev-main --dev --ansi
|
||||
${{ matrix.commands.install }}
|
||||
|
||||
-
|
||||
run: |
|
||||
cd standalone
|
||||
${{ matrix.commands.run }}
|
|
@ -0,0 +1,37 @@
|
|||
name: Standalone Rule Test
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
standalone_rule_test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
actions:
|
||||
-
|
||||
name: 'Rector Prefixed'
|
||||
run: composer require rector/rector:dev-main --dev
|
||||
|
||||
steps:
|
||||
# see https://github.com/rectorphp/rector-prefixed-rule-test
|
||||
-
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: rectorphp/rector-prefixed-rule-test
|
||||
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '7.3'
|
||||
coverage: none
|
||||
|
||||
- uses: "ramsey/composer-install@v1"
|
||||
|
||||
- run: ${{ matrix.actions.run }}
|
||||
|
||||
- run: vendor/bin/phpunit
|
|
@ -1,34 +0,0 @@
|
|||
name: Tests
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
|
||||
env:
|
||||
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
|
||||
COMPOSER_ROOT_VERSION: "dev-main"
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php: ['7.3', '7.4', '8.0']
|
||||
path:
|
||||
- tests
|
||||
- rules-tests
|
||||
- packages-tests
|
||||
|
||||
name: PHP ${{ matrix.php }} tests for ${{ matrix.path }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
coverage: none
|
||||
|
||||
- uses: "ramsey/composer-install@v1"
|
||||
|
||||
- run: vendor/bin/phpunit ${{ matrix.path }}
|
|
@ -1,58 +0,0 @@
|
|||
name: Weekly Pull Requests
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# https://crontab.guru/once-a-week
|
||||
- cron: "0 0 * * 0"
|
||||
|
||||
env:
|
||||
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
|
||||
COMPOSER_ROOT_VERSION: "dev-main"
|
||||
|
||||
jobs:
|
||||
weekly_pull_requests:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
actions:
|
||||
-
|
||||
name: "Re-Generate Nodes/Rectors Documentation"
|
||||
run: "composer docs"
|
||||
branch: 'automated-regenerated-nodes-rectors-documentation'
|
||||
|
||||
-
|
||||
name: 'Apply Coding Standard'
|
||||
run: "composer fix-cs"
|
||||
branch: 'automated-apply-coding-standards'
|
||||
|
||||
name: ${{ matrix.actions.name }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
-
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
token: ${{ secrets.ACCESS_TOKEN }}
|
||||
|
||||
# see https://github.com/shivammathur/setup-php
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.4
|
||||
coverage: none
|
||||
|
||||
- uses: "ramsey/composer-install@v1"
|
||||
|
||||
- run: ${{ matrix.actions.run }}
|
||||
|
||||
# see https://github.com/peter-evans/create-pull-request
|
||||
-
|
||||
name: Create pull-request
|
||||
uses: peter-evans/create-pull-request@v3
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: "[automated] ${{ matrix.actions.name }}"
|
||||
base: 'main'
|
||||
branch: ${{ matrix.actions.branch }}
|
||||
title: '[automated] ${{ matrix.actions.name }}'
|
||||
delete-branch: true
|
|
@ -0,0 +1,58 @@
|
|||
ARG PHP_VERSION=8.0
|
||||
FROM php:${PHP_VERSION}-cli as base
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libzip4 \
|
||||
libicu63 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
FROM base as build
|
||||
|
||||
WORKDIR /rector
|
||||
|
||||
# Install php extensions
|
||||
RUN apt-get update && apt-get install -y \
|
||||
g++ \
|
||||
git \
|
||||
libicu-dev \
|
||||
libzip-dev \
|
||||
unzip \
|
||||
wget \
|
||||
zip \
|
||||
&& pecl -q install \
|
||||
zip \
|
||||
&& docker-php-ext-configure intl \
|
||||
&& docker-php-ext-configure opcache --enable-opcache \
|
||||
&& docker-php-ext-install \
|
||||
intl \
|
||||
opcache \
|
||||
zip
|
||||
|
||||
# Add source
|
||||
COPY . .
|
||||
|
||||
# Build runtime image
|
||||
FROM base as rector
|
||||
|
||||
COPY --from=build /usr/local/lib/php /usr/local/lib/php
|
||||
COPY --from=build /usr/local/etc/php /usr/local/etc/php
|
||||
COPY .docker/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
|
||||
|
||||
ENV PATH /rector/bin:$PATH
|
||||
|
||||
# Add source
|
||||
COPY . /rector
|
||||
|
||||
ENTRYPOINT [ "rector" ]
|
||||
|
||||
VOLUME ["/project"]
|
||||
WORKDIR "/project"
|
||||
|
||||
RUN mkdir -p /tmp/opcache
|
||||
|
||||
RUN chmod +x /rector/bin/rector
|
||||
RUN /rector/bin/rector list
|
||||
|
||||
RUN mkdir -p /tmp/opcache \
|
||||
&& /rector/bin/rector list \
|
||||
&& chmod 777 -R /tmp
|
211
README.md
211
README.md
|
@ -1,88 +1,11 @@
|
|||
# Rector - Speedup Your PHP Development
|
||||
# Prefixed Rector
|
||||
|
||||
[![Downloads](https://img.shields.io/packagist/dt/rector/rector.svg?style=flat-square)](https://packagist.org/packages/rector/rector)
|
||||
[![Build Status Github Actions](https://img.shields.io/github/workflow/status/rectorphp/rector-prefixed/Code_Checks?style=flat-square)](https://github.com/rectorphp/rector-prefixed/actions)
|
||||
[![Downloads](https://img.shields.io/packagist/dt/rector/rector.svg?style=flat-square)](https://packagist.org/packages/rector/rector-prefixed)
|
||||
|
||||
<br>
|
||||
Do you have conflicts on Rector install? You're in the right place. Prefixed Rector can [be installed even on very old Symfony](https://getrector.org/blog/2020/01/20/how-to-install-rector-despite-composer-conflicts).
|
||||
|
||||
Rector helps you with 2 areas - major code changes and in daily work.
|
||||
|
||||
- Do you have a legacy code base? Do you want to have that latest version of PHP or your favorite framework?
|
||||
→ **Rector gets you there with instant upgrade**.
|
||||
|
||||
<br>
|
||||
|
||||
- Do you have code quality you need, but struggle to keep it with new developers in your team? Do you wish to have code-reviews for each member of your team, but don't have time for it?
|
||||
→ **Add Rector to you CI and let it fix your code for you. Get [instant feedback](https://tomasvotruba.com/blog/2020/01/13/why-is-first-instant-feedback-crucial-to-developers/) after each commit.**
|
||||
|
||||
<br>
|
||||
|
||||
It's a tool that [we develop](https://getrector.org/) and share for free, so anyone can automate their refactoring.
|
||||
|
||||
[Hire us](https://getrector.org/contact) to speed up learning Rector, AST and nodes, to educate your team about Rectors benefits and to setup Rector in your project, so that you can enjoy the 300 % development speed :+1:
|
||||
|
||||
<br>
|
||||
|
||||
## Open-Source First
|
||||
|
||||
Rector **instantly upgrades and refactors the PHP code of your application**.
|
||||
It supports all versions of PHP from 5.3 and major open-source projects:
|
||||
|
||||
<br>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/php.png">
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" width=30>
|
||||
<a href="https://github.com/rectorphp/rector-phpunit"><img src="https://github.com/rectorphp/rector/blob/main/docs/images/phpunit.png"></a>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" width=30>
|
||||
<a href="https://github.com/rectorphp/rector-symfony"><img src="https://github.com/rectorphp/rector/blob/main/docs/images/symfony.png"></a>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" width=30>
|
||||
<a href="https://github.com/palantirnet/drupal-rector">
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/drupal.png" alt="Drupal Rector rules">
|
||||
</a>
|
||||
<br>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" height=15>
|
||||
<br>
|
||||
<a href="https://github.com/rectorphp/rector-cakephp"><img src="https://github.com/rectorphp/rector/blob/main/docs/images/cakephp.png"></a>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" width=30>
|
||||
<a href="https://github.com/sabbelasichon/typo3-rector">
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/typo3.png">
|
||||
</a>
|
||||
<br>
|
||||
<img src="https://github.com/rectorphp/rector/blob/main/docs/images/space.png" height=15>
|
||||
</p>
|
||||
|
||||
### What Can Rector Do for You?
|
||||
|
||||
- [Complete 2800 `@var` types in 2 minutes](https://tomasvotruba.com/blog/2019/07/29/how-we-completed-thousands-of-missing-var-annotations-in-a-day/)
|
||||
- [Upgrade 30 000 unit tests from PHPUnit 6 to 9](https://twitter.com/LBajsarowicz/status/1272947900016967683)
|
||||
- [Complete PHP 7.4 Property Types](https://tomasvotruba.com/blog/2018/11/15/how-to-get-php-74-typed-properties-to-your-code-in-few-seconds/)
|
||||
- [Migrate from Nette to Symfony](https://tomasvotruba.com/blog/2019/02/21/how-we-migrated-from-nette-to-symfony-in-3-weeks-part-1/)
|
||||
- [Refactor Laravel Facades to Dependency Injection](https://tomasvotruba.com/blog/2019/03/04/how-to-turn-laravel-from-static-to-dependency-injection-in-one-day/)
|
||||
- And much more...
|
||||
|
||||
<br>
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Explore 450+ Rector Rules](/docs/rector_rules_overview.md)
|
||||
- [How Does Rector Work?](/docs/how_it_works.md)
|
||||
- [PHP Parser Nodes](https://github.com/rectorphp/php-parser-nodes-docs/)
|
||||
|
||||
### Advanced
|
||||
|
||||
- [Auto Import Names](/docs/auto_import_names.md)
|
||||
- [How to Ignore Rule or Paths](/docs/how_to_ignore_rule_or_paths.md)
|
||||
- [Static Reflection and Autoload](/docs/static_reflection_and_autoload.md)
|
||||
- [How to Configure Rule](/docs/how_to_configure_rules.md)
|
||||
- [How to Generate Configuration file](/docs/init_command.md)
|
||||
|
||||
### Contributing
|
||||
|
||||
- [How to add Test for Rector Rule](/docs/how_to_add_test_for_rector_rule.md)
|
||||
- [How to work with Doc Block and Comments](/docs/how_to_work_with_doc_block_and_comments.md)
|
||||
- [How to Create New Rector Rule](/docs/create_own_rule.md)
|
||||
|
||||
<br>
|
||||
Do you have older PHP? Rector prefixed goes down to PHP 7.1, so you can install it even on older projects.
|
||||
|
||||
## Install
|
||||
|
||||
|
@ -90,131 +13,13 @@ It supports all versions of PHP from 5.3 and major open-source projects:
|
|||
composer require rector/rector --dev
|
||||
```
|
||||
|
||||
- Having conflicts during `composer require`? → Use the [Rector Prefixed](https://github.com/rectorphp/rector-prefixed) with PHP 7.1+ version
|
||||
- Using a different PHP version than Rector supports? → Use the [Docker image](/docs/how_to_run_rector_in_docker.md)
|
||||
|
||||
<br>
|
||||
|
||||
## Running Rector
|
||||
|
||||
There a 2 main ways to use Rector:
|
||||
|
||||
- a *single rule*, to have the change under control
|
||||
- or group of rules called *sets*
|
||||
|
||||
To use them, create a `rector.php` in your root directory:
|
||||
|
||||
```bash
|
||||
# generate "rector.php" config
|
||||
vendor/bin/rector init
|
||||
```
|
||||
|
||||
And modify it:
|
||||
|
||||
```php
|
||||
// rector.php
|
||||
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
||||
use Rector\Set\ValueObject\SetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
// here we can define, what sets of rules will be applied
|
||||
// tip: use "SetList" class to autocomplete sets
|
||||
$containerConfigurator->import(SetList::CODE_QUALITY);
|
||||
|
||||
// register single rule
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(TypedPropertyRector::class);
|
||||
};
|
||||
```
|
||||
|
||||
Then dry run Rector:
|
||||
|
||||
```bash
|
||||
# dry run
|
||||
vendor/bin/rector process src --dry-run
|
||||
```
|
||||
|
||||
Rector will show you diff of files that it *would* change. To *make* the changes, drop `--dry-run`:
|
||||
|
||||
```bash
|
||||
# changing run
|
||||
vendor/bin/rector process src
|
||||
```
|
||||
|
||||
*Note: `rector.php` is loaded by default. For different location, use `--config` option.*
|
||||
|
||||
<br>
|
||||
|
||||
## Configuration
|
||||
|
||||
```php
|
||||
// rector.php
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
// paths to refactor; solid alternative to CLI arguments
|
||||
$parameters->set(Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests']);
|
||||
|
||||
// is your PHP version different from the one your refactor to? [default: your PHP version], uses PHP_VERSION_ID format
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_72);
|
||||
|
||||
// Run Rector only on changed files
|
||||
$parameters->set(Option::ENABLE_CACHE, true);
|
||||
|
||||
// Path to phpstan with extensions, that PHPSTan in Rector uses to determine types
|
||||
$parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, getcwd() . '/phpstan-for-config.neon');
|
||||
};
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## How to Contribute
|
||||
|
||||
See [the contribution guide](/CONTRIBUTING.md).
|
||||
|
||||
<br>
|
||||
|
||||
### Debugging
|
||||
|
||||
You can use `--debug` option, that will print nested exceptions output:
|
||||
|
||||
```bash
|
||||
vendor/bin/rector process src/Controller --dry-run --debug
|
||||
```
|
||||
|
||||
Or with Xdebug:
|
||||
|
||||
1. Make sure [Xdebug](https://xdebug.org/) is installed and configured
|
||||
2. Add `--xdebug` option when running Rector
|
||||
|
||||
```bash
|
||||
vendor/bin/rector process src/Controller --dry-run --xdebug
|
||||
```
|
||||
|
||||
To assist with simple debugging Rector provides a 2 helpers to pretty-print AST-nodes:
|
||||
|
||||
```php
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
|
||||
$node = new String_('hello world!');
|
||||
|
||||
// prints node to string, as PHP code displays it
|
||||
print_node($node);
|
||||
|
||||
// dump nested node object with nested properties
|
||||
dump_node($node);
|
||||
// 2nd argument is how deep the nesting is - this makes sure the dump is short and useful
|
||||
dump_node($node, 1);
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## Known Drawbacks
|
||||
|
||||
### How to Apply Coding Standards?
|
||||
|
||||
Rector uses [nikic/php-parser](https://github.com/nikic/PHP-Parser/), built on technology called an *abstract syntax tree* (AST). An AST doesn't know about spaces and when written to a file it produces poorly formatted code in both PHP and docblock annotations. **That's why your project needs to have a coding standard tool** and a set of formatting rules, so it can make Rector's output code nice and shiny again.
|
||||
|
||||
We're using [ECS](https://github.com/symplify/easy-coding-standard) with [this setup](ecs.php).
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
<?php
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
require_once __DIR__ . '/rector.php';
|
||||
|
|
105
bin/rector.php
105
bin/rector.php
|
@ -1,145 +1,114 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Core\Bootstrap\RectorConfigsResolver;
|
||||
use Rector\Core\Console\ConsoleApplication;
|
||||
use Rector\Core\Console\Style\SymfonyStyleFactory;
|
||||
use Rector\Core\DependencyInjection\RectorContainerFactory;
|
||||
use Rector\Core\HttpKernel\RectorKernel;
|
||||
use Symplify\PackageBuilder\Console\ShellCode;
|
||||
use Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
|
||||
use RectorPrefix20210509\Symplify\PackageBuilder\Console\ShellCode;
|
||||
use RectorPrefix20210509\Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
// @ intentionally: continue anyway
|
||||
@ini_set('memory_limit', '-1');
|
||||
|
||||
@\ini_set('memory_limit', '-1');
|
||||
// Performance boost
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 'stderr');
|
||||
gc_disable();
|
||||
|
||||
define('__RECTOR_RUNNING__', true);
|
||||
|
||||
|
||||
\error_reporting(\E_ALL);
|
||||
\ini_set('display_errors', 'stderr');
|
||||
\gc_disable();
|
||||
\define('__RECTOR_RUNNING__', \true);
|
||||
// Require Composer autoload.php
|
||||
$autoloadIncluder = new AutoloadIncluder();
|
||||
$autoloadIncluder = new \RectorPrefix20210509\AutoloadIncluder();
|
||||
$autoloadIncluder->includeDependencyOrRepositoryVendorAutoloadIfExists();
|
||||
|
||||
|
||||
// load extracted PHPStan with its own preload.php
|
||||
$extractedPhpstanAutoload = __DIR__ . '/../vendor/phpstan/phpstan-extracted/vendor/autoload.php';
|
||||
if (file_exists($extractedPhpstanAutoload)) {
|
||||
if (\file_exists($extractedPhpstanAutoload)) {
|
||||
require_once $extractedPhpstanAutoload;
|
||||
} elseif (should_include_preload()) {
|
||||
} elseif (\RectorPrefix20210509\should_include_preload()) {
|
||||
require_once __DIR__ . '/../preload.php';
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../src/constants.php';
|
||||
|
||||
$autoloadIncluder->loadIfExistsAndNotLoadedYet(__DIR__ . '/../vendor/scoper-autoload.php');
|
||||
|
||||
$autoloadIncluder->autoloadProjectAutoloaderFile();
|
||||
$autoloadIncluder->autoloadFromCommandLine();
|
||||
|
||||
$symfonyStyleFactory = new SymfonyStyleFactory(new PrivatesCaller());
|
||||
$symfonyStyleFactory = new \Rector\Core\Console\Style\SymfonyStyleFactory(new \RectorPrefix20210509\Symplify\PackageBuilder\Reflection\PrivatesCaller());
|
||||
$symfonyStyle = $symfonyStyleFactory->create();
|
||||
|
||||
$rectorConfigsResolver = new RectorConfigsResolver();
|
||||
|
||||
$rectorConfigsResolver = new \Rector\Core\Bootstrap\RectorConfigsResolver();
|
||||
try {
|
||||
$bootstrapConfigs = $rectorConfigsResolver->provide();
|
||||
$rectorContainerFactory = new RectorContainerFactory();
|
||||
$rectorContainerFactory = new \Rector\Core\DependencyInjection\RectorContainerFactory();
|
||||
$container = $rectorContainerFactory->createFromBootstrapConfigs($bootstrapConfigs);
|
||||
} catch (Throwable $throwable) {
|
||||
} catch (\Throwable $throwable) {
|
||||
$symfonyStyle->error($throwable->getMessage());
|
||||
exit(ShellCode::ERROR);
|
||||
exit(\RectorPrefix20210509\Symplify\PackageBuilder\Console\ShellCode::ERROR);
|
||||
}
|
||||
|
||||
|
||||
// preload local InstalledVersions.php - to fix incorrect version by same-named class in phpstan
|
||||
$currentlyInstalledVersions = __DIR__ . '/../../../../vendor/composer/InstalledVersions.php';
|
||||
if (file_exists($currentlyInstalledVersions)) {
|
||||
if (\file_exists($currentlyInstalledVersions)) {
|
||||
require_once $currentlyInstalledVersions;
|
||||
}
|
||||
|
||||
|
||||
/** @var ConsoleApplication $application */
|
||||
$application = $container->get(ConsoleApplication::class);
|
||||
$application = $container->get(\Rector\Core\Console\ConsoleApplication::class);
|
||||
exit($application->run());
|
||||
|
||||
final class AutoloadIncluder
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $alreadyLoadedAutoloadFiles = [];
|
||||
|
||||
public function includeDependencyOrRepositoryVendorAutoloadIfExists(): void
|
||||
public function includeDependencyOrRepositoryVendorAutoloadIfExists() : void
|
||||
{
|
||||
// Rector's vendor is already loaded
|
||||
if (class_exists(RectorKernel::class)) {
|
||||
if (\class_exists(\Rector\Core\HttpKernel\RectorKernel::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// in Rector develop repository
|
||||
$this->loadIfExistsAndNotLoadedYet(__DIR__ . '/../vendor/autoload.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* In case Rector is installed as vendor dependency,
|
||||
* this autoloads the project vendor/autoload.php, including Rector
|
||||
*/
|
||||
public function autoloadProjectAutoloaderFile(): void
|
||||
public function autoloadProjectAutoloaderFile() : void
|
||||
{
|
||||
$this->loadIfExistsAndNotLoadedYet(__DIR__ . '/../../../autoload.php');
|
||||
}
|
||||
|
||||
public function autoloadFromCommandLine(): void
|
||||
public function autoloadFromCommandLine() : void
|
||||
{
|
||||
$cliArgs = $_SERVER['argv'];
|
||||
|
||||
$autoloadOptionPosition = array_search('-a', $cliArgs, true) ?: array_search('--autoload-file', $cliArgs, true);
|
||||
if (! $autoloadOptionPosition) {
|
||||
$autoloadOptionPosition = \array_search('-a', $cliArgs, \true) ?: \array_search('--autoload-file', $cliArgs, \true);
|
||||
if (!$autoloadOptionPosition) {
|
||||
return;
|
||||
}
|
||||
|
||||
$autoloadFileValuePosition = $autoloadOptionPosition + 1;
|
||||
$fileToAutoload = $cliArgs[$autoloadFileValuePosition] ?? null;
|
||||
if ($fileToAutoload === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->loadIfExistsAndNotLoadedYet($fileToAutoload);
|
||||
}
|
||||
|
||||
public function loadIfExistsAndNotLoadedYet(string $filePath): void
|
||||
public function loadIfExistsAndNotLoadedYet(string $filePath) : void
|
||||
{
|
||||
if (! file_exists($filePath)) {
|
||||
if (!\file_exists($filePath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (in_array($filePath, $this->alreadyLoadedAutoloadFiles, true)) {
|
||||
if (\in_array($filePath, $this->alreadyLoadedAutoloadFiles, \true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->alreadyLoadedAutoloadFiles[] = realpath($filePath);
|
||||
|
||||
$this->alreadyLoadedAutoloadFiles[] = \realpath($filePath);
|
||||
require_once $filePath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
\class_alias('RectorPrefix20210509\\AutoloadIncluder', 'AutoloadIncluder', \false);
|
||||
// load local php-parser only in prefixed version or development repository
|
||||
function should_include_preload(): bool
|
||||
function should_include_preload() : bool
|
||||
{
|
||||
if (file_exists(__DIR__ . '/../vendor/scoper-autoload.php')) {
|
||||
return true;
|
||||
if (\file_exists(__DIR__ . '/../vendor/scoper-autoload.php')) {
|
||||
return \true;
|
||||
}
|
||||
|
||||
if (! file_exists(getcwd() . '/composer.json')) {
|
||||
return false;
|
||||
if (!\file_exists(\getcwd() . '/composer.json')) {
|
||||
return \false;
|
||||
}
|
||||
|
||||
$composerJsonFileContent = file_get_contents(getcwd() . '/composer.json');
|
||||
return strpos($composerJsonFileContent, '"name": "rector/rector"') !== false;
|
||||
$composerJsonFileContent = \file_get_contents(\getcwd() . '/composer.json');
|
||||
return \strpos($composerJsonFileContent, '"name": "rector/rector"') !== \false;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
// inspired by https://github.com/phpstan/phpstan/blob/master/bootstrap.php
|
||||
|
||||
spl_autoload_register(function (string $class): void {
|
||||
static $composerAutoloader;
|
||||
|
||||
// already loaded in bin/rector.php
|
||||
if (defined('__RECTOR_RUNNING__')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// load prefixed or native class, e.g. for running tests
|
||||
if (strpos($class, 'RectorPrefix') === 0 || strpos($class, 'Rector\\') === 0) {
|
||||
if ($composerAutoloader === null) {
|
||||
// prefixed version autoload
|
||||
$composerAutoloader = require __DIR__ . '/vendor/autoload.php';
|
||||
}
|
||||
$composerAutoloader->loadClass($class);
|
||||
}
|
||||
|
||||
// aliased by php-scoper, that's why its missing
|
||||
if ($class === 'Symplify\SmartFileSystem\SmartFileInfo') {
|
||||
$filePath = __DIR__ . '/vendor/symplify/smart-file-system/src/SmartFileInfo.php';
|
||||
if (file_exists($filePath)) {
|
||||
require $filePath;
|
||||
}
|
||||
}
|
||||
});
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\Symfony\Set\SymfonySetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
// route class must exist and be loaded, as annotation parser uses dynamic reflection
|
||||
require_once __DIR__ . '/../stubs/Symfony/Component/Routing/Annotation/Route.php';
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$containerConfigurator->import(SymfonySetList::SYMFONY_52);
|
||||
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80);
|
||||
};
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(FinalizeClassesWithoutChildrenRector::class);
|
||||
};
|
128
composer.json
128
composer.json
|
@ -1,138 +1,26 @@
|
|||
{
|
||||
"name": "rector/rector",
|
||||
"description": "Instant upgrade and refactoring of your PHP code",
|
||||
"description": "Prefixed and PHP 7.1 downgraded version of rector/rector",
|
||||
"license": "MIT",
|
||||
"bin": [
|
||||
"bin/rector"
|
||||
],
|
||||
"license": "MIT",
|
||||
"homepage": "https://getrector.org",
|
||||
"require": {
|
||||
"php": "^7.3|^8.0",
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"composer/semver": "^3.2",
|
||||
"composer/xdebug-handler": "^1.3|^2.0",
|
||||
"danielstjules/stringy": "^3.1",
|
||||
"doctrine/inflector": "^2.0",
|
||||
"ergebnis/json-printer": "^3.1",
|
||||
"idiosyncratic/editorconfig": "^0.1.0",
|
||||
"jean85/pretty-package-versions": "^1.6",
|
||||
"nette/caching": "^3.1",
|
||||
"nette/utils": "^3.2",
|
||||
"nikic/php-parser": "4.10.4",
|
||||
"phpstan/phpdoc-parser": "^0.5.4",
|
||||
"phpstan/phpstan": "0.12.85",
|
||||
"phpstan/phpstan-phpunit": "^0.12.18",
|
||||
"rector/rector-cakephp": "^0.10.4",
|
||||
"rector/rector-doctrine": "^0.10.6",
|
||||
"rector/extension-installer": "^0.10.2",
|
||||
"rector/rector-laravel": "^0.10.2",
|
||||
"rector/rector-nette": "^0.10.9",
|
||||
"rector/rector-nette-to-symfony": "^0.10.0",
|
||||
"rector/rector-phpunit": "^0.10.8",
|
||||
"rector/rector-symfony": "^0.10.5",
|
||||
"sebastian/diff": "^4.0.4",
|
||||
"shanethehat/pretty-xml": "^1.0",
|
||||
"symfony/console": "^4.4.8|^5.1",
|
||||
"symfony/dependency-injection": "^5.1",
|
||||
"symfony/finder": "^4.4.8|^5.1",
|
||||
"symfony/http-kernel": "^4.4.8|^5.1",
|
||||
"symplify/astral": "^9.3",
|
||||
"symplify/autowire-array-parameter": "^9.3",
|
||||
"symplify/console-color-diff": "^9.3",
|
||||
"symplify/package-builder": "^9.3",
|
||||
"symplify/rule-doc-generator-contracts": "^9.3",
|
||||
"symplify/set-config-resolver": "^9.3",
|
||||
"symplify/simple-php-doc-parser": "^9.3",
|
||||
"symplify/skipper": "^9.3",
|
||||
"symplify/smart-file-system": "^9.3",
|
||||
"symplify/symfony-php-config": "^9.3",
|
||||
"tracy/tracy": "^2.8",
|
||||
"webmozart/assert": "^1.10"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/extension-installer": "^1.1",
|
||||
"phpstan/phpstan-nette": "^0.12.16",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"rector/rector-generator": "^0.1.7",
|
||||
"rector/rector-phpstan-rules": "^0.1",
|
||||
"symplify/coding-standard": "^9.3",
|
||||
"symplify/easy-ci": "^9.3",
|
||||
"symplify/easy-coding-standard": "^9.3",
|
||||
"symplify/easy-testing": "^9.3",
|
||||
"symplify/phpstan-extensions": "^9.3",
|
||||
"symplify/phpstan-rules": "^9.3",
|
||||
"symplify/rule-doc-generator": "^9.3"
|
||||
},
|
||||
"replace": {
|
||||
"rector/rector-prefixed": "self.version"
|
||||
"php": "^7.1|^8.0",
|
||||
"phpstan/phpstan": "0.12.85"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Rector\\": ["packages", "rules"],
|
||||
"Rector\\Core\\": "src",
|
||||
"Rector\\Compiler\\": "utils/compiler/src"
|
||||
},
|
||||
"files": [
|
||||
"src/functions/node_helper.php",
|
||||
"src/constants.php"
|
||||
"bootstrap.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Rector\\Tests\\": ["packages-tests", "rules-tests"],
|
||||
"Rector\\Core\\Tests\\": "tests",
|
||||
"Rector\\RuleDocGenerator\\": "utils/rule-doc-generator/src"
|
||||
},
|
||||
"classmap": [
|
||||
"stubs/Annotations",
|
||||
"stubs/Nette",
|
||||
"rules-tests/Autodiscovery/Rector/Class_/MoveServicesBySuffixToDirectoryRector/Expected",
|
||||
"rules-tests/Autodiscovery/Rector/Interface_/MoveInterfacesToContractNamespaceDirectoryRector/Expected",
|
||||
"rules-tests/CodingStyle/Rector/Namespace_/ImportFullyQualifiedNamesRector/Source",
|
||||
"rules-tests/Renaming/Rector/Name/RenameClassRector/Source",
|
||||
"rules-tests/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/Source",
|
||||
"rules-tests/CodingStyle/Rector/Namespace_/ImportFullyQualifiedNamesRector/Source",
|
||||
"rules-tests/Renaming/Rector/Name/RenameClassRector/Source"
|
||||
],
|
||||
"files": [
|
||||
"stubs/Doctrine/Persistence/ObjectManager.php",
|
||||
"stubs/Doctrine/Common/Persistence/ObjectManager.php",
|
||||
"rules-tests/Transform/Rector/FuncCall/FuncCallToMethodCallRector/Source/some_view_function.php",
|
||||
"rules-tests/TypeDeclaration/Rector/FunctionLike/ReturnTypeDeclarationRector/Source/MyBar.php",
|
||||
"rules-tests/TypeDeclaration/Rector/Property/CompleteVarDocTypePropertyRector/Source/EventDispatcher.php"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"complete-check": [
|
||||
"@check-cs",
|
||||
"@phpstan",
|
||||
"@docs",
|
||||
"phpunit"
|
||||
],
|
||||
"check-cs": [
|
||||
"vendor/bin/ecs check --ansi",
|
||||
"vendor/bin/ecs check-markdown README.md --ansi"
|
||||
],
|
||||
"fix-cs": [
|
||||
"vendor/bin/ecs check --fix --ansi",
|
||||
"vendor/bin/ecs check-markdown README.md --fix --ansi"
|
||||
],
|
||||
"phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify",
|
||||
"phpstan-config": "vendor/bin/phpstan analyse config --ansi --error-format symplify",
|
||||
"docs": [
|
||||
"vendor/bin/rule-doc-generator generate packages rules --output-file docs/rector_rules_overview.md --ansi --categorize",
|
||||
"vendor/bin/ecs check-markdown docs/rector_rules_overview.md --ansi --fix"
|
||||
],
|
||||
"rector": "bin/rector process --ansi"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "0.10-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"platform-check": false
|
||||
"conflict": {
|
||||
"phpstan/phpdoc-parser": "<=0.5.3",
|
||||
"phpstan/phpstan": "<=0.12.82"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +1,24 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Core\Bootstrap\ExtensionConfigResolver;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$containerConfigurator->import(__DIR__ . '/services.php');
|
||||
$containerConfigurator->import(__DIR__ . '/services-rules.php');
|
||||
$containerConfigurator->import(__DIR__ . '/services-packages.php');
|
||||
$containerConfigurator->import(__DIR__ . '/parameters.php');
|
||||
|
||||
$extensionConfigResolver = new ExtensionConfigResolver();
|
||||
$extensionConfigResolver = new \Rector\Core\Bootstrap\ExtensionConfigResolver();
|
||||
$extensionConfigFiles = $extensionConfigResolver->provide();
|
||||
foreach ($extensionConfigFiles as $extensionConfigFile) {
|
||||
$containerConfigurator->import($extensionConfigFile->getRealPath());
|
||||
}
|
||||
|
||||
// require only in dev
|
||||
$containerConfigurator->import(__DIR__ . '/../utils/compiler/config/config.php', null, 'not_found');
|
||||
|
||||
// to override extension-loaded config
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, getcwd() . '/phpstan-for-rector.neon');
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHPSTAN_FOR_RECTOR_PATH, \getcwd() . '/phpstan-for-rector.neon');
|
||||
};
|
||||
|
|
|
@ -1,33 +1,28 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\ProjectType;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
// paths and extensions
|
||||
$parameters->set(Option::PATHS, []);
|
||||
$parameters->set(Option::FILE_EXTENSIONS, ['php']);
|
||||
$parameters->set(Option::AUTOLOAD_PATHS, []);
|
||||
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PATHS, []);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::FILE_EXTENSIONS, ['php']);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::AUTOLOAD_PATHS, []);
|
||||
// these files will be executed, useful e.g. for constant definitions
|
||||
$parameters->set(Option::BOOTSTRAP_FILES, []);
|
||||
|
||||
$parameters->set(\Rector\Core\Configuration\Option::BOOTSTRAP_FILES, []);
|
||||
// FQN class importing
|
||||
$parameters->set(Option::AUTO_IMPORT_NAMES, false);
|
||||
$parameters->set(Option::IMPORT_SHORT_CLASSES, true);
|
||||
$parameters->set(Option::IMPORT_DOC_BLOCKS, true);
|
||||
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, null);
|
||||
$parameters->set(Option::PROJECT_TYPE, ProjectType::PROPRIETARY);
|
||||
$parameters->set(Option::NESTED_CHAIN_METHOD_CALL_LIMIT, 30);
|
||||
$parameters->set(Option::SKIP, []);
|
||||
|
||||
$parameters->set(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES, \false);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::IMPORT_SHORT_CLASSES, \true);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::IMPORT_DOC_BLOCKS, \true);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, null);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PROJECT_TYPE, \Rector\Core\ValueObject\ProjectType::PROPRIETARY);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::NESTED_CHAIN_METHOD_CALL_LIMIT, 30);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::SKIP, []);
|
||||
// cache
|
||||
$parameters->set(Option::ENABLE_CACHE, false);
|
||||
$parameters->set(Option::CACHE_DIR, sys_get_temp_dir() . '/rector_cached_files');
|
||||
$parameters->set(\Rector\Core\Configuration\Option::ENABLE_CACHE, \false);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::CACHE_DIR, \sys_get_temp_dir() . '/rector_cached_files');
|
||||
};
|
||||
|
|
|
@ -1,27 +1,20 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$services->defaults()
|
||||
->public()
|
||||
->autowire()
|
||||
->autoconfigure();
|
||||
|
||||
$services->load('Rector\\', __DIR__ . '/../packages')
|
||||
->exclude([
|
||||
__DIR__ . '/../packages/*/{ValueObject,Contract,Exception}',
|
||||
__DIR__ . '/../packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php',
|
||||
__DIR__ . '/../packages/Testing/PHPUnit',
|
||||
__DIR__ . '/../packages/BetterPhpDocParser/PhpDoc',
|
||||
__DIR__ . '/../packages/NodeTypeResolver/NodeVisitor/FileNodeVisitor.php',
|
||||
|
||||
// used in PHPStan
|
||||
__DIR__ . '/../packages/NodeTypeResolver/Reflection/BetterReflection/RectorBetterReflectionSourceLocatorFactory.php',
|
||||
__DIR__ . '/../packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php',
|
||||
]);
|
||||
$services->defaults()->public()->autowire()->autoconfigure();
|
||||
$services->load('Rector\\', __DIR__ . '/../packages')->exclude([
|
||||
__DIR__ . '/../packages/*/{ValueObject,Contract,Exception}',
|
||||
__DIR__ . '/../packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php',
|
||||
__DIR__ . '/../packages/Testing/PHPUnit',
|
||||
__DIR__ . '/../packages/BetterPhpDocParser/PhpDoc',
|
||||
__DIR__ . '/../packages/NodeTypeResolver/NodeVisitor/FileNodeVisitor.php',
|
||||
// used in PHPStan
|
||||
__DIR__ . '/../packages/NodeTypeResolver/Reflection/BetterReflection/RectorBetterReflectionSourceLocatorFactory.php',
|
||||
__DIR__ . '/../packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php',
|
||||
]);
|
||||
};
|
||||
|
|
|
@ -1,26 +1,18 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\PSR4\Composer\PSR4NamespaceMatcher;
|
||||
use Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::TYPES_TO_REMOVE_STATIC_FROM, []);
|
||||
|
||||
$parameters->set(\Rector\Core\Configuration\Option::TYPES_TO_REMOVE_STATIC_FROM, []);
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$services->defaults()
|
||||
->public()
|
||||
->autowire()
|
||||
->autoconfigure();
|
||||
|
||||
$services->defaults()->public()->autowire()->autoconfigure();
|
||||
// psr-4
|
||||
$services->alias(PSR4AutoloadNamespaceMatcherInterface::class, PSR4NamespaceMatcher::class);
|
||||
|
||||
$services->load('Rector\\', __DIR__ . '/../rules')
|
||||
->exclude([__DIR__ . '/../rules/*/{ValueObject,Rector,Contract,Exception}']);
|
||||
$services->alias(\Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface::class, \Rector\PSR4\Composer\PSR4NamespaceMatcher::class);
|
||||
$services->load('Rector\\', __DIR__ . '/../rules')->exclude([__DIR__ . '/../rules/*/{ValueObject,Rector,Contract,Exception}']);
|
||||
};
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Composer\Semver\VersionParser;
|
||||
use Doctrine\Inflector\Inflector;
|
||||
use Doctrine\Inflector\Rules\English\InflectorFactory;
|
||||
use Ergebnis\Json\Printer\Printer;
|
||||
use Ergebnis\Json\Printer\PrinterInterface;
|
||||
use Idiosyncratic\EditorConfig\EditorConfig;
|
||||
use Nette\Caching\Cache;
|
||||
use RectorPrefix20210509\Composer\Semver\VersionParser;
|
||||
use RectorPrefix20210509\Doctrine\Inflector\Inflector;
|
||||
use RectorPrefix20210509\Doctrine\Inflector\Rules\English\InflectorFactory;
|
||||
use RectorPrefix20210509\Ergebnis\Json\Printer\Printer;
|
||||
use RectorPrefix20210509\Ergebnis\Json\Printer\PrinterInterface;
|
||||
use RectorPrefix20210509\Idiosyncratic\EditorConfig\EditorConfig;
|
||||
use RectorPrefix20210509\Nette\Caching\Cache;
|
||||
use PhpParser\BuilderFactory;
|
||||
use PhpParser\Lexer;
|
||||
use PhpParser\NodeFinder;
|
||||
|
@ -24,7 +25,7 @@ use PHPStan\PhpDoc\TypeNodeResolver;
|
|||
use PHPStan\PhpDocParser\Parser\PhpDocParser;
|
||||
use PHPStan\PhpDocParser\Parser\TypeParser;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use PrettyXml\Formatter;
|
||||
use RectorPrefix20210509\PrettyXml\Formatter;
|
||||
use Rector\BetterPhpDocParser\PhpDocParser\BetterPhpDocParser;
|
||||
use Rector\BetterPhpDocParser\PhpDocParser\BetterTypeParser;
|
||||
use Rector\Caching\Cache\NetteCacheFactory;
|
||||
|
@ -36,125 +37,72 @@ use Rector\FileFormatter\EditorConfig\EditorConfigIdiosyncraticParser;
|
|||
use Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory;
|
||||
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator;
|
||||
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider;
|
||||
use Symfony\Component\Console\Application as SymfonyApplication;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
|
||||
use Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
|
||||
use Symplify\PackageBuilder\Console\Command\CommandNaming;
|
||||
use Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory;
|
||||
use Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use Symplify\PackageBuilder\Php\TypeChecker;
|
||||
use Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
use Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
use Symplify\PackageBuilder\Strings\StringFormatConverter;
|
||||
use Symplify\SmartFileSystem\FileSystemFilter;
|
||||
use Symplify\SmartFileSystem\FileSystemGuard;
|
||||
use Symplify\SmartFileSystem\Finder\FinderSanitizer;
|
||||
use Symplify\SmartFileSystem\Json\JsonFileSystem;
|
||||
use Symplify\SmartFileSystem\SmartFileSystem;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\Console\Application as SymfonyApplication;
|
||||
use RectorPrefix20210509\Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use function RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\service;
|
||||
use RectorPrefix20210509\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
|
||||
use RectorPrefix20210509\Symplify\PackageBuilder\Console\Command\CommandNaming;
|
||||
use RectorPrefix20210509\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory;
|
||||
use RectorPrefix20210509\Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use RectorPrefix20210509\Symplify\PackageBuilder\Php\TypeChecker;
|
||||
use RectorPrefix20210509\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
use RectorPrefix20210509\Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
use RectorPrefix20210509\Symplify\PackageBuilder\Strings\StringFormatConverter;
|
||||
use RectorPrefix20210509\Symplify\SmartFileSystem\FileSystemFilter;
|
||||
use RectorPrefix20210509\Symplify\SmartFileSystem\FileSystemGuard;
|
||||
use RectorPrefix20210509\Symplify\SmartFileSystem\Finder\FinderSanitizer;
|
||||
use RectorPrefix20210509\Symplify\SmartFileSystem\Json\JsonFileSystem;
|
||||
use RectorPrefix20210509\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$services->defaults()
|
||||
->public()
|
||||
->autowire()
|
||||
->autoconfigure();
|
||||
|
||||
$services->load('Rector\Core\\', __DIR__ . '/../src')
|
||||
->exclude([
|
||||
__DIR__ . '/../src/Rector',
|
||||
__DIR__ . '/../src/Exception',
|
||||
__DIR__ . '/../src/DependencyInjection/CompilerPass',
|
||||
__DIR__ . '/../src/DependencyInjection/Loader',
|
||||
__DIR__ . '/../src/HttpKernel',
|
||||
__DIR__ . '/../src/ValueObject',
|
||||
__DIR__ . '/../src/Bootstrap',
|
||||
__DIR__ . '/../src/PhpParser/Node/CustomNode',
|
||||
__DIR__ . '/../src/functions',
|
||||
__DIR__ . '/../src/constants.php',
|
||||
]);
|
||||
|
||||
$services->alias(SymfonyApplication::class, ConsoleApplication::class);
|
||||
|
||||
$services->set(FileSystemGuard::class);
|
||||
|
||||
$services->set(SimpleCallableNodeTraverser::class);
|
||||
|
||||
$services->set(ParserFactory::class);
|
||||
$services->set(BuilderFactory::class);
|
||||
$services->set(CloningVisitor::class);
|
||||
$services->set(NodeFinder::class);
|
||||
|
||||
$services->set(Parser::class)
|
||||
->factory([service(NikicPhpParserFactory::class), 'create']);
|
||||
$services->set(Lexer::class)
|
||||
->factory([service(PhpParserLexerFactory::class), 'create']);
|
||||
|
||||
$services->defaults()->public()->autowire()->autoconfigure();
|
||||
$services->load('Rector\\Core\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/Rector', __DIR__ . '/../src/Exception', __DIR__ . '/../src/DependencyInjection/CompilerPass', __DIR__ . '/../src/DependencyInjection/Loader', __DIR__ . '/../src/HttpKernel', __DIR__ . '/../src/ValueObject', __DIR__ . '/../src/Bootstrap', __DIR__ . '/../src/PhpParser/Node/CustomNode', __DIR__ . '/../src/functions', __DIR__ . '/../src/constants.php']);
|
||||
$services->alias(\RectorPrefix20210509\Symfony\Component\Console\Application::class, \Rector\Core\Console\ConsoleApplication::class);
|
||||
$services->set(\RectorPrefix20210509\Symplify\SmartFileSystem\FileSystemGuard::class);
|
||||
$services->set(\RectorPrefix20210509\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser::class);
|
||||
$services->set(\PhpParser\ParserFactory::class);
|
||||
$services->set(\PhpParser\BuilderFactory::class);
|
||||
$services->set(\PhpParser\NodeVisitor\CloningVisitor::class);
|
||||
$services->set(\PhpParser\NodeFinder::class);
|
||||
$services->set(\PhpParser\Parser::class)->factory([\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Core\PhpParser\Parser\NikicPhpParserFactory::class), 'create']);
|
||||
$services->set(\PhpParser\Lexer::class)->factory([\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Core\PhpParser\Parser\PhpParserLexerFactory::class), 'create']);
|
||||
// symplify/package-builder
|
||||
$services->set(PrivatesAccessor::class);
|
||||
$services->set(PrivatesCaller::class);
|
||||
$services->set(FinderSanitizer::class);
|
||||
$services->set(FileSystemFilter::class);
|
||||
|
||||
$services->set(ParameterProvider::class)
|
||||
->arg('$container', service('service_container'));
|
||||
|
||||
$services->set(CommandNaming::class);
|
||||
$services->set(SmartFileSystem::class);
|
||||
|
||||
$services->set(StringFormatConverter::class);
|
||||
|
||||
$services->set(SymfonyStyleFactory::class);
|
||||
$services->set(SymfonyStyle::class)
|
||||
->factory([service(SymfonyStyleFactory::class), 'create']);
|
||||
|
||||
$services->set(JsonFileSystem::class);
|
||||
$services->set(NodeConnectingVisitor::class);
|
||||
|
||||
$services->set(InflectorFactory::class);
|
||||
$services->set(Inflector::class)
|
||||
->factory([service(InflectorFactory::class), 'build']);
|
||||
|
||||
$services->set(VersionParser::class);
|
||||
$services->set(TypeChecker::class);
|
||||
|
||||
$services->set(\RectorPrefix20210509\Symplify\PackageBuilder\Reflection\PrivatesAccessor::class);
|
||||
$services->set(\RectorPrefix20210509\Symplify\PackageBuilder\Reflection\PrivatesCaller::class);
|
||||
$services->set(\RectorPrefix20210509\Symplify\SmartFileSystem\Finder\FinderSanitizer::class);
|
||||
$services->set(\RectorPrefix20210509\Symplify\SmartFileSystem\FileSystemFilter::class);
|
||||
$services->set(\RectorPrefix20210509\Symplify\PackageBuilder\Parameter\ParameterProvider::class)->arg('$container', \RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\service('service_container'));
|
||||
$services->set(\RectorPrefix20210509\Symplify\PackageBuilder\Console\Command\CommandNaming::class);
|
||||
$services->set(\RectorPrefix20210509\Symplify\SmartFileSystem\SmartFileSystem::class);
|
||||
$services->set(\RectorPrefix20210509\Symplify\PackageBuilder\Strings\StringFormatConverter::class);
|
||||
$services->set(\RectorPrefix20210509\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory::class);
|
||||
$services->set(\RectorPrefix20210509\Symfony\Component\Console\Style\SymfonyStyle::class)->factory([\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\service(\RectorPrefix20210509\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory::class), 'create']);
|
||||
$services->set(\RectorPrefix20210509\Symplify\SmartFileSystem\Json\JsonFileSystem::class);
|
||||
$services->set(\PhpParser\NodeVisitor\NodeConnectingVisitor::class);
|
||||
$services->set(\RectorPrefix20210509\Doctrine\Inflector\Rules\English\InflectorFactory::class);
|
||||
$services->set(\RectorPrefix20210509\Doctrine\Inflector\Inflector::class)->factory([\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\service(\RectorPrefix20210509\Doctrine\Inflector\Rules\English\InflectorFactory::class), 'build']);
|
||||
$services->set(\RectorPrefix20210509\Composer\Semver\VersionParser::class);
|
||||
$services->set(\RectorPrefix20210509\Symplify\PackageBuilder\Php\TypeChecker::class);
|
||||
// phpdoc parser
|
||||
$services->set(\PHPStan\PhpDocParser\Lexer\Lexer::class);
|
||||
$services->alias(PhpDocParser::class, BetterPhpDocParser::class);
|
||||
|
||||
$services->alias(\PHPStan\PhpDocParser\Parser\PhpDocParser::class, \Rector\BetterPhpDocParser\PhpDocParser\BetterPhpDocParser::class);
|
||||
// cache
|
||||
$services->set(DependencyResolver::class)
|
||||
->factory([service(PHPStanServicesFactory::class), 'createDependencyResolver']);
|
||||
$services->set(FileHelper::class)
|
||||
->factory([service(PHPStanServicesFactory::class), 'createFileHelper']);
|
||||
|
||||
$services->set(Cache::class)
|
||||
->factory([service(NetteCacheFactory::class), 'create']);
|
||||
|
||||
$services->set(\PHPStan\Dependency\DependencyResolver::class)->factory([\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createDependencyResolver']);
|
||||
$services->set(\PHPStan\File\FileHelper::class)->factory([\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createFileHelper']);
|
||||
$services->set(\RectorPrefix20210509\Nette\Caching\Cache::class)->factory([\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Caching\Cache\NetteCacheFactory::class), 'create']);
|
||||
// type resolving
|
||||
$services->set(IntermediateSourceLocator::class);
|
||||
$services->alias(TypeParser::class, BetterTypeParser::class);
|
||||
|
||||
$services->set(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator::class);
|
||||
$services->alias(\PHPStan\PhpDocParser\Parser\TypeParser::class, \Rector\BetterPhpDocParser\PhpDocParser\BetterTypeParser::class);
|
||||
// PHPStan services
|
||||
$services->set(ReflectionProvider::class)
|
||||
->factory([service(PHPStanServicesFactory::class), 'createReflectionProvider']);
|
||||
$services->set(NodeScopeResolver::class)
|
||||
->factory([service(PHPStanServicesFactory::class), 'createNodeScopeResolver']);
|
||||
$services->set(ScopeFactory::class)
|
||||
->factory([service(PHPStanServicesFactory::class), 'createScopeFactory']);
|
||||
$services->set(TypeNodeResolver::class)
|
||||
->factory([service(PHPStanServicesFactory::class), 'createTypeNodeResolver']);
|
||||
$services->set(DynamicSourceLocatorProvider::class)
|
||||
->factory([service(PHPStanServicesFactory::class), 'createDynamicSourceLocatorProvider']);
|
||||
|
||||
$services->set(Printer::class);
|
||||
$services->alias(PrinterInterface::class, Printer::class);
|
||||
|
||||
$services->set(Formatter::class);
|
||||
|
||||
$services->set(EditorConfig::class);
|
||||
|
||||
$services->alias(EditorConfigParserInterface::class, EditorConfigIdiosyncraticParser::class);
|
||||
$services->set(\PHPStan\Reflection\ReflectionProvider::class)->factory([\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createReflectionProvider']);
|
||||
$services->set(\PHPStan\Analyser\NodeScopeResolver::class)->factory([\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createNodeScopeResolver']);
|
||||
$services->set(\PHPStan\Analyser\ScopeFactory::class)->factory([\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createScopeFactory']);
|
||||
$services->set(\PHPStan\PhpDoc\TypeNodeResolver::class)->factory([\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createTypeNodeResolver']);
|
||||
$services->set(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider::class)->factory([\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createDynamicSourceLocatorProvider']);
|
||||
$services->set(\RectorPrefix20210509\Ergebnis\Json\Printer\Printer::class);
|
||||
$services->alias(\RectorPrefix20210509\Ergebnis\Json\Printer\PrinterInterface::class, \RectorPrefix20210509\Ergebnis\Json\Printer\Printer::class);
|
||||
$services->set(\RectorPrefix20210509\PrettyXml\Formatter::class);
|
||||
$services->set(\RectorPrefix20210509\Idiosyncratic\EditorConfig\EditorConfig::class);
|
||||
$services->alias(\Rector\FileFormatter\Contract\EditorConfig\EditorConfigParserInterface::class, \Rector\FileFormatter\EditorConfig\EditorConfigIdiosyncraticParser::class);
|
||||
};
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector;
|
||||
use Rector\DependencyInjection\Rector\Variable\ReplaceVariableByPropertyFetchRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ActionInjectionToConstructorInjectionRector::class);
|
||||
$services->set(ReplaceVariableByPropertyFetchRector::class);
|
||||
$services->set(\Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector::class);
|
||||
$services->set(\Rector\DependencyInjection\Rector\Variable\ReplaceVariableByPropertyFetchRector::class);
|
||||
};
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Carbon\Rector\MethodCall\ChangeCarbonSingularMethodCallToPluralRector;
|
||||
use Rector\Carbon\Rector\MethodCall\ChangeDiffForHumansArgsRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
# source: https://carbon.nesbot.com/docs/#api-carbon-2
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ChangeDiffForHumansArgsRector::class);
|
||||
$services->set(ChangeCarbonSingularMethodCallToPluralRector::class);
|
||||
$services->set(\Rector\Carbon\Rector\MethodCall\ChangeDiffForHumansArgsRector::class);
|
||||
$services->set(\Rector\Carbon\Rector\MethodCall\ChangeCarbonSingularMethodCallToPluralRector::class);
|
||||
};
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
|
||||
use Rector\CodeQualityStrict\Rector\If_\MoveOutMethodCallInsideIfConditionRector;
|
||||
use Rector\CodeQualityStrict\Rector\Variable\MoveVariableDeclarationNearReferenceRector;
|
||||
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
|
||||
use Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(MoveOutMethodCallInsideIfConditionRector::class);
|
||||
$services->set(CountArrayToEmptyArrayComparisonRector::class);
|
||||
$services->set(MoveVariableDeclarationNearReferenceRector::class);
|
||||
$services->set(UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
$services->set(FlipTypeControlToUseExclusiveTypeRector::class);
|
||||
$services->set(\Rector\CodeQualityStrict\Rector\If_\MoveOutMethodCallInsideIfConditionRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector::class);
|
||||
$services->set(\Rector\CodeQualityStrict\Rector\Variable\MoveVariableDeclarationNearReferenceRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\CodeQuality\Rector\Array_\ArrayThisCallToThisMethodCallRector;
|
||||
use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
|
||||
|
@ -74,107 +75,103 @@ use Rector\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector;
|
|||
use Rector\Php52\Rector\Property\VarToPublicPropertyRector;
|
||||
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(CombinedAssignRector::class);
|
||||
$services->set(SimplifyEmptyArrayCheckRector::class);
|
||||
$services->set(ForeachToInArrayRector::class);
|
||||
$services->set(SimplifyForeachToCoalescingRector::class);
|
||||
$services->set(InArrayAndArrayKeysToArrayKeyExistsRector::class);
|
||||
$services->set(SimplifyFuncGetArgsCountRector::class);
|
||||
$services->set(SimplifyInArrayValuesRector::class);
|
||||
$services->set(SimplifyStrposLowerRector::class);
|
||||
$services->set(GetClassToInstanceOfRector::class);
|
||||
$services->set(SimplifyArraySearchRector::class);
|
||||
$services->set(SimplifyConditionsRector::class);
|
||||
$services->set(SimplifyIfNotNullReturnRector::class);
|
||||
$services->set(SimplifyIfReturnBoolRector::class);
|
||||
$services->set(SimplifyUselessVariableRector::class);
|
||||
$services->set(UnnecessaryTernaryExpressionRector::class);
|
||||
$services->set(RemoveExtraParametersRector::class);
|
||||
$services->set(SimplifyDeMorganBinaryRector::class);
|
||||
$services->set(SimplifyTautologyTernaryRector::class);
|
||||
$services->set(SimplifyForeachToArrayFilterRector::class);
|
||||
$services->set(SingleInArrayToCompareRector::class);
|
||||
$services->set(SimplifyIfElseToTernaryRector::class);
|
||||
$services->set(JoinStringConcatRector::class);
|
||||
$services->set(ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class);
|
||||
$services->set(SimplifyIfIssetToNullCoalescingRector::class);
|
||||
$services->set(ExplicitBoolCompareRector::class);
|
||||
$services->set(CombineIfRector::class);
|
||||
$services->set(UseIdenticalOverEqualWithSameTypeRector::class);
|
||||
$services->set(SimplifyDuplicatedTernaryRector::class);
|
||||
$services->set(SimplifyBoolIdenticalTrueRector::class);
|
||||
$services->set(SimplifyRegexPatternRector::class);
|
||||
$services->set(BooleanNotIdenticalToNotIdenticalRector::class);
|
||||
$services->set(CallableThisArrayToAnonymousFunctionRector::class);
|
||||
$services->set(AndAssignsToSeparateLinesRector::class);
|
||||
$services->set(ForToForeachRector::class);
|
||||
$services->set(CompactToVariablesRector::class);
|
||||
$services->set(CompleteDynamicPropertiesRector::class);
|
||||
$services->set(IsAWithStringWithThirdArgumentRector::class);
|
||||
$services->set(StrlenZeroToIdenticalEmptyStringRector::class);
|
||||
$services->set(RemoveAlwaysTrueConditionSetInConstructorRector::class);
|
||||
$services->set(ThrowWithPreviousExceptionRector::class);
|
||||
$services->set(RemoveSoleValueSprintfRector::class);
|
||||
$services->set(ShortenElseIfRector::class);
|
||||
$services->set(AddPregQuoteDelimiterRector::class);
|
||||
$services->set(ArrayMergeOfNonArraysToSimpleArrayRector::class);
|
||||
$services->set(IntvalToTypeCastRector::class);
|
||||
$services->set(ArrayKeyExistsTernaryThenValueToCoalescingRector::class);
|
||||
$services->set(AbsolutizeRequireAndIncludePathRector::class);
|
||||
$services->set(ChangeArrayPushToArrayAssignRector::class);
|
||||
$services->set(ForRepeatedCountToOwnVariableRector::class);
|
||||
$services->set(ForeachItemsAssignToEmptyArrayToAssignRector::class);
|
||||
$services->set(InlineIfToExplicitIfRector::class);
|
||||
$services->set(ArrayKeysAndInArrayToArrayKeyExistsRector::class);
|
||||
$services->set(SplitListAssignToSeparateLineRector::class);
|
||||
$services->set(UnusedForeachValueToArrayKeysRector::class);
|
||||
$services->set(ArrayThisCallToThisMethodCallRector::class);
|
||||
$services->set(CommonNotEqualRector::class);
|
||||
$services->set(RenameFunctionRector::class)
|
||||
->call('configure', [[
|
||||
RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
'split' => 'explode',
|
||||
'join' => 'implode',
|
||||
'sizeof' => 'count',
|
||||
# https://www.php.net/manual/en/aliases.php
|
||||
'chop' => 'rtrim',
|
||||
'doubleval' => 'floatval',
|
||||
'gzputs' => 'gzwrites',
|
||||
'fputs' => 'fwrite',
|
||||
'ini_alter' => 'ini_set',
|
||||
'is_double' => 'is_float',
|
||||
'is_integer' => 'is_int',
|
||||
'is_long' => 'is_int',
|
||||
'is_real' => 'is_float',
|
||||
'is_writeable' => 'is_writable',
|
||||
'key_exists' => 'array_key_exists',
|
||||
'pos' => 'current',
|
||||
'strchr' => 'strstr',
|
||||
# mb
|
||||
'mbstrcut' => 'mb_strcut',
|
||||
'mbstrlen' => 'mb_strlen',
|
||||
'mbstrpos' => 'mb_strpos',
|
||||
'mbstrrpos' => 'mb_strrpos',
|
||||
'mbsubstr' => 'mb_substr',
|
||||
],
|
||||
]]);
|
||||
$services->set(SetTypeToCastRector::class);
|
||||
$services->set(LogicalToBooleanRector::class);
|
||||
$services->set(VarToPublicPropertyRector::class);
|
||||
$services->set(FixClassCaseSensitivityNameRector::class);
|
||||
$services->set(IssetOnPropertyObjectToPropertyExistsRector::class);
|
||||
$services->set(NewStaticToNewSelfRector::class);
|
||||
$services->set(DateTimeToDateTimeInterfaceRector::class);
|
||||
$services->set(UnwrapSprintfOneArgumentRector::class);
|
||||
$services->set(SwitchNegatedTernaryRector::class);
|
||||
$services->set(SingularSwitchToIfRector::class);
|
||||
$services->set(SimplifyIfNullableReturnRector::class);
|
||||
$services->set(NarrowUnionTypeDocRector::class);
|
||||
$services->set(FuncGetArgsToVariadicParamRector::class);
|
||||
$services->set(CallUserFuncToMethodCallRector::class);
|
||||
$services->set(CallUserFuncWithArrowFunctionToInlineRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Assign\CombinedAssignRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\ForeachToInArrayRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToCoalescingRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\InArrayAndArrayKeysToArrayKeyExistsRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SimplifyFuncGetArgsCountRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SimplifyInArrayValuesRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\GetClassToInstanceOfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\SimplifyArraySearchRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfNotNullReturnRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector::class);
|
||||
$services->set(\Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\SimplifyTautologyTernaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToArrayFilterRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Concat\JoinStringConcatRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfIssetToNullCoalescingRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\CombineIfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\SimplifyDuplicatedTernaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\LogicalAnd\AndAssignsToSeparateLinesRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\For_\ForToForeachRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\IsAWithStringWithThirdArgumentRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\StrlenZeroToIdenticalEmptyStringRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FunctionLike\RemoveAlwaysTrueConditionSetInConstructorRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\RemoveSoleValueSprintfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\ShortenElseIfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\AddPregQuoteDelimiterRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\ArrayMergeOfNonArraysToSimpleArrayRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\IntvalToTypeCastRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\ArrayKeyExistsTernaryThenValueToCoalescingRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Include_\AbsolutizeRequireAndIncludePathRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\ArrayKeysAndInArrayToArrayKeyExistsRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Assign\SplitListAssignToSeparateLineRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Array_\ArrayThisCallToThisMethodCallRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
'split' => 'explode',
|
||||
'join' => 'implode',
|
||||
'sizeof' => 'count',
|
||||
# https://www.php.net/manual/en/aliases.php
|
||||
'chop' => 'rtrim',
|
||||
'doubleval' => 'floatval',
|
||||
'gzputs' => 'gzwrites',
|
||||
'fputs' => 'fwrite',
|
||||
'ini_alter' => 'ini_set',
|
||||
'is_double' => 'is_float',
|
||||
'is_integer' => 'is_int',
|
||||
'is_long' => 'is_int',
|
||||
'is_real' => 'is_float',
|
||||
'is_writeable' => 'is_writable',
|
||||
'key_exists' => 'array_key_exists',
|
||||
'pos' => 'current',
|
||||
'strchr' => 'strstr',
|
||||
# mb
|
||||
'mbstrcut' => 'mb_strcut',
|
||||
'mbstrlen' => 'mb_strlen',
|
||||
'mbstrpos' => 'mb_strpos',
|
||||
'mbstrrpos' => 'mb_strrpos',
|
||||
'mbsubstr' => 'mb_substr',
|
||||
]]]);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SetTypeToCastRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector::class);
|
||||
$services->set(\Rector\Php52\Rector\Property\VarToPublicPropertyRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Name\FixClassCaseSensitivityNameRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\New_\NewStaticToNewSelfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\ClassMethod\DateTimeToDateTimeInterfaceRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\UnwrapSprintfOneArgumentRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Switch_\SingularSwitchToIfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\ClassMethod\NarrowUnionTypeDocRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\CallUserFuncWithArrowFunctionToInlineRector::class);
|
||||
};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\CodingStyle\Rector\Assign\ManualJsonStringToJsonEncodeArrayRector;
|
||||
use Rector\CodingStyle\Rector\Assign\PHPStormVarAnnotationRector;
|
||||
|
@ -33,47 +34,38 @@ use Rector\CodingStyle\Rector\Use_\RemoveUnusedAliasRector;
|
|||
use Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector;
|
||||
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
||||
use Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(PHPStormVarAnnotationRector::class);
|
||||
$services->set(NullableCompareToNullRector::class);
|
||||
$services->set(BinarySwitchToIfElseRector::class);
|
||||
$services->set(ConsistentImplodeRector::class);
|
||||
$services->set(TernaryConditionVariableAssignmentRector::class);
|
||||
$services->set(RemoveUnusedAliasRector::class);
|
||||
$services->set(SymplifyQuoteEscapeRector::class);
|
||||
$services->set(SplitGroupedConstantsAndPropertiesRector::class);
|
||||
$services->set(SplitStringClassConstantToClassConstFetchRector::class);
|
||||
$services->set(StringClassNameToClassConstantRector::class);
|
||||
$services->set(ConsistentPregDelimiterRector::class);
|
||||
$services->set(FollowRequireByDirRector::class);
|
||||
$services->set(CatchExceptionNameMatchingTypeRector::class);
|
||||
$services->set(UseIncrementAssignRector::class);
|
||||
$services->set(SplitDoubleAssignRector::class);
|
||||
$services->set(VarConstantCommentRector::class);
|
||||
$services->set(EncapsedStringsToSprintfRector::class);
|
||||
$services->set(WrapEncapsedVariableInCurlyBracesRector::class);
|
||||
$services->set(NewlineBeforeNewAssignSetRector::class);
|
||||
$services->set(ManualJsonStringToJsonEncodeArrayRector::class);
|
||||
$services->set(AddArrayDefaultToArrayPropertyRector::class);
|
||||
$services->set(AddFalseDefaultToBoolPropertyRector::class);
|
||||
$services->set(MakeInheritedMethodVisibilitySameAsParentRector::class);
|
||||
$services->set(CallUserFuncArrayToVariadicRector::class);
|
||||
$services->set(VersionCompareFuncCallToConstantRector::class);
|
||||
$services->set(UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
|
||||
$services->set(FuncCallToConstFetchRector::class)
|
||||
->call('configure', [[
|
||||
FuncCallToConstFetchRector::FUNCTIONS_TO_CONSTANTS => [
|
||||
'php_sapi_name' => 'PHP_SAPI',
|
||||
'pi' => 'M_PI',
|
||||
],
|
||||
]]);
|
||||
|
||||
$services->set(SeparateMultiUseImportsRector::class);
|
||||
$services->set(RemoveDoubleUnderscoreInMethodNameRector::class);
|
||||
$services->set(PostIncDecToPreIncDecRector::class);
|
||||
$services->set(UnSpreadOperatorRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Assign\PHPStormVarAnnotationRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\If_\NullableCompareToNullRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Use_\RemoveUnusedAliasRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassConst\SplitGroupedConstantsAndPropertiesRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector::class);
|
||||
$services->set(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Include_\FollowRequireByDirRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Assign\ManualJsonStringToJsonEncodeArrayRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
$services->set(\Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector::class)->call('configure', [[\Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector::FUNCTIONS_TO_CONSTANTS => ['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']]]);
|
||||
$services->set(\Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\RemoveDoubleUnderscoreInMethodNameRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector;
|
||||
use Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector;
|
||||
|
@ -46,54 +47,52 @@ use Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector;
|
|||
use Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector;
|
||||
use Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector;
|
||||
use Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(UnwrapFutureCompatibleIfFunctionExistsRector::class);
|
||||
$services->set(UnwrapFutureCompatibleIfPhpVersionRector::class);
|
||||
$services->set(RecastingRemovalRector::class);
|
||||
$services->set(RemoveDeadStmtRector::class);
|
||||
$services->set(RemoveDuplicatedArrayKeyRector::class);
|
||||
$services->set(RemoveUnusedForeachKeyRector::class);
|
||||
$services->set(RemoveParentCallWithoutParentRector::class);
|
||||
$services->set(RemoveEmptyClassMethodRector::class);
|
||||
$services->set(RemoveDoubleAssignRector::class);
|
||||
$services->set(SimplifyMirrorAssignRector::class);
|
||||
$services->set(RemoveOverriddenValuesRector::class);
|
||||
$services->set(RemoveUnusedPrivatePropertyRector::class);
|
||||
$services->set(RemoveUnusedPrivateClassConstantRector::class);
|
||||
$services->set(RemoveUnusedPrivateMethodRector::class);
|
||||
$services->set(RemoveCodeAfterReturnRector::class);
|
||||
$services->set(RemoveDeadConstructorRector::class);
|
||||
$services->set(RemoveDeadReturnRector::class);
|
||||
$services->set(RemoveDeadIfForeachForRector::class);
|
||||
$services->set(RemoveAndTrueRector::class);
|
||||
$services->set(RemoveConcatAutocastRector::class);
|
||||
$services->set(SimplifyUselessVariableRector::class);
|
||||
$services->set(RemoveDelegatingParentCallRector::class);
|
||||
$services->set(RemoveDuplicatedInstanceOfRector::class);
|
||||
$services->set(RemoveDuplicatedCaseInSwitchRector::class);
|
||||
$services->set(RemoveSetterOnlyPropertyAndMethodCallRector::class);
|
||||
$services->set(RemoveNullPropertyInitializationRector::class);
|
||||
$services->set(RemoveUnreachableStatementRector::class);
|
||||
$services->set(SimplifyIfElseWithSameContentRector::class);
|
||||
$services->set(TernaryToBooleanOrFalseToBooleanAndRector::class);
|
||||
$services->set(RemoveEmptyTestMethodRector::class);
|
||||
$services->set(RemoveDeadTryCatchRector::class);
|
||||
$services->set(RemoveUnusedVariableAssignRector::class);
|
||||
$services->set(RemoveDuplicatedIfReturnRector::class);
|
||||
$services->set(RemoveUnusedNonEmptyArrayBeforeForeachRector::class);
|
||||
$services->set(RemoveAssignOfVoidReturnFunctionRector::class);
|
||||
$services->set(RemoveEmptyMethodCallRector::class);
|
||||
$services->set(RemoveDeadConditionAboveReturnRector::class);
|
||||
$services->set(RemoveUnusedConstructorParamRector::class);
|
||||
$services->set(RemoveDeadInstanceOfRector::class);
|
||||
$services->set(RemoveDeadLoopRector::class);
|
||||
$services->set(RemoveUnusedPrivateMethodParameterRector::class);
|
||||
|
||||
$services->set(\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Cast\RecastingRemovalRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\FunctionLike\RemoveOverriddenValuesRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\FunctionLike\RemoveCodeAfterReturnRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\For_\RemoveDeadIfForeachForRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\BinaryOp\RemoveDuplicatedInstanceOfRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Property\RemoveSetterOnlyPropertyAndMethodCallRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector::class);
|
||||
$services->set(\Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Assign\RemoveAssignOfVoidReturnFunctionRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Return_\RemoveDeadConditionAboveReturnRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\For_\RemoveDeadLoopRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector::class);
|
||||
// docblock
|
||||
$services->set(RemoveUselessParamTagRector::class);
|
||||
$services->set(RemoveUselessReturnTagRector::class);
|
||||
$services->set(RemoveNonExistingVarAnnotationRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Defluent\Rector\ClassMethod\ReturnThisRemoveRector;
|
||||
use Rector\Defluent\Rector\MethodCall\FluentChainMethodCallToNormalMethodCallRector;
|
||||
|
@ -10,24 +11,19 @@ use Rector\Defluent\Rector\MethodCall\NewFluentChainMethodCallToNonFluentRector;
|
|||
use Rector\Defluent\Rector\Return_\DefluentReturnMethodCallRector;
|
||||
use Rector\Defluent\Rector\Return_\ReturnFluentChainMethodCallToNormalMethodCallRector;
|
||||
use Rector\Defluent\Rector\Return_\ReturnNewFluentChainMethodCallToNonFluentRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
// @see https://ocramius.github.io/blog/fluent-interfaces-are-evil/
|
||||
// @see https://www.yegor256.com/2018/03/13/fluent-interfaces.html
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
// variable/property
|
||||
$services->set(FluentChainMethodCallToNormalMethodCallRector::class);
|
||||
$services->set(ReturnFluentChainMethodCallToNormalMethodCallRector::class);
|
||||
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\FluentChainMethodCallToNormalMethodCallRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\Return_\ReturnFluentChainMethodCallToNormalMethodCallRector::class);
|
||||
// new
|
||||
$services->set(NewFluentChainMethodCallToNonFluentRector::class);
|
||||
$services->set(ReturnNewFluentChainMethodCallToNonFluentRector::class);
|
||||
|
||||
$services->set(ReturnThisRemoveRector::class);
|
||||
$services->set(DefluentReturnMethodCallRector::class);
|
||||
$services->set(MethodCallOnSetterMethodCallToStandaloneAssignRector::class);
|
||||
$services->set(InArgFluentChainMethodCallToStandaloneMethodCallRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\NewFluentChainMethodCallToNonFluentRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\Return_\ReturnNewFluentChainMethodCallToNonFluentRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\ClassMethod\ReturnThisRemoveRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\Return_\DefluentReturnMethodCallRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\MethodCallOnSetterMethodCallToStandaloneAssignRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\InArgFluentChainMethodCallToStandaloneMethodCallRector::class);
|
||||
};
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_53);
|
||||
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_53);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(DirConstToFileConstRector::class);
|
||||
$services->set(\Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
|
@ -13,20 +14,18 @@ use Rector\DowngradePhp70\Rector\GroupUse\SplitGroupedUseImportsRector;
|
|||
use Rector\DowngradePhp70\Rector\New_\DowngradeAnonymousClassRector;
|
||||
use Rector\DowngradePhp70\Rector\Spaceship\DowngradeSpaceshipRector;
|
||||
use Rector\DowngradePhp70\Rector\String_\DowngradeGeneratedScalarTypesRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_56);
|
||||
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_56);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(DowngradeScalarTypeDeclarationRector::class);
|
||||
$services->set(DowngradeStrictTypeDeclarationRector::class);
|
||||
$services->set(DowngradeAnonymousClassRector::class);
|
||||
$services->set(DowngradeNullCoalesceRector::class);
|
||||
$services->set(DowngradeSpaceshipRector::class);
|
||||
$services->set(DowngradeDefineArrayConstantRector::class);
|
||||
$services->set(DowngradeSessionStartArrayOptionsRector::class);
|
||||
$services->set(SplitGroupedUseImportsRector::class);
|
||||
$services->set(DowngradeGeneratedScalarTypesRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\FunctionLike\DowngradeScalarTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\Declare_\DowngradeStrictTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\New_\DowngradeAnonymousClassRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\Coalesce\DowngradeNullCoalesceRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\Spaceship\DowngradeSpaceshipRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\Expression\DowngradeDefineArrayConstantRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\FuncCall\DowngradeSessionStartArrayOptionsRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\GroupUse\SplitGroupedUseImportsRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\String_\DowngradeGeneratedScalarTypesRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
|
@ -13,20 +14,18 @@ use Rector\DowngradePhp71\Rector\FunctionLike\DowngradeVoidTypeDeclarationRector
|
|||
use Rector\DowngradePhp71\Rector\List_\DowngradeKeysInListRector;
|
||||
use Rector\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector;
|
||||
use Rector\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_70);
|
||||
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_70);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(DowngradeNullableTypeDeclarationRector::class);
|
||||
$services->set(DowngradeVoidTypeDeclarationRector::class);
|
||||
$services->set(DowngradeClassConstantVisibilityRector::class);
|
||||
$services->set(DowngradePipeToMultiCatchExceptionRector::class);
|
||||
$services->set(SymmetricArrayDestructuringToListRector::class);
|
||||
$services->set(DowngradeNegativeStringOffsetToStrlenRector::class);
|
||||
$services->set(DowngradeKeysInListRector::class);
|
||||
$services->set(DowngradeIterablePseudoTypeDeclarationRector::class);
|
||||
$services->set(DowngradeIsIterableRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeVoidTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\ClassConst\DowngradeClassConstantVisibilityRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\Array_\SymmetricArrayDestructuringToListRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\List_\DowngradeKeysInListRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\FuncCall\DowngradeIsIterableRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
|
@ -8,15 +9,13 @@ use Rector\DowngradePhp72\Rector\Class_\DowngradeParameterTypeWideningRector;
|
|||
use Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector;
|
||||
use Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector;
|
||||
use Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_71);
|
||||
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_71);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(DowngradeObjectTypeDeclarationRector::class);
|
||||
$services->set(DowngradeParameterTypeWideningRector::class);
|
||||
$services->set(DowngradePregUnmatchedAsNullConstantRector::class);
|
||||
$services->set(DowngradeStreamIsattyRector::class);
|
||||
$services->set(\Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp72\Rector\Class_\DowngradeParameterTypeWideningRector::class);
|
||||
$services->set(\Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector::class);
|
||||
$services->set(\Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
|
@ -9,16 +10,14 @@ use Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCalls
|
|||
use Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector;
|
||||
use Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector;
|
||||
use Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_72);
|
||||
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_72);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(DowngradeFlexibleHeredocSyntaxRector::class);
|
||||
$services->set(DowngradeListReferenceAssignmentRector::class);
|
||||
$services->set(DowngradeTrailingCommasInFunctionCallsRector::class);
|
||||
$services->set(DowngradeArrayKeyFirstLastRector::class);
|
||||
$services->set(SetCookieOptionsArrayToArgumentsRector::class);
|
||||
$services->set(\Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector::class);
|
||||
$services->set(\Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector::class);
|
||||
$services->set(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector::class);
|
||||
$services->set(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeArrayKeyFirstLastRector::class);
|
||||
$services->set(\Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
|
@ -15,22 +16,20 @@ use Rector\DowngradePhp74\Rector\FuncCall\DowngradeStripTagsCallWithArrayRector;
|
|||
use Rector\DowngradePhp74\Rector\Identical\DowngradeFreadFwriteFalsyToNegationRector;
|
||||
use Rector\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector;
|
||||
use Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_73);
|
||||
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_73);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(DowngradeTypedPropertyRector::class);
|
||||
$services->set(ArrowFunctionToAnonymousFunctionRector::class);
|
||||
$services->set(DowngradeCovariantReturnTypeRector::class);
|
||||
$services->set(DowngradeContravariantArgumentTypeRector::class);
|
||||
$services->set(DowngradeNullCoalescingOperatorRector::class);
|
||||
$services->set(DowngradeNumericLiteralSeparatorRector::class);
|
||||
$services->set(DowngradeStripTagsCallWithArrayRector::class);
|
||||
$services->set(DowngradeArraySpreadRector::class);
|
||||
$services->set(DowngradeArrayMergeCallWithoutArgumentsRector::class);
|
||||
$services->set(DowngradeFreadFwriteFalsyToNegationRector::class);
|
||||
$services->set(DowngradeSelfTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\ArrowFunction\ArrowFunctionToAnonymousFunctionRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeCovariantReturnTypeRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeContravariantArgumentTypeRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\Coalesce\DowngradeNullCoalescingOperatorRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\FuncCall\DowngradeStripTagsCallWithArrayRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\Array_\DowngradeArraySpreadRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\FuncCall\DowngradeArrayMergeCallWithoutArgumentsRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\Identical\DowngradeFreadFwriteFalsyToNegationRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeSelfTypeDeclarationRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
|
@ -14,21 +15,19 @@ use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRecto
|
|||
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector;
|
||||
use Rector\DowngradePhp80\Rector\NullsafeMethodCall\DowngradeNullsafeToTernaryOperatorRector;
|
||||
use Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_74);
|
||||
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_74);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(DowngradeUnionTypeTypedPropertyRector::class);
|
||||
$services->set(DowngradeUnionTypeDeclarationRector::class);
|
||||
$services->set(DowngradeMixedTypeDeclarationRector::class);
|
||||
$services->set(DowngradeStaticTypeDeclarationRector::class);
|
||||
$services->set(DowngradePropertyPromotionRector::class);
|
||||
$services->set(DowngradeNonCapturingCatchesRector::class);
|
||||
$services->set(DowngradeMatchToSwitchRector::class);
|
||||
$services->set(DowngradeClassOnObjectToGetClassRector::class);
|
||||
$services->set(DowngradeNullsafeToTernaryOperatorRector::class);
|
||||
$services->set(DowngradeTrailingCommasInParamUseRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\ClassConstFetch\DowngradeClassOnObjectToGetClassRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\NullsafeMethodCall\DowngradeNullsafeToTernaryOperatorRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeTrailingCommasInParamUseRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
|
||||
use Rector\EarlyReturn\Rector\Foreach_\ReturnAfterToEarlyOnBreakRector;
|
||||
|
@ -13,19 +14,18 @@ use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
|
|||
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
|
||||
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector;
|
||||
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ChangeNestedForeachIfsToEarlyContinueRector::class);
|
||||
$services->set(ChangeAndIfToEarlyReturnRector::class);
|
||||
$services->set(ChangeIfElseValueAssignToEarlyReturnRector::class);
|
||||
$services->set(ChangeNestedIfsToEarlyReturnRector::class);
|
||||
$services->set(RemoveAlwaysElseRector::class);
|
||||
$services->set(ReturnBinaryAndToEarlyReturnRector::class);
|
||||
$services->set(ChangeOrIfReturnToEarlyReturnRector::class);
|
||||
$services->set(ChangeOrIfContinueToMultiContinueRector::class);
|
||||
$services->set(ReturnAfterToEarlyOnBreakRector::class);
|
||||
$services->set(PreparedValueToEarlyReturnRector::class);
|
||||
$services->set(ReturnBinaryOrToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\Foreach_\ReturnAfterToEarlyOnBreakRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector::class);
|
||||
};
|
||||
|
|
|
@ -1,35 +1,29 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(RenameMethodRector::class)
|
||||
->call('configure', [[
|
||||
RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([
|
||||
// Rename is now move, specific for files.
|
||||
new MethodCallRename('League\Flysystem\Filesystem', 'rename', 'move'),
|
||||
|
||||
// No arbitrary abbreviations
|
||||
new MethodCallRename('League\Flysystem\Filesystem', 'createDir', 'createDirectory'),
|
||||
|
||||
// Writes are now deterministic
|
||||
new MethodCallRename('League\Flysystem\Filesystem', 'update', 'write'),
|
||||
new MethodCallRename('League\Flysystem\Filesystem', 'updateStream', 'writeStream'),
|
||||
new MethodCallRename('League\Flysystem\Filesystem', 'put', 'write'),
|
||||
new MethodCallRename('League\Flysystem\Filesystem', 'putStream', 'writeStream'),
|
||||
|
||||
// Metadata getters are renamed
|
||||
new MethodCallRename('League\Flysystem\Filesystem', 'getTimestamp', 'lastModified'),
|
||||
new MethodCallRename('League\Flysystem\Filesystem', 'has', 'fileExists'),
|
||||
new MethodCallRename('League\Flysystem\Filesystem', 'getMimetype', 'mimeType'),
|
||||
new MethodCallRename('League\Flysystem\Filesystem', 'getSize', 'fileSize'),
|
||||
new MethodCallRename('League\Flysystem\Filesystem', 'getVisibility', 'visibility'),
|
||||
]),
|
||||
]]);
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([
|
||||
// Rename is now move, specific for files.
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'rename', 'move'),
|
||||
// No arbitrary abbreviations
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'createDir', 'createDirectory'),
|
||||
// Writes are now deterministic
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'update', 'write'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'updateStream', 'writeStream'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'put', 'write'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'putStream', 'writeStream'),
|
||||
// Metadata getters are renamed
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'getTimestamp', 'lastModified'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'has', 'fileExists'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'getMimetype', 'mimeType'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'getSize', 'fileSize'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'getVisibility', 'visibility'),
|
||||
])]]);
|
||||
};
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Symfony\Rector\ClassMethod\RemoveServiceFromSensioRouteRector;
|
||||
use Rector\Symfony\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ReplaceSensioRouteAnnotationWithSymfonyRector::class);
|
||||
|
||||
$services->set(RemoveServiceFromSensioRouteRector::class);
|
||||
$services->set(\Rector\Symfony\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector::class);
|
||||
$services->set(\Rector\Symfony\Rector\ClassMethod\RemoveServiceFromSensioRouteRector::class);
|
||||
};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Symfony\Rector\ClassMethod\TemplateAnnotationToThisRenderRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(TemplateAnnotationToThisRenderRector::class);
|
||||
$services->set(\Rector\Symfony\Rector\ClassMethod\TemplateAnnotationToThisRenderRector::class);
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Defluent\Rector\MethodCall\FluentChainMethodCallToNormalMethodCallRector;
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
|
@ -9,37 +10,14 @@ use Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector;
|
|||
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
|
||||
use Rector\Transform\ValueObject\FuncCallToMethodCall;
|
||||
use Rector\Transform\ValueObject\StaticCallToFuncCall;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
# both uses "%classes_to_defluent%
|
||||
$services->set(FluentChainMethodCallToNormalMethodCallRector::class);
|
||||
|
||||
$configuration = [
|
||||
new FuncCallToMethodCall('GuzzleHttp\json_decode', 'GuzzleHttp\Utils', 'jsonDecode'),
|
||||
new FuncCallToMethodCall('GuzzleHttp\get_path', 'GuzzleHttp\Utils', 'getPath'),
|
||||
];
|
||||
|
||||
$services->set(FuncCallToMethodCallRector::class)
|
||||
->call('configure', [[
|
||||
FuncCallToMethodCallRector::FUNC_CALL_TO_CLASS_METHOD_CALL => ValueObjectInliner::inline($configuration),
|
||||
]]);
|
||||
|
||||
$services->set(StaticCallToFuncCallRector::class)
|
||||
->call('configure', [[
|
||||
StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => ValueObjectInliner::inline([
|
||||
new StaticCallToFuncCall('GuzzleHttp\Utils', 'setPath', 'GuzzleHttp\set_path'),
|
||||
new StaticCallToFuncCall('GuzzleHttp\Pool', 'batch', 'GuzzleHttp\Pool\batch'),
|
||||
]),
|
||||
]]);
|
||||
|
||||
$services->set(RenameMethodRector::class)
|
||||
->call('configure', [[
|
||||
RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([
|
||||
new MethodCallRename('GuzzleHttp\Message\MessageInterface', 'getHeaderLines', 'getHeaderAsArray'),
|
||||
]),
|
||||
]]);
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\FluentChainMethodCallToNormalMethodCallRector::class);
|
||||
$configuration = [new \Rector\Transform\ValueObject\FuncCallToMethodCall('GuzzleHttp\\json_decode', 'GuzzleHttp\\Utils', 'jsonDecode'), new \Rector\Transform\ValueObject\FuncCallToMethodCall('GuzzleHttp\\get_path', 'GuzzleHttp\\Utils', 'getPath')];
|
||||
$services->set(\Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector::class)->call('configure', [[\Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector::FUNC_CALL_TO_CLASS_METHOD_CALL => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline($configuration)]]);
|
||||
$services->set(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class)->call('configure', [[\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Transform\ValueObject\StaticCallToFuncCall('GuzzleHttp\\Utils', 'setPath', 'GuzzleHttp\\set_path'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('GuzzleHttp\\Pool', 'batch', 'GuzzleHttp\\Pool\\batch')])]]);
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Renaming\ValueObject\MethodCallRename('GuzzleHttp\\Message\\MessageInterface', 'getHeaderLines', 'getHeaderAsArray')])]]);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Core\ValueObject\Visibility;
|
||||
use Rector\NetteToSymfony\Rector\MethodCall\WrapTransParameterNameRector;
|
||||
|
@ -9,36 +10,12 @@ use Rector\Renaming\Rector\Name\RenameClassRector;
|
|||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector;
|
||||
use Rector\Visibility\ValueObject\ChangeMethodVisibility;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ChangeMethodVisibilityRector::class)
|
||||
->call('configure', [[
|
||||
ChangeMethodVisibilityRector::METHOD_VISIBILITIES => ValueObjectInliner::inline([
|
||||
new ChangeMethodVisibility('Kdyby\Events\Subscriber', 'getSubscribedEvents', Visibility::STATIC),
|
||||
]),
|
||||
]]);
|
||||
|
||||
$services->set(RenameMethodRector::class)
|
||||
->call('configure', [[
|
||||
RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([
|
||||
new MethodCallRename('Kdyby\Translation\Translator', 'translate', 'trans'),
|
||||
new MethodCallRename('Kdyby\RabbitMq\IConsumer', 'process', 'execute'),
|
||||
]),
|
||||
]]);
|
||||
|
||||
$services->set(RenameClassRector::class)
|
||||
->call('configure', [[
|
||||
RenameClassRector::OLD_TO_NEW_CLASSES => [
|
||||
'Kdyby\RabbitMq\IConsumer' => 'OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface',
|
||||
'Kdyby\RabbitMq\IProducer' => 'OldSound\RabbitMqBundle\RabbitMq\ProducerInterface',
|
||||
'Kdyby\Monolog\Logger' => 'Psr\Log\LoggerInterface',
|
||||
'Kdyby\Events\Subscriber' => 'Symfony\Component\EventDispatcher\EventSubscriberInterface',
|
||||
'Kdyby\Translation\Translator' => 'Symfony\Contracts\Translation\TranslatorInterface',
|
||||
],
|
||||
]]);
|
||||
|
||||
$services->set(WrapTransParameterNameRector::class);
|
||||
$services->set(\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::class)->call('configure', [[\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::METHOD_VISIBILITIES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Visibility\ValueObject\ChangeMethodVisibility('Kdyby\\Events\\Subscriber', 'getSubscribedEvents', \Rector\Core\ValueObject\Visibility::STATIC)])]]);
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Renaming\ValueObject\MethodCallRename('Kdyby\\Translation\\Translator', 'translate', 'trans'), new \Rector\Renaming\ValueObject\MethodCallRename('Kdyby\\RabbitMq\\IConsumer', 'process', 'execute')])]]);
|
||||
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->call('configure', [[\Rector\Renaming\Rector\Name\RenameClassRector::OLD_TO_NEW_CLASSES => ['Kdyby\\RabbitMq\\IConsumer' => 'OldSound\\RabbitMqBundle\\RabbitMq\\ConsumerInterface', 'Kdyby\\RabbitMq\\IProducer' => 'OldSound\\RabbitMqBundle\\RabbitMq\\ProducerInterface', 'Kdyby\\Monolog\\Logger' => 'Psr\\Log\\LoggerInterface', 'Kdyby\\Events\\Subscriber' => 'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface', 'Kdyby\\Translation\\Translator' => 'Symfony\\Contracts\\Translation\\TranslatorInterface']]]);
|
||||
$services->set(\Rector\NetteToSymfony\Rector\MethodCall\WrapTransParameterNameRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use PHPStan\Type\ObjectWithoutClassType;
|
||||
use PHPStan\Type\StringType;
|
||||
|
@ -19,85 +20,19 @@ use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
|
|||
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
|
||||
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
|
||||
|
||||
$parameters->set(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES, \true);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ChangePackageVersionComposerRector::class)
|
||||
->call('configure', [[
|
||||
ChangePackageVersionComposerRector::PACKAGES_AND_VERSIONS => ValueObjectInliner::inline([
|
||||
new PackageAndVersion('league/event', '^3.0'),
|
||||
]),
|
||||
]]);
|
||||
|
||||
$services->set(RenameMethodRector::class)
|
||||
->call('configure', [[
|
||||
RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([
|
||||
new MethodCallRename('League\Event\EventInterface', 'getName', 'eventName'),
|
||||
new MethodCallRename('League\Event\EmitterInterface', 'emit', 'dispatch'),
|
||||
new MethodCallRename('League\Event\EmitterInterface', 'addListener', 'subscribeTo'),
|
||||
new MethodCallRename('League\Event\EmitterInterface', 'addOneTimeListener', 'subscribeOneTo'),
|
||||
new MethodCallRename('League\Event\EmitterInterface', 'useListenerProvider', 'subscribeListenersFrom'),
|
||||
new MethodCallRename('League\Event\ListenerInterface', 'handle', '__invoke'),
|
||||
]),
|
||||
]]);
|
||||
|
||||
$services->set(AddParamTypeDeclarationRector::class)
|
||||
->call('configure', [[
|
||||
AddParamTypeDeclarationRector::PARAMETER_TYPEHINTS => ValueObjectInliner::inline([
|
||||
new AddParamTypeDeclaration(
|
||||
'League\Event\ListenerInterface',
|
||||
'__invoke',
|
||||
0,
|
||||
new ObjectWithoutClassType()
|
||||
),
|
||||
]),
|
||||
]]);
|
||||
|
||||
$services->set(AddReturnTypeDeclarationRector::class)
|
||||
->call('configure', [[
|
||||
AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => ValueObjectInliner::inline([
|
||||
new AddReturnTypeDeclaration('League\Event\EventInterface', 'eventName', new StringType()),
|
||||
new AddReturnTypeDeclaration('League\Event\ListenerInterface', '__invoke', new VoidType()),
|
||||
]),
|
||||
]]);
|
||||
|
||||
$services->set(RenameClassRector::class)
|
||||
->call('configure', [[
|
||||
RenameClassRector::OLD_TO_NEW_CLASSES => [
|
||||
'League\Event\Emitter' => 'League\Event\EventDispatcher',
|
||||
'League\Event\ListenerInterface' => 'League\Event\Listener',
|
||||
'League\Event\GeneratorInterface' => 'League\Event\EventGenerator',
|
||||
'League\Event\ListenerProviderInterface' => 'League\Event\ListenerSubscriber',
|
||||
'League\Event\ListenerAcceptorInterface' => 'League\Event\ListenerRegistry',
|
||||
],
|
||||
]]);
|
||||
|
||||
$services->set(AddInterfaceByParentRector::class)
|
||||
->call('configure', [[
|
||||
AddInterfaceByParentRector::INTERFACE_BY_PARENT => [
|
||||
'League\Event\Event' => 'League\Event\HasEventName',
|
||||
'League\Event\AbstractListener' => 'League\Event\Listener',
|
||||
],
|
||||
]]);
|
||||
|
||||
$services->set(RemoveInterfacesRector::class)
|
||||
->call('configure', [[
|
||||
RemoveInterfacesRector::INTERFACES_TO_REMOVE => ['League\Event\EventInterface'],
|
||||
]]);
|
||||
|
||||
$services->set(RemoveParentRector::class)
|
||||
->call('configure', [[
|
||||
RemoveParentRector::PARENT_TYPES_TO_REMOVE => [
|
||||
'League\Event\AbstractEvent',
|
||||
'League\Event\Event',
|
||||
'League\Event\AbstractListener',
|
||||
],
|
||||
]]);
|
||||
|
||||
$services->set(DispatchStringToObjectRector::class);
|
||||
$services->set(\Rector\Composer\Rector\ChangePackageVersionComposerRector::class)->call('configure', [[\Rector\Composer\Rector\ChangePackageVersionComposerRector::PACKAGES_AND_VERSIONS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Composer\ValueObject\PackageAndVersion('league/event', '^3.0')])]]);
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EventInterface', 'getName', 'eventName'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EmitterInterface', 'emit', 'dispatch'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EmitterInterface', 'addListener', 'subscribeTo'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EmitterInterface', 'addOneTimeListener', 'subscribeOneTo'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EmitterInterface', 'useListenerProvider', 'subscribeListenersFrom'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\ListenerInterface', 'handle', '__invoke')])]]);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class)->call('configure', [[\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::PARAMETER_TYPEHINTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('League\\Event\\ListenerInterface', '__invoke', 0, new \PHPStan\Type\ObjectWithoutClassType())])]]);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class)->call('configure', [[\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('League\\Event\\EventInterface', 'eventName', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('League\\Event\\ListenerInterface', '__invoke', new \PHPStan\Type\VoidType())])]]);
|
||||
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->call('configure', [[\Rector\Renaming\Rector\Name\RenameClassRector::OLD_TO_NEW_CLASSES => ['League\\Event\\Emitter' => 'League\\Event\\EventDispatcher', 'League\\Event\\ListenerInterface' => 'League\\Event\\Listener', 'League\\Event\\GeneratorInterface' => 'League\\Event\\EventGenerator', 'League\\Event\\ListenerProviderInterface' => 'League\\Event\\ListenerSubscriber', 'League\\Event\\ListenerAcceptorInterface' => 'League\\Event\\ListenerRegistry']]]);
|
||||
$services->set(\Rector\Transform\Rector\Class_\AddInterfaceByParentRector::class)->call('configure', [[\Rector\Transform\Rector\Class_\AddInterfaceByParentRector::INTERFACE_BY_PARENT => ['League\\Event\\Event' => 'League\\Event\\HasEventName', 'League\\Event\\AbstractListener' => 'League\\Event\\Listener']]]);
|
||||
$services->set(\Rector\Removing\Rector\Class_\RemoveInterfacesRector::class)->call('configure', [[\Rector\Removing\Rector\Class_\RemoveInterfacesRector::INTERFACES_TO_REMOVE => ['League\\Event\\EventInterface']]]);
|
||||
$services->set(\Rector\Removing\Rector\Class_\RemoveParentRector::class)->call('configure', [[\Rector\Removing\Rector\Class_\RemoveParentRector::PARENT_TYPES_TO_REMOVE => ['League\\Event\\AbstractEvent', 'League\\Event\\Event', 'League\\Event\\AbstractListener']]]);
|
||||
$services->set(\Rector\LeagueEvent\Rector\MethodCall\DispatchStringToObjectRector::class);
|
||||
};
|
||||
|
|
|
@ -1,30 +1,14 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
# https://github.com/Seldaek/monolog/commit/39f8a20e6dadc0194e846b254c5f23d1c732290b#diff-dce565f403e044caa5e6a0d988339430
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(RenameMethodRector::class)
|
||||
->call('configure', [[
|
||||
RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([
|
||||
new MethodCallRename('Monolog\Logger', 'addDebug', 'debug'),
|
||||
new MethodCallRename('Monolog\Logger', 'addInfo', 'info'),
|
||||
new MethodCallRename('Monolog\Logger', 'addNotice', 'notice'),
|
||||
new MethodCallRename('Monolog\Logger', 'addWarning', 'warning'),
|
||||
new MethodCallRename('Monolog\Logger', 'addError', 'error'),
|
||||
new MethodCallRename('Monolog\Logger', 'addCritical', 'critical'),
|
||||
new MethodCallRename('Monolog\Logger', 'addAlert', 'alert'),
|
||||
new MethodCallRename('Monolog\Logger', 'addEmergency', 'emergency'),
|
||||
new MethodCallRename('Monolog\Logger', 'warn', 'warning'),
|
||||
new MethodCallRename('Monolog\Logger', 'err', 'error'),
|
||||
new MethodCallRename('Monolog\Logger', 'crit', 'critical'),
|
||||
new MethodCallRename('Monolog\Logger', 'emerg', 'emergency'),
|
||||
]),
|
||||
]]);
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addDebug', 'debug'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addInfo', 'info'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addNotice', 'notice'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addWarning', 'warning'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addError', 'error'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addCritical', 'critical'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addAlert', 'alert'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addEmergency', 'emergency'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'warn', 'warning'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'err', 'error'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'crit', 'critical'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'emerg', 'emergency')])]]);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector;
|
||||
use Rector\Arguments\ValueObject\SwapFuncCallArguments;
|
||||
|
@ -12,75 +13,21 @@ use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector;
|
|||
use Rector\Removing\ValueObject\RemoveFuncCallArg;
|
||||
use Rector\Renaming\Rector\ConstFetch\RenameConstantRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
# https://stackoverflow.com/a/1390625/1348344
|
||||
# https://github.com/philip/MySQLConverterTool/blob/master/Converter.php
|
||||
# https://www.phpclasses.org/blog/package/9199/post/3-Smoothly-Migrate-your-PHP-Code-using-the-Old-MySQL-extension-to-MySQLi.html
|
||||
$services->set(MysqlAssignToMysqliRector::class);
|
||||
|
||||
$services->set(MysqlFuncCallToMysqliRector::class);
|
||||
|
||||
$services->set(RemoveFuncCallArgRector::class)
|
||||
->call('configure', [[
|
||||
RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => ValueObjectInliner::inline([
|
||||
new RemoveFuncCallArg('mysql_pconnect', 3),
|
||||
new RemoveFuncCallArg('mysql_connect', 3),
|
||||
new RemoveFuncCallArg('mysql_connect', 4),
|
||||
]),
|
||||
]]);
|
||||
|
||||
$services->set(MysqlPConnectToMysqliConnectRector::class);
|
||||
|
||||
$services->set(\Rector\MysqlToMysqli\Rector\Assign\MysqlAssignToMysqliRector::class);
|
||||
$services->set(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlFuncCallToMysqliRector::class);
|
||||
$services->set(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class)->call('configure', [[\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_pconnect', 3), new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_connect', 3), new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_connect', 4)])]]);
|
||||
$services->set(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlPConnectToMysqliConnectRector::class);
|
||||
# first swap arguments, then rename
|
||||
$services->set(SwapFuncCallArgumentsRector::class)
|
||||
->call('configure', [[
|
||||
SwapFuncCallArgumentsRector::FUNCTION_ARGUMENT_SWAPS => ValueObjectInliner::inline([
|
||||
new SwapFuncCallArguments('mysql_query', [1, 0]),
|
||||
new SwapFuncCallArguments('mysql_real_escape_string', [1, 0]),
|
||||
new SwapFuncCallArguments('mysql_select_db', [1, 0]),
|
||||
new SwapFuncCallArguments('mysql_set_charset', [1, 0]),
|
||||
]),
|
||||
]]);
|
||||
|
||||
$services->set(RenameFunctionRector::class)
|
||||
->call('configure', [[
|
||||
RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
'mysql_connect' => 'mysqli_connect',
|
||||
'mysql_data_seek' => 'mysqli_data_seek',
|
||||
'mysql_fetch_array' => 'mysqli_fetch_array',
|
||||
'mysql_fetch_assoc' => 'mysqli_fetch_assoc',
|
||||
'mysql_fetch_lengths' => 'mysqli_fetch_lengths',
|
||||
'mysql_fetch_object' => 'mysqli_fetch_object',
|
||||
'mysql_fetch_row' => 'mysqli_fetch_row',
|
||||
'mysql_field_seek' => 'mysqli_field_seek',
|
||||
'mysql_free_result' => 'mysqli_free_result',
|
||||
'mysql_get_client_info' => 'mysqli_get_client_info',
|
||||
'mysql_num_fields' => 'mysqli_num_fields',
|
||||
'mysql_numfields' => 'mysqli_num_fields',
|
||||
'mysql_num_rows' => 'mysqli_num_rows',
|
||||
'mysql_numrows' => 'mysqli_num_rows',
|
||||
],
|
||||
]]);
|
||||
|
||||
$services->set(\Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector::class)->call('configure', [[\Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector::FUNCTION_ARGUMENT_SWAPS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_query', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_real_escape_string', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_select_db', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_set_charset', [1, 0])])]]);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['mysql_connect' => 'mysqli_connect', 'mysql_data_seek' => 'mysqli_data_seek', 'mysql_fetch_array' => 'mysqli_fetch_array', 'mysql_fetch_assoc' => 'mysqli_fetch_assoc', 'mysql_fetch_lengths' => 'mysqli_fetch_lengths', 'mysql_fetch_object' => 'mysqli_fetch_object', 'mysql_fetch_row' => 'mysqli_fetch_row', 'mysql_field_seek' => 'mysqli_field_seek', 'mysql_free_result' => 'mysqli_free_result', 'mysql_get_client_info' => 'mysqli_get_client_info', 'mysql_num_fields' => 'mysqli_num_fields', 'mysql_numfields' => 'mysqli_num_fields', 'mysql_num_rows' => 'mysqli_num_rows', 'mysql_numrows' => 'mysqli_num_rows']]]);
|
||||
# http://php.net/manual/en/mysql.constants.php → http://php.net/manual/en/mysqli.constants.php
|
||||
$services->set(RenameConstantRector::class)
|
||||
->call('configure', [[
|
||||
RenameConstantRector::OLD_TO_NEW_CONSTANTS => [
|
||||
'MYSQL_ASSOC' => 'MYSQLI_ASSOC',
|
||||
'MYSQL_BOTH' => 'MYSQLI_BOTH',
|
||||
'MYSQL_CLIENT_COMPRESS' => 'MYSQLI_CLIENT_COMPRESS',
|
||||
'MYSQL_CLIENT_IGNORE_SPACE' => 'MYSQLI_CLIENT_IGNORE_SPACE',
|
||||
'MYSQL_CLIENT_INTERACTIVE' => 'MYSQLI_CLIENT_INTERACTIVE',
|
||||
'MYSQL_CLIENT_SSL' => 'MYSQLI_CLIENT_SSL',
|
||||
'MYSQL_NUM' => 'MYSQLI_NUM',
|
||||
'MYSQL_PRIMARY_KEY_FLAG' => 'MYSQLI_PRI_KEY_FLAG',
|
||||
],
|
||||
]]);
|
||||
|
||||
$services->set(MysqlQueryMysqlErrorWithLinkRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\ConstFetch\RenameConstantRector::class)->call('configure', [[\Rector\Renaming\Rector\ConstFetch\RenameConstantRector::OLD_TO_NEW_CONSTANTS => ['MYSQL_ASSOC' => 'MYSQLI_ASSOC', 'MYSQL_BOTH' => 'MYSQLI_BOTH', 'MYSQL_CLIENT_COMPRESS' => 'MYSQLI_CLIENT_COMPRESS', 'MYSQL_CLIENT_IGNORE_SPACE' => 'MYSQLI_CLIENT_IGNORE_SPACE', 'MYSQL_CLIENT_INTERACTIVE' => 'MYSQLI_CLIENT_INTERACTIVE', 'MYSQL_CLIENT_SSL' => 'MYSQLI_CLIENT_SSL', 'MYSQL_NUM' => 'MYSQLI_NUM', 'MYSQL_PRIMARY_KEY_FLAG' => 'MYSQLI_PRI_KEY_FLAG']]]);
|
||||
$services->set(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlQueryMysqlErrorWithLinkRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector;
|
||||
use Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector;
|
||||
|
@ -11,17 +12,16 @@ use Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector;
|
|||
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector;
|
||||
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector;
|
||||
use Rector\Naming\Rector\Property\MakeBoolPropertyRespectIsHasWasMethodNamingRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(RenameParamToMatchTypeRector::class);
|
||||
$services->set(RenamePropertyToMatchTypeRector::class);
|
||||
$services->set(RenameVariableToMatchNewTypeRector::class);
|
||||
$services->set(RenameVariableToMatchMethodCallReturnTypeRector::class);
|
||||
$services->set(MakeGetterClassMethodNameStartWithGetRector::class);
|
||||
$services->set(MakeIsserClassMethodNameStartWithIsRector::class);
|
||||
$services->set(RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class);
|
||||
$services->set(MakeBoolPropertyRespectIsHasWasMethodNamingRector::class);
|
||||
$services->set(RenameForeachValueVariableToMatchExprVariableRector::class);
|
||||
$services->set(\Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\ClassMethod\MakeGetterClassMethodNameStartWithGetRector::class);
|
||||
$services->set(\Rector\Naming\Rector\ClassMethod\MakeIsserClassMethodNameStartWithIsRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Property\MakeBoolPropertyRespectIsHasWasMethodNamingRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector::class);
|
||||
};
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Order\Rector\Class_\OrderClassConstantsByIntegerValueRector;
|
||||
use Rector\Order\Rector\Class_\OrderConstantsByVisibilityRector;
|
||||
use Rector\Order\Rector\Class_\OrderMethodsByVisibilityRector;
|
||||
use Rector\Order\Rector\Class_\OrderPrivateMethodsByUseRector;
|
||||
use Rector\Order\Rector\Class_\OrderPropertiesByVisibilityRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(OrderPrivateMethodsByUseRector::class);
|
||||
$services->set(OrderClassConstantsByIntegerValueRector::class);
|
||||
$services->set(OrderMethodsByVisibilityRector::class);
|
||||
$services->set(OrderPropertiesByVisibilityRector::class);
|
||||
$services->set(OrderConstantsByVisibilityRector::class);
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderPrivateMethodsByUseRector::class);
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderClassConstantsByIntegerValueRector::class);
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderMethodsByVisibilityRector::class);
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderPropertiesByVisibilityRector::class);
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderConstantsByVisibilityRector::class);
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,24 +1,20 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Php52\Rector\Property\VarToPublicPropertyRector;
|
||||
use Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector;
|
||||
use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector;
|
||||
use Rector\Removing\ValueObject\RemoveFuncCallArg;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(VarToPublicPropertyRector::class);
|
||||
$services->set(ContinueToBreakInSwitchRector::class);
|
||||
|
||||
$services->set(RemoveFuncCallArgRector::class)
|
||||
->call('configure', [[
|
||||
RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => ValueObjectInliner::inline([
|
||||
// see https://www.php.net/manual/en/function.ldap-first-attribute.php
|
||||
new RemoveFuncCallArg('ldap_first_attribute', 2),
|
||||
]),
|
||||
]]);
|
||||
$services->set(\Rector\Php52\Rector\Property\VarToPublicPropertyRector::class);
|
||||
$services->set(\Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector::class);
|
||||
$services->set(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class)->call('configure', [[\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([
|
||||
// see https://www.php.net/manual/en/function.ldap-first-attribute.php
|
||||
new \Rector\Removing\ValueObject\RemoveFuncCallArg('ldap_first_attribute', 2),
|
||||
])]]);
|
||||
};
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Php53\Rector\AssignRef\ClearReturnNewByReferenceRector;
|
||||
use Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector;
|
||||
use Rector\Php53\Rector\Ternary\TernaryToElvisRector;
|
||||
use Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(TernaryToElvisRector::class);
|
||||
|
||||
$services->set(DirNameFileConstantToDirConstantRector::class);
|
||||
|
||||
$services->set(ClearReturnNewByReferenceRector::class);
|
||||
|
||||
$services->set(ReplaceHttpServerVarsByServerRector::class);
|
||||
$services->set(\Rector\Php53\Rector\Ternary\TernaryToElvisRector::class);
|
||||
$services->set(\Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector::class);
|
||||
$services->set(\Rector\Php53\Rector\AssignRef\ClearReturnNewByReferenceRector::class);
|
||||
$services->set(\Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector::class);
|
||||
};
|
||||
|
|
|
@ -1,22 +1,15 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector;
|
||||
use Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(RenameFunctionRector::class)
|
||||
->call('configure', [[
|
||||
RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
'mysqli_param_count' => 'mysqli_stmt_param_count',
|
||||
],
|
||||
]]);
|
||||
|
||||
$services->set(RemoveReferenceFromCallRector::class);
|
||||
|
||||
$services->set(RemoveZeroBreakContinueRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['mysqli_param_count' => 'mysqli_stmt_param_count']]]);
|
||||
$services->set(\Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector::class);
|
||||
$services->set(\Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector::class);
|
||||
};
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Php55\Rector\Class_\ClassConstantToSelfClassRector;
|
||||
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(StringClassNameToClassConstantRector::class);
|
||||
$services->set(ClassConstantToSelfClassRector::class);
|
||||
$services->set(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class);
|
||||
$services->set(\Rector\Php55\Rector\Class_\ClassConstantToSelfClassRector::class);
|
||||
};
|
||||
|
|
|
@ -1,57 +1,16 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Php56\Rector\FuncCall\PowToExpRector;
|
||||
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(PowToExpRector::class);
|
||||
|
||||
$services->set(RenameFunctionRector::class)
|
||||
->call('configure', [[
|
||||
RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
'mcrypt_generic_end' => 'mcrypt_generic_deinit',
|
||||
'set_socket_blocking' => 'stream_set_blocking',
|
||||
'ocibindbyname' => 'oci_bind_by_name',
|
||||
'ocicancel' => 'oci_cancel',
|
||||
'ocicolumnisnull' => 'oci_field_is_null',
|
||||
'ocicolumnname' => 'oci_field_name',
|
||||
'ocicolumnprecision' => 'oci_field_precision',
|
||||
'ocicolumnscale' => 'oci_field_scale',
|
||||
'ocicolumnsize' => 'oci_field_size',
|
||||
'ocicolumntype' => 'oci_field_type',
|
||||
'ocicolumntyperaw' => 'oci_field_type_raw',
|
||||
'ocicommit' => 'oci_commit',
|
||||
'ocidefinebyname' => 'oci_define_by_name',
|
||||
'ocierror' => 'oci_error',
|
||||
'ociexecute' => 'oci_execute',
|
||||
'ocifetch' => 'oci_fetch',
|
||||
'ocifetchstatement' => 'oci_fetch_all',
|
||||
'ocifreecursor' => 'oci_free_statement',
|
||||
'ocifreestatement' => 'oci_free_statement',
|
||||
'ociinternaldebug' => 'oci_internal_debug',
|
||||
'ocilogoff' => 'oci_close',
|
||||
'ocilogon' => 'oci_connect',
|
||||
'ocinewcollection' => 'oci_new_collection',
|
||||
'ocinewcursor' => 'oci_new_cursor',
|
||||
'ocinewdescriptor' => 'oci_new_descriptor',
|
||||
'ocinlogon' => 'oci_new_connect',
|
||||
'ocinumcols' => 'oci_num_fields',
|
||||
'ociparse' => 'oci_parse',
|
||||
'ociplogon' => 'oci_pconnect',
|
||||
'ociresult' => 'oci_result',
|
||||
'ocirollback' => 'oci_rollback',
|
||||
'ocirowcount' => 'oci_num_rows',
|
||||
'ociserverversion' => 'oci_server_version',
|
||||
'ocisetprefetch' => 'oci_set_prefetch',
|
||||
'ocistatementtype' => 'oci_statement_type',
|
||||
],
|
||||
]]);
|
||||
|
||||
$services->set(\Rector\Php56\Rector\FuncCall\PowToExpRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['mcrypt_generic_end' => 'mcrypt_generic_deinit', 'set_socket_blocking' => 'stream_set_blocking', 'ocibindbyname' => 'oci_bind_by_name', 'ocicancel' => 'oci_cancel', 'ocicolumnisnull' => 'oci_field_is_null', 'ocicolumnname' => 'oci_field_name', 'ocicolumnprecision' => 'oci_field_precision', 'ocicolumnscale' => 'oci_field_scale', 'ocicolumnsize' => 'oci_field_size', 'ocicolumntype' => 'oci_field_type', 'ocicolumntyperaw' => 'oci_field_type_raw', 'ocicommit' => 'oci_commit', 'ocidefinebyname' => 'oci_define_by_name', 'ocierror' => 'oci_error', 'ociexecute' => 'oci_execute', 'ocifetch' => 'oci_fetch', 'ocifetchstatement' => 'oci_fetch_all', 'ocifreecursor' => 'oci_free_statement', 'ocifreestatement' => 'oci_free_statement', 'ociinternaldebug' => 'oci_internal_debug', 'ocilogoff' => 'oci_close', 'ocilogon' => 'oci_connect', 'ocinewcollection' => 'oci_new_collection', 'ocinewcursor' => 'oci_new_cursor', 'ocinewdescriptor' => 'oci_new_descriptor', 'ocinlogon' => 'oci_new_connect', 'ocinumcols' => 'oci_num_fields', 'ociparse' => 'oci_parse', 'ociplogon' => 'oci_pconnect', 'ociresult' => 'oci_result', 'ocirollback' => 'oci_rollback', 'ocirowcount' => 'oci_num_rows', 'ociserverversion' => 'oci_server_version', 'ocisetprefetch' => 'oci_set_prefetch', 'ocistatementtype' => 'oci_statement_type']]]);
|
||||
# inspired by level in psalm - https://github.com/vimeo/psalm/blob/82e0bcafac723fdf5007a31a7ae74af1736c9f6f/tests/FileManipulationTest.php#L1063
|
||||
$services->set(AddDefaultValueForUndefinedVariableRector::class);
|
||||
$services->set(\Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Php70\Rector\Assign\ListSplitStringRector;
|
||||
use Rector\Php70\Rector\Assign\ListSwapArrayOrderRector;
|
||||
|
@ -21,48 +22,28 @@ use Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector;
|
|||
use Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector;
|
||||
use Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector;
|
||||
use Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$containerConfigurator->import(__DIR__ . '/mysql-to-mysqli.php');
|
||||
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(Php4ConstructorRector::class);
|
||||
|
||||
$services->set(TernaryToNullCoalescingRector::class);
|
||||
|
||||
$services->set(RandomFunctionRector::class);
|
||||
|
||||
$services->set(ExceptionHandlerTypehintRector::class);
|
||||
|
||||
$services->set(MultiDirnameRector::class);
|
||||
|
||||
$services->set(ListSplitStringRector::class);
|
||||
|
||||
$services->set(EmptyListRector::class);
|
||||
|
||||
$services->set(\Rector\Php70\Rector\ClassMethod\Php4ConstructorRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\RandomFunctionRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\MultiDirnameRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Assign\ListSplitStringRector::class);
|
||||
$services->set(\Rector\Php70\Rector\List_\EmptyListRector::class);
|
||||
# be careful, run this just once, since it can keep swapping order back and forth
|
||||
$services->set(ListSwapArrayOrderRector::class);
|
||||
|
||||
$services->set(CallUserMethodRector::class);
|
||||
|
||||
$services->set(EregToPregMatchRector::class);
|
||||
|
||||
$services->set(ReduceMultipleDefaultSwitchRector::class);
|
||||
|
||||
$services->set(TernaryToSpaceshipRector::class);
|
||||
|
||||
$services->set(WrapVariableVariableNameInCurlyBracesRector::class);
|
||||
|
||||
$services->set(IfToSpaceshipRector::class);
|
||||
|
||||
$services->set(StaticCallOnNonStaticToInstanceCallRector::class);
|
||||
|
||||
$services->set(ThisCallOnStaticMethodToStaticCallRector::class);
|
||||
|
||||
$services->set(BreakNotInLoopOrSwitchToReturnRector::class);
|
||||
|
||||
$services->set(RenameMktimeWithoutArgsToTimeRector::class);
|
||||
|
||||
$services->set(NonVariableToVariableOnFunctionCallRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Assign\ListSwapArrayOrderRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\CallUserMethodRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\EregToPregMatchRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector::class);
|
||||
$services->set(\Rector\Php70\Rector\If_\IfToSpaceshipRector::class);
|
||||
$services->set(\Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector::class);
|
||||
$services->set(\Rector\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Php71\Rector\Assign\AssignArrayToStringRector;
|
||||
use Rector\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector;
|
||||
|
@ -9,15 +10,14 @@ use Rector\Php71\Rector\FuncCall\CountOnNullRector;
|
|||
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
|
||||
use Rector\Php71\Rector\List_\ListToArrayDestructRector;
|
||||
use Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(IsIterableRector::class);
|
||||
$services->set(MultiExceptionCatchRector::class);
|
||||
$services->set(AssignArrayToStringRector::class);
|
||||
$services->set(CountOnNullRector::class);
|
||||
$services->set(RemoveExtraParametersRector::class);
|
||||
$services->set(BinaryOpBetweenNumberAndStringRector::class);
|
||||
$services->set(ListToArrayDestructRector::class);
|
||||
$services->set(\Rector\Php71\Rector\BooleanOr\IsIterableRector::class);
|
||||
$services->set(\Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector::class);
|
||||
$services->set(\Rector\Php71\Rector\Assign\AssignArrayToStringRector::class);
|
||||
$services->set(\Rector\Php71\Rector\FuncCall\CountOnNullRector::class);
|
||||
$services->set(\Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector::class);
|
||||
$services->set(\Rector\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector::class);
|
||||
$services->set(\Rector\Php71\Rector\List_\ListToArrayDestructRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Php72\Rector\Assign\ListEachRector;
|
||||
use Rector\Php72\Rector\Assign\ReplaceEachAssignmentWithKeyCurrentRector;
|
||||
|
@ -13,42 +14,28 @@ use Rector\Php72\Rector\FuncCall\StringsAssertNakedRector;
|
|||
use Rector\Php72\Rector\Unset_\UnsetCastRector;
|
||||
use Rector\Php72\Rector\While_\WhileEachToForeachRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(WhileEachToForeachRector::class);
|
||||
|
||||
$services->set(ListEachRector::class);
|
||||
|
||||
$services->set(ReplaceEachAssignmentWithKeyCurrentRector::class);
|
||||
|
||||
$services->set(UnsetCastRector::class);
|
||||
|
||||
$services->set(RenameFunctionRector::class)
|
||||
->call('configure', [[
|
||||
RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
# and imagewbmp
|
||||
'jpeg2wbmp' => 'imagecreatefromjpeg',
|
||||
# or imagewbmp
|
||||
'png2wbmp' => 'imagecreatefrompng',
|
||||
#migration72.deprecated.gmp_random-function
|
||||
# http://php.net/manual/en/migration72.deprecated.php
|
||||
# or gmp_random_range
|
||||
'gmp_random' => 'gmp_random_bits',
|
||||
'read_exif_data' => 'exif_read_data',
|
||||
],
|
||||
]]);
|
||||
|
||||
$services->set(GetClassOnNullRector::class);
|
||||
|
||||
$services->set(IsObjectOnIncompleteClassRector::class);
|
||||
|
||||
$services->set(ParseStrWithResultArgumentRector::class);
|
||||
|
||||
$services->set(StringsAssertNakedRector::class);
|
||||
|
||||
$services->set(CreateFunctionToAnonymousFunctionRector::class);
|
||||
|
||||
$services->set(StringifyDefineRector::class);
|
||||
$services->set(\Rector\Php72\Rector\While_\WhileEachToForeachRector::class);
|
||||
$services->set(\Rector\Php72\Rector\Assign\ListEachRector::class);
|
||||
$services->set(\Rector\Php72\Rector\Assign\ReplaceEachAssignmentWithKeyCurrentRector::class);
|
||||
$services->set(\Rector\Php72\Rector\Unset_\UnsetCastRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
# and imagewbmp
|
||||
'jpeg2wbmp' => 'imagecreatefromjpeg',
|
||||
# or imagewbmp
|
||||
'png2wbmp' => 'imagecreatefrompng',
|
||||
#migration72.deprecated.gmp_random-function
|
||||
# http://php.net/manual/en/migration72.deprecated.php
|
||||
# or gmp_random_range
|
||||
'gmp_random' => 'gmp_random_bits',
|
||||
'read_exif_data' => 'exif_read_data',
|
||||
]]]);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\GetClassOnNullRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\StringsAssertNakedRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\StringifyDefineRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector;
|
||||
use Rector\Php73\Rector\BooleanOr\IsCountableRector;
|
||||
|
@ -12,39 +13,33 @@ use Rector\Php73\Rector\FuncCall\SensitiveDefineRector;
|
|||
use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
|
||||
use Rector\Php73\Rector\String_\SensitiveHereNowDocRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(IsCountableRector::class);
|
||||
$services->set(ArrayKeyFirstLastRector::class);
|
||||
$services->set(SensitiveDefineRector::class);
|
||||
$services->set(SensitiveConstantNameRector::class);
|
||||
$services->set(SensitiveHereNowDocRector::class);
|
||||
|
||||
$services->set(RenameFunctionRector::class)
|
||||
->call('configure', [[
|
||||
RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
# https://wiki.php.net/rfc/deprecations_php_7_3
|
||||
'image2wbmp' => 'imagewbmp',
|
||||
'mbregex_encoding' => 'mb_regex_encoding',
|
||||
'mbereg' => 'mb_ereg',
|
||||
'mberegi' => 'mb_eregi',
|
||||
'mbereg_replace' => 'mb_ereg_replace',
|
||||
'mberegi_replace' => 'mb_eregi_replace',
|
||||
'mbsplit' => 'mb_split',
|
||||
'mbereg_match' => 'mb_ereg_match',
|
||||
'mbereg_search' => 'mb_ereg_search',
|
||||
'mbereg_search_pos' => 'mb_ereg_search_pos',
|
||||
'mbereg_search_regs' => 'mb_ereg_search_regs',
|
||||
'mbereg_search_init' => 'mb_ereg_search_init',
|
||||
'mbereg_search_getregs' => 'mb_ereg_search_getregs',
|
||||
'mbereg_search_getpos' => 'mb_ereg_search_getpos',
|
||||
],
|
||||
]]);
|
||||
|
||||
$services->set(StringifyStrNeedlesRector::class);
|
||||
$services->set(JsonThrowOnErrorRector::class);
|
||||
$services->set(RegexDashEscapeRector::class);
|
||||
$services->set(ContinueToBreakInSwitchRector::class);
|
||||
$services->set(\Rector\Php73\Rector\BooleanOr\IsCountableRector::class);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector::class);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\SensitiveDefineRector::class);
|
||||
$services->set(\Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector::class);
|
||||
$services->set(\Rector\Php73\Rector\String_\SensitiveHereNowDocRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
# https://wiki.php.net/rfc/deprecations_php_7_3
|
||||
'image2wbmp' => 'imagewbmp',
|
||||
'mbregex_encoding' => 'mb_regex_encoding',
|
||||
'mbereg' => 'mb_ereg',
|
||||
'mberegi' => 'mb_eregi',
|
||||
'mbereg_replace' => 'mb_ereg_replace',
|
||||
'mberegi_replace' => 'mb_eregi_replace',
|
||||
'mbsplit' => 'mb_split',
|
||||
'mbereg_match' => 'mb_ereg_match',
|
||||
'mbereg_search' => 'mb_ereg_search',
|
||||
'mbereg_search_pos' => 'mb_ereg_search_pos',
|
||||
'mbereg_search_regs' => 'mb_ereg_search_regs',
|
||||
'mbereg_search_init' => 'mb_ereg_search_init',
|
||||
'mbereg_search_getregs' => 'mb_ereg_search_getregs',
|
||||
'mbereg_search_getpos' => 'mb_ereg_search_getpos',
|
||||
]]]);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector::class);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector::class);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\RegexDashEscapeRector::class);
|
||||
$services->set(\Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Php74\Rector\Assign\NullCoalescingOperatorRector;
|
||||
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
|
||||
|
@ -17,48 +18,29 @@ use Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector;
|
|||
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
||||
use Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(TypedPropertyRector::class);
|
||||
|
||||
$services->set(RenameFunctionRector::class)
|
||||
->call('configure', [[
|
||||
RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
#the_real_type
|
||||
# https://wiki.php.net/rfc/deprecations_php_7_4
|
||||
'is_real' => 'is_float',
|
||||
#apache_request_headers_function
|
||||
# https://wiki.php.net/rfc/deprecations_php_7_4
|
||||
'apache_request_headers' => 'getallheaders',
|
||||
//'hebrevc' => ['nl2br', 'hebrev'],
|
||||
],
|
||||
]]);
|
||||
|
||||
$services->set(ArrayKeyExistsOnPropertyRector::class);
|
||||
|
||||
$services->set(FilterVarToAddSlashesRector::class);
|
||||
|
||||
$services->set(ExportToReflectionFunctionRector::class);
|
||||
|
||||
$services->set(GetCalledClassToStaticClassRector::class);
|
||||
|
||||
$services->set(MbStrrposEncodingArgumentPositionRector::class);
|
||||
|
||||
$services->set(RealToFloatTypeCastRector::class);
|
||||
|
||||
$services->set(NullCoalescingOperatorRector::class);
|
||||
|
||||
$services->set(ReservedFnFunctionRector::class);
|
||||
|
||||
$services->set(ClosureToArrowFunctionRector::class);
|
||||
|
||||
$services->set(ArraySpreadInsteadOfArrayMergeRector::class);
|
||||
|
||||
$services->set(AddLiteralSeparatorToNumberRector::class);
|
||||
|
||||
$services->set(ChangeReflectionTypeToStringToGetNameRector::class);
|
||||
|
||||
$services->set(RestoreDefaultNullToNullableTypePropertyRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Property\TypedPropertyRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
#the_real_type
|
||||
# https://wiki.php.net/rfc/deprecations_php_7_4
|
||||
'is_real' => 'is_float',
|
||||
#apache_request_headers_function
|
||||
# https://wiki.php.net/rfc/deprecations_php_7_4
|
||||
'apache_request_headers' => 'getallheaders',
|
||||
]]]);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector::class);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\FilterVarToAddSlashesRector::class);
|
||||
$services->set(\Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector::class);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector::class);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Double\RealToFloatTypeCastRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Assign\NullCoalescingOperatorRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Function_\ReservedFnFunctionRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector::class);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector::class);
|
||||
$services->set(\Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector::class);
|
||||
$services->set(\Rector\Php74\Rector\MethodCall\ChangeReflectionTypeToStringToGetNameRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector;
|
||||
use Rector\Arguments\ValueObject\ArgumentAdder;
|
||||
|
@ -21,63 +22,28 @@ use Rector\Php80\Rector\NotIdentical\StrContainsRector;
|
|||
use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;
|
||||
use Rector\Php80\Rector\Ternary\GetDebugTypeRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(UnionTypesRector::class);
|
||||
$services->set(StrContainsRector::class);
|
||||
$services->set(StrStartsWithRector::class);
|
||||
$services->set(StrEndsWithRector::class);
|
||||
$services->set(StringableForToStringRector::class);
|
||||
$services->set(AnnotationToAttributeRector::class);
|
||||
$services->set(ClassOnObjectRector::class);
|
||||
$services->set(GetDebugTypeRector::class);
|
||||
$services->set(TokenGetAllToObjectRector::class);
|
||||
$services->set(RemoveUnusedVariableInCatchRector::class);
|
||||
$services->set(ClassPropertyAssignToConstructorPromotionRector::class);
|
||||
$services->set(ChangeSwitchToMatchRector::class);
|
||||
|
||||
$services->set(\Rector\Php80\Rector\FunctionLike\UnionTypesRector::class);
|
||||
$services->set(\Rector\Php80\Rector\NotIdentical\StrContainsRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Identical\StrStartsWithRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Identical\StrEndsWithRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Class_\StringableForToStringRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class);
|
||||
$services->set(\Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Ternary\GetDebugTypeRector::class);
|
||||
$services->set(\Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class);
|
||||
// nette\utils and Strings::replace()
|
||||
$services->set(ArgumentAdderRector::class)
|
||||
->call('configure', [[
|
||||
ArgumentAdderRector::ADDED_ARGUMENTS => ValueObjectInliner::inline([
|
||||
new ArgumentAdder('Nette\Utils\Strings', 'replace', 2, 'replacement', ''),
|
||||
]),
|
||||
]]);
|
||||
$services->set(RemoveParentCallWithoutParentRector::class);
|
||||
$services->set(SetStateToStaticRector::class);
|
||||
$services->set(FinalPrivateToPrivateVisibilityRector::class);
|
||||
$services->set(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class)->call('configure', [[\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::ADDED_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Arguments\ValueObject\ArgumentAdder('Nette\\Utils\\Strings', 'replace', 2, 'replacement', '')])]]);
|
||||
$services->set(\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class);
|
||||
$services->set(\Rector\Php80\Rector\ClassMethod\SetStateToStaticRector::class);
|
||||
$services->set(\Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class);
|
||||
// @see https://php.watch/versions/8.0/pgsql-aliases-deprecated
|
||||
$services->set(RenameFunctionRector::class)
|
||||
->call('configure', [[
|
||||
RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
'pg_clientencoding' => 'pg_client_encoding',
|
||||
'pg_cmdtuples' => 'pg_affected_rows',
|
||||
'pg_errormessage' => 'pg_last_error',
|
||||
'pg_fieldisnull' => 'pg_field_is_null',
|
||||
'pg_fieldname' => 'pg_field_name',
|
||||
'pg_fieldnum' => 'pg_field_num',
|
||||
'pg_fieldprtlen' => 'pg_field_prtlen',
|
||||
'pg_fieldsize' => 'pg_field_size',
|
||||
'pg_fieldtype' => 'pg_field_type',
|
||||
'pg_freeresult' => 'pg_free_result',
|
||||
'pg_getlastoid' => 'pg_last_oid',
|
||||
'pg_loclose' => 'pg_lo_close',
|
||||
'pg_locreate' => 'pg_lo_create',
|
||||
'pg_loexport' => 'pg_lo_export',
|
||||
'pg_loimport' => 'pg_lo_import',
|
||||
'pg_loopen' => 'pg_lo_open',
|
||||
'pg_loread' => 'pg_lo_read',
|
||||
'pg_loreadall' => 'pg_lo_read_all',
|
||||
'pg_lounlink' => 'pg_lo_unlink',
|
||||
'pg_lowrite' => 'pg_lo_write',
|
||||
'pg_numfields' => 'pg_num_fields',
|
||||
'pg_numrows' => 'pg_num_rows',
|
||||
'pg_result' => 'pg_fetch_result',
|
||||
'pg_setclientencoding' => 'pg_set_client_encoding',
|
||||
],
|
||||
]]);
|
||||
$services->set(OptionalParametersAfterRequiredRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['pg_clientencoding' => 'pg_client_encoding', 'pg_cmdtuples' => 'pg_affected_rows', 'pg_errormessage' => 'pg_last_error', 'pg_fieldisnull' => 'pg_field_is_null', 'pg_fieldname' => 'pg_field_name', 'pg_fieldnum' => 'pg_field_num', 'pg_fieldprtlen' => 'pg_field_prtlen', 'pg_fieldsize' => 'pg_field_size', 'pg_fieldtype' => 'pg_field_type', 'pg_freeresult' => 'pg_free_result', 'pg_getlastoid' => 'pg_last_oid', 'pg_loclose' => 'pg_lo_close', 'pg_locreate' => 'pg_lo_create', 'pg_loexport' => 'pg_lo_export', 'pg_loimport' => 'pg_lo_import', 'pg_loopen' => 'pg_lo_open', 'pg_loread' => 'pg_lo_read', 'pg_loreadall' => 'pg_lo_read_all', 'pg_lounlink' => 'pg_lo_unlink', 'pg_lowrite' => 'pg_lo_write', 'pg_numfields' => 'pg_num_fields', 'pg_numrows' => 'pg_num_rows', 'pg_result' => 'pg_fetch_result', 'pg_setclientencoding' => 'pg_set_client_encoding']]]);
|
||||
$services->set(\Rector\Php80\Rector\ClassMethod\OptionalParametersAfterRequiredRector::class);
|
||||
};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ReturnNeverTypeRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector::class);
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Class_\AddMockPropertiesRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Class_\PhpSpecClassToPHPUnitClassRector;
|
||||
|
@ -9,24 +10,18 @@ use Rector\PhpSpecToPHPUnit\Rector\ClassMethod\PhpSpecMethodToPHPUnitMethodRecto
|
|||
use Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecMocksToPHPUnitMocksRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecPromisesToPHPUnitAssertRector;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Variable\MockVariableToPropertyFetchRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
# see: https://gnugat.github.io/2015/09/23/phpunit-with-phpspec.html
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
# 1. first convert mocks
|
||||
$services->set(PhpSpecMocksToPHPUnitMocksRector::class);
|
||||
|
||||
$services->set(PhpSpecPromisesToPHPUnitAssertRector::class);
|
||||
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecMocksToPHPUnitMocksRector::class);
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecPromisesToPHPUnitAssertRector::class);
|
||||
# 2. then methods
|
||||
$services->set(PhpSpecMethodToPHPUnitMethodRector::class);
|
||||
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\ClassMethod\PhpSpecMethodToPHPUnitMethodRector::class);
|
||||
# 3. then the class itself
|
||||
$services->set(PhpSpecClassToPHPUnitClassRector::class);
|
||||
|
||||
$services->set(AddMockPropertiesRector::class);
|
||||
$services->set(MockVariableToPropertyFetchRector::class);
|
||||
$services->set(RenameSpecFileToTestFileRector::class);
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\Class_\PhpSpecClassToPHPUnitClassRector::class);
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\Class_\AddMockPropertiesRector::class);
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\Variable\MockVariableToPropertyFetchRector::class);
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\Class_\RenameSpecFileToTestFileRector::class);
|
||||
};
|
||||
|
|
|
@ -1,41 +1,19 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(RenameMethodRector::class)
|
||||
->call('configure', [[
|
||||
RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([
|
||||
// @see http://www.phpspec.net/en/stable/manual/upgrading-to-phpspec-3.html
|
||||
new MethodCallRename('PhpSpec\ServiceContainer', 'set', 'define'),
|
||||
new MethodCallRename('PhpSpec\ServiceContainer', 'setShared', 'define'),
|
||||
]),
|
||||
]]);
|
||||
|
||||
$services->set(RenameClassRector::class)
|
||||
->call('configure', [[
|
||||
RenameClassRector::OLD_TO_NEW_CLASSES => [
|
||||
'PhpSpec\Console\IO' => 'PhpSpec\Console\ConsoleIO',
|
||||
'PhpSpec\IO\IOInterface' => 'PhpSpec\IO\IO',
|
||||
'PhpSpec\Locator\ResourceInterface' => 'PhpSpec\Locator\Resource',
|
||||
'PhpSpec\Locator\ResourceLocatorInterface' => 'PhpSpec\Locator\ResourceLocator',
|
||||
'PhpSpec\Formatter\Presenter\PresenterInterface' => 'PhpSpec\Formatter\Presenter\Presenter',
|
||||
'PhpSpec\CodeGenerator\Generator\GeneratorInterface' => 'PhpSpec\CodeGenerator\Generator\Generator',
|
||||
'PhpSpec\Extension\ExtensionInterface' => 'PhpSpec\Extension',
|
||||
'Phpspec\CodeAnalysis\AccessInspectorInterface' => 'Phpspec\CodeAnalysis\AccessInspector',
|
||||
'Phpspec\Event\EventInterface' => 'Phpspec\Event\PhpSpecEvent',
|
||||
'PhpSpec\Formatter\Presenter\Differ\EngineInterface' => 'PhpSpec\Formatter\Presenter\Differ\DifferEngine',
|
||||
'PhpSpec\Matcher\MatcherInterface' => 'PhpSpec\Matcher\Matcher',
|
||||
'PhpSpec\Matcher\MatchersProviderInterface' => 'PhpSpec\Matcher\MatchersProvider',
|
||||
'PhpSpec\SpecificationInterface' => 'PhpSpec\Specification',
|
||||
'PhpSpec\Runner\Maintainer\MaintainerInterface' => 'PhpSpec\Runner\Maintainer\Maintainer',
|
||||
],
|
||||
]]);
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([
|
||||
// @see http://www.phpspec.net/en/stable/manual/upgrading-to-phpspec-3.html
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('PhpSpec\\ServiceContainer', 'set', 'define'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('PhpSpec\\ServiceContainer', 'setShared', 'define'),
|
||||
])]]);
|
||||
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->call('configure', [[\Rector\Renaming\Rector\Name\RenameClassRector::OLD_TO_NEW_CLASSES => ['PhpSpec\\Console\\IO' => 'PhpSpec\\Console\\ConsoleIO', 'PhpSpec\\IO\\IOInterface' => 'PhpSpec\\IO\\IO', 'PhpSpec\\Locator\\ResourceInterface' => 'PhpSpec\\Locator\\Resource', 'PhpSpec\\Locator\\ResourceLocatorInterface' => 'PhpSpec\\Locator\\ResourceLocator', 'PhpSpec\\Formatter\\Presenter\\PresenterInterface' => 'PhpSpec\\Formatter\\Presenter\\Presenter', 'PhpSpec\\CodeGenerator\\Generator\\GeneratorInterface' => 'PhpSpec\\CodeGenerator\\Generator\\Generator', 'PhpSpec\\Extension\\ExtensionInterface' => 'PhpSpec\\Extension', 'Phpspec\\CodeAnalysis\\AccessInspectorInterface' => 'Phpspec\\CodeAnalysis\\AccessInspector', 'Phpspec\\Event\\EventInterface' => 'Phpspec\\Event\\PhpSpecEvent', 'PhpSpec\\Formatter\\Presenter\\Differ\\EngineInterface' => 'PhpSpec\\Formatter\\Presenter\\Differ\\DifferEngine', 'PhpSpec\\Matcher\\MatcherInterface' => 'PhpSpec\\Matcher\\Matcher', 'PhpSpec\\Matcher\\MatchersProviderInterface' => 'PhpSpec\\Matcher\\MatchersProvider', 'PhpSpec\\SpecificationInterface' => 'PhpSpec\\Specification', 'PhpSpec\\Runner\\Maintainer\\MaintainerInterface' => 'PhpSpec\\Runner\\Maintainer\\Maintainer']]]);
|
||||
};
|
||||
|
|
|
@ -1,23 +1,16 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use PHPStan\Type\ArrayType;
|
||||
use PHPStan\Type\MixedType;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$arrayType = new ArrayType(new MixedType(), new MixedType());
|
||||
|
||||
$services->set(AddReturnTypeDeclarationRector::class)
|
||||
->call('configure', [[
|
||||
AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => ValueObjectInliner::inline([
|
||||
new AddReturnTypeDeclaration('PhpSpec\ObjectBehavior', 'getMatchers', $arrayType),
|
||||
]),
|
||||
]]);
|
||||
$arrayType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType());
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class)->call('configure', [[\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('PhpSpec\\ObjectBehavior', 'getMatchers', $arrayType)])]]);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\Privatization\Rector\Class_\ChangeLocalPropertyToVariableRector;
|
||||
use Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector;
|
||||
|
@ -12,20 +13,18 @@ use Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector;
|
|||
use Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector;
|
||||
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
|
||||
use Rector\Privatization\Rector\Property\PrivatizeLocalPropertyToPrivatePropertyRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(FinalizeClassesWithoutChildrenRector::class);
|
||||
$services->set(ChangeGlobalVariablesToPropertiesRector::class);
|
||||
$services->set(ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class);
|
||||
$services->set(ChangeReadOnlyVariableWithDefaultValueToConstantRector::class);
|
||||
$services->set(RepeatedLiteralToClassConstantRector::class);
|
||||
$services->set(PrivatizeLocalGetterToPropertyRector::class);
|
||||
$services->set(PrivatizeLocalPropertyToPrivatePropertyRector::class);
|
||||
$services->set(PrivatizeFinalClassPropertyRector::class);
|
||||
$services->set(PrivatizeFinalClassMethodRector::class);
|
||||
|
||||
$services->set(\Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\ClassMethod\ChangeGlobalVariablesToPropertiesRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Property\PrivatizeLocalPropertyToPrivatePropertyRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector::class);
|
||||
// buggy, requires more work
|
||||
// $services->set(ChangeLocalPropertyToVariableRector::class);
|
||||
};
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector;
|
||||
use Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(NormalizeNamespaceByPSR4ComposerAutoloadRector::class);
|
||||
$services->set(MultipleClassFileToPsr4ClassesRector::class);
|
||||
$services->set(\Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector::class);
|
||||
$services->set(\Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector::class);
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
|
||||
|
@ -10,16 +11,15 @@ use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyR
|
|||
use Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector;
|
||||
use Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector;
|
||||
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(AddClosureReturnTypeRector::class);
|
||||
$services->set(ReturnTypeFromStrictTypedPropertyRector::class);
|
||||
$services->set(TypedPropertyFromStrictConstructorRector::class);
|
||||
$services->set(ParamTypeFromStrictTypedPropertyRector::class);
|
||||
$services->set(ReturnTypeFromStrictTypedCallRector::class);
|
||||
$services->set(AddVoidReturnTypeWhereNoReturnRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector::class);
|
||||
// $services->set(AddMethodCallBasedStrictParamTypeRector::class);
|
||||
$services->set(ReturnTypeFromReturnNewRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector::class);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddArrayParamDocTypeRector;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector;
|
||||
|
@ -9,15 +10,14 @@ use Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector;
|
|||
use Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ParamTypeDeclarationRector::class);
|
||||
$services->set(ReturnTypeDeclarationRector::class);
|
||||
$services->set(PropertyTypeDeclarationRector::class);
|
||||
$services->set(AddClosureReturnTypeRector::class);
|
||||
$services->set(AddArrayParamDocTypeRector::class);
|
||||
$services->set(AddArrayReturnDocTypeRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddArrayParamDocTypeRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector::class);
|
||||
// $services->set(AddParamTypeFromCallersRector::class);
|
||||
};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix20210509;
|
||||
|
||||
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
use RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210509\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(UnwrapFutureCompatibleIfFunctionExistsRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector::class);
|
||||
};
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\Annotation;
|
||||
|
||||
final class AnnotationNaming
|
||||
{
|
||||
public function normalizeName(string $name): string
|
||||
public function normalizeName(string $name) : string
|
||||
{
|
||||
return '@' . ltrim($name, '@');
|
||||
return '@' . \ltrim($name, '@');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,30 +1,22 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\Attributes;
|
||||
|
||||
use PHPStan\PhpDocParser\Ast\Node;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
|
||||
final class AttributeMirrorer
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private const ATTRIBUTES_TO_MIRROR = [
|
||||
PhpDocAttributeKey::PARENT,
|
||||
PhpDocAttributeKey::START_AND_END,
|
||||
PhpDocAttributeKey::ORIG_NODE,
|
||||
];
|
||||
|
||||
public function mirror(Node $oldNode, Node $newNode): void
|
||||
private const ATTRIBUTES_TO_MIRROR = [\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT, \Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, \Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE];
|
||||
public function mirror(\PHPStan\PhpDocParser\Ast\Node $oldNode, \PHPStan\PhpDocParser\Ast\Node $newNode) : void
|
||||
{
|
||||
foreach (self::ATTRIBUTES_TO_MIRROR as $attributeToMirror) {
|
||||
if (! $oldNode->hasAttribute($attributeToMirror)) {
|
||||
if (!$oldNode->hasAttribute($attributeToMirror)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$attributeValue = $oldNode->getAttribute($attributeToMirror);
|
||||
$newNode->setAttribute($attributeToMirror, $attributeValue);
|
||||
}
|
||||
|
|
|
@ -1,98 +1,76 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\Comment;
|
||||
|
||||
use PhpParser\Comment;
|
||||
use PhpParser\Node;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
|
||||
|
||||
use RectorPrefix20210509\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
|
||||
final class CommentsMerger
|
||||
{
|
||||
/**
|
||||
* @var SimpleCallableNodeTraverser
|
||||
*/
|
||||
private $simpleCallableNodeTraverser;
|
||||
|
||||
public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser)
|
||||
public function __construct(\RectorPrefix20210509\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser)
|
||||
{
|
||||
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node[] $mergedNodes
|
||||
*/
|
||||
public function keepComments(Node $newNode, array $mergedNodes): void
|
||||
public function keepComments(\PhpParser\Node $newNode, array $mergedNodes) : void
|
||||
{
|
||||
$comments = $newNode->getComments();
|
||||
|
||||
foreach ($mergedNodes as $mergedNode) {
|
||||
$comments = array_merge($comments, $mergedNode->getComments());
|
||||
$comments = \array_merge($comments, $mergedNode->getComments());
|
||||
}
|
||||
|
||||
if ($comments === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
$newNode->setAttribute(AttributeKey::COMMENTS, $comments);
|
||||
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $comments);
|
||||
// remove so comments "win"
|
||||
$newNode->setAttribute(AttributeKey::PHP_DOC_INFO, null);
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, null);
|
||||
}
|
||||
|
||||
public function keepParent(Node $newNode, Node $oldNode): void
|
||||
public function keepParent(\PhpParser\Node $newNode, \PhpParser\Node $oldNode) : void
|
||||
{
|
||||
$parent = $oldNode->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if (! $parent instanceof Node) {
|
||||
$parent = $oldNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
if (!$parent instanceof \PhpParser\Node) {
|
||||
return;
|
||||
}
|
||||
|
||||
$phpDocInfo = $parent->getAttribute(AttributeKey::PHP_DOC_INFO);
|
||||
$phpDocInfo = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO);
|
||||
$comments = $parent->getComments();
|
||||
|
||||
if ($phpDocInfo === null && $comments === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
$newNode->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo);
|
||||
$newNode->setAttribute(AttributeKey::COMMENTS, $comments);
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo);
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $comments);
|
||||
}
|
||||
|
||||
public function keepChildren(Node $newNode, Node $oldNode): void
|
||||
public function keepChildren(\PhpParser\Node $newNode, \PhpParser\Node $oldNode) : void
|
||||
{
|
||||
$childrenComments = $this->collectChildrenComments($oldNode);
|
||||
|
||||
if ($childrenComments === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
$commentContent = '';
|
||||
foreach ($childrenComments as $childComment) {
|
||||
$commentContent .= $childComment->getText() . PHP_EOL;
|
||||
$commentContent .= $childComment->getText() . \PHP_EOL;
|
||||
}
|
||||
|
||||
$newNode->setAttribute(AttributeKey::COMMENTS, [new Comment($commentContent)]);
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, [new \PhpParser\Comment($commentContent)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Comment[]
|
||||
*/
|
||||
private function collectChildrenComments(Node $node): array
|
||||
private function collectChildrenComments(\PhpParser\Node $node) : array
|
||||
{
|
||||
$childrenComments = [];
|
||||
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (Node $node) use (
|
||||
&$childrenComments
|
||||
): void {
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (\PhpParser\Node $node) use(&$childrenComments) : void {
|
||||
$comments = $node->getComments();
|
||||
|
||||
if ($comments !== []) {
|
||||
$childrenComments = array_merge($childrenComments, $comments);
|
||||
$childrenComments = \array_merge($childrenComments, $comments);
|
||||
}
|
||||
});
|
||||
|
||||
return $childrenComments;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\Contract;
|
||||
|
||||
use Symplify\SimplePhpDocParser\Contract\PhpDocNodeVisitorInterface;
|
||||
|
||||
interface BasePhpDocNodeVisitorInterface extends PhpDocNodeVisitorInterface
|
||||
use RectorPrefix20210509\Symplify\SimplePhpDocParser\Contract\PhpDocNodeVisitorInterface;
|
||||
interface BasePhpDocNodeVisitorInterface extends \RectorPrefix20210509\Symplify\SimplePhpDocParser\Contract\PhpDocNodeVisitorInterface
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,24 +1,20 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\DataProvider;
|
||||
|
||||
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
|
||||
|
||||
final class CurrentTokenIteratorProvider
|
||||
{
|
||||
/**
|
||||
* @var BetterTokenIterator
|
||||
*/
|
||||
private $betterTokenIterator;
|
||||
|
||||
public function setBetterTokenIterator(BetterTokenIterator $betterTokenIterator): void
|
||||
public function setBetterTokenIterator(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator) : void
|
||||
{
|
||||
$this->betterTokenIterator = $betterTokenIterator;
|
||||
}
|
||||
|
||||
public function provide(): BetterTokenIterator
|
||||
public function provide() : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator
|
||||
{
|
||||
return $this->betterTokenIterator;
|
||||
}
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDoc;
|
||||
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode;
|
||||
|
||||
final class DoctrineAnnotationTagValueNode extends AbstractValuesAwareNode
|
||||
final class DoctrineAnnotationTagValueNode extends \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $annotationClass;
|
||||
|
||||
/**
|
||||
* @param array<mixed, mixed> $values
|
||||
*/
|
||||
|
@ -22,37 +19,31 @@ final class DoctrineAnnotationTagValueNode extends AbstractValuesAwareNode
|
|||
?string $originalContent = null,
|
||||
array $values = [],
|
||||
?string $silentKey = null
|
||||
) {
|
||||
$this->hasChanged = true;
|
||||
)
|
||||
{
|
||||
$this->hasChanged = \true;
|
||||
$this->annotationClass = $annotationClass;
|
||||
|
||||
parent::__construct($values, $originalContent, $silentKey);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
public function __toString() : string
|
||||
{
|
||||
if (! $this->hasChanged) {
|
||||
if (!$this->hasChanged) {
|
||||
if ($this->originalContent === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->originalContent;
|
||||
}
|
||||
|
||||
if ($this->values === []) {
|
||||
if ($this->originalContent === '()') {
|
||||
// empty brackets
|
||||
return $this->originalContent;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
$itemContents = $this->printValuesContent($this->values);
|
||||
return sprintf('(%s)', $itemContents);
|
||||
return \sprintf('(%s)', $itemContents);
|
||||
}
|
||||
|
||||
public function getAnnotationClass(): string
|
||||
public function getAnnotationClass() : string
|
||||
{
|
||||
return $this->annotationClass;
|
||||
}
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDoc;
|
||||
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
|
||||
/**
|
||||
* Useful for annotation class based annotation, e.g. @ORM\Entity to prevent space
|
||||
* between the @ORM\Entity and (someContent)
|
||||
*/
|
||||
final class SpacelessPhpDocTagNode extends PhpDocTagNode
|
||||
final class SpacelessPhpDocTagNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode
|
||||
{
|
||||
public function __toString(): string
|
||||
public function __toString() : string
|
||||
{
|
||||
return $this->name . $this->value;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDocInfo;
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use RectorPrefix20210509\Nette\Utils\Strings;
|
||||
use PHPStan\PhpDocParser\Ast\Node;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode;
|
||||
|
@ -29,8 +28,7 @@ use Rector\ChangesReporting\Collector\RectorChangeCollector;
|
|||
use Rector\Core\Configuration\CurrentNodeProvider;
|
||||
use Rector\Core\Exception\NotImplementedYetException;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use Symplify\SimplePhpDocParser\PhpDocNodeTraverser;
|
||||
|
||||
use RectorPrefix20210509\Symplify\SimplePhpDocParser\PhpDocNodeTraverser;
|
||||
/**
|
||||
* @template TNode as \PHPStan\PhpDocParser\Ast\Node
|
||||
* @see \Rector\Tests\BetterPhpDocParser\PhpDocInfo\PhpDocInfo\PhpDocInfoTest
|
||||
|
@ -40,280 +38,218 @@ final class PhpDocInfo
|
|||
/**
|
||||
* @var array<class-string<PhpDocTagValueNode>, string>
|
||||
*/
|
||||
private const TAGS_TYPES_TO_NAMES = [
|
||||
ReturnTagValueNode::class => '@return',
|
||||
ParamTagValueNode::class => '@param',
|
||||
VarTagValueNode::class => '@var',
|
||||
MethodTagValueNode::class => '@method',
|
||||
PropertyTagValueNode::class => '@property',
|
||||
];
|
||||
|
||||
private const TAGS_TYPES_TO_NAMES = [\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class => '@return', \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode::class => '@param', \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class => '@var', \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode::class => '@method', \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode::class => '@property'];
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isSingleLine = false;
|
||||
|
||||
private $isSingleLine = \false;
|
||||
/**
|
||||
* @var PhpDocNode
|
||||
*/
|
||||
private $phpDocNode;
|
||||
|
||||
/**
|
||||
* @var PhpDocNode
|
||||
*/
|
||||
private $originalPhpDocNode;
|
||||
|
||||
/**
|
||||
* @var StaticTypeMapper
|
||||
*/
|
||||
private $staticTypeMapper;
|
||||
|
||||
/**
|
||||
* @var \PhpParser\Node
|
||||
*/
|
||||
private $node;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $hasChanged = false;
|
||||
|
||||
private $hasChanged = \false;
|
||||
/**
|
||||
* @var AnnotationNaming
|
||||
*/
|
||||
private $annotationNaming;
|
||||
|
||||
/**
|
||||
* @var CurrentNodeProvider
|
||||
*/
|
||||
private $currentNodeProvider;
|
||||
|
||||
/**
|
||||
* @var RectorChangeCollector
|
||||
*/
|
||||
private $rectorChangeCollector;
|
||||
|
||||
/**
|
||||
* @var BetterTokenIterator
|
||||
*/
|
||||
private $betterTokenIterator;
|
||||
|
||||
public function __construct(
|
||||
PhpDocNode $phpDocNode,
|
||||
BetterTokenIterator $betterTokenIterator,
|
||||
StaticTypeMapper $staticTypeMapper,
|
||||
\PhpParser\Node $node,
|
||||
AnnotationNaming $annotationNaming,
|
||||
CurrentNodeProvider $currentNodeProvider,
|
||||
RectorChangeCollector $rectorChangeCollector
|
||||
) {
|
||||
public function __construct(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \PhpParser\Node $node, \Rector\BetterPhpDocParser\Annotation\AnnotationNaming $annotationNaming, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \Rector\ChangesReporting\Collector\RectorChangeCollector $rectorChangeCollector)
|
||||
{
|
||||
$this->phpDocNode = $phpDocNode;
|
||||
$this->betterTokenIterator = $betterTokenIterator;
|
||||
$this->originalPhpDocNode = clone $phpDocNode;
|
||||
|
||||
if (! $betterTokenIterator->containsTokenType(Lexer::TOKEN_PHPDOC_EOL)) {
|
||||
$this->isSingleLine = true;
|
||||
if (!$betterTokenIterator->containsTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL)) {
|
||||
$this->isSingleLine = \true;
|
||||
}
|
||||
|
||||
$this->staticTypeMapper = $staticTypeMapper;
|
||||
$this->node = $node;
|
||||
$this->annotationNaming = $annotationNaming;
|
||||
$this->currentNodeProvider = $currentNodeProvider;
|
||||
$this->rectorChangeCollector = $rectorChangeCollector;
|
||||
}
|
||||
|
||||
public function addPhpDocTagNode(PhpDocChildNode $phpDocChildNode): void
|
||||
public function addPhpDocTagNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $phpDocChildNode) : void
|
||||
{
|
||||
$this->phpDocNode->children[] = $phpDocChildNode;
|
||||
// to give node more space
|
||||
$this->makeMultiLined();
|
||||
|
||||
$this->markAsChanged();
|
||||
}
|
||||
|
||||
public function getPhpDocNode(): PhpDocNode
|
||||
public function getPhpDocNode() : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode
|
||||
{
|
||||
return $this->phpDocNode;
|
||||
}
|
||||
|
||||
public function getOriginalPhpDocNode(): PhpDocNode
|
||||
public function getOriginalPhpDocNode() : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode
|
||||
{
|
||||
return $this->originalPhpDocNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getTokens(): array
|
||||
public function getTokens() : array
|
||||
{
|
||||
return $this->betterTokenIterator->getTokens();
|
||||
}
|
||||
|
||||
public function getTokenCount(): int
|
||||
public function getTokenCount() : int
|
||||
{
|
||||
return $this->betterTokenIterator->count();
|
||||
}
|
||||
|
||||
public function getVarTagValueNode(): ?VarTagValueNode
|
||||
public function getVarTagValueNode() : ?\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode
|
||||
{
|
||||
return $this->phpDocNode->getVarTagValues()[0] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<PhpDocTagNode>
|
||||
*/
|
||||
public function getTagsByName(string $name): array
|
||||
public function getTagsByName(string $name) : array
|
||||
{
|
||||
$name = $this->annotationNaming->normalizeName($name);
|
||||
|
||||
$tags = $this->phpDocNode->getTags();
|
||||
|
||||
$tags = array_filter($tags, function (PhpDocTagNode $tag) use ($name): bool {
|
||||
$tags = \array_filter($tags, function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode $tag) use($name) : bool {
|
||||
return $tag->name === $name;
|
||||
});
|
||||
|
||||
$tags = array_values($tags);
|
||||
return array_values($tags);
|
||||
$tags = \array_values($tags);
|
||||
return \array_values($tags);
|
||||
}
|
||||
|
||||
public function getParamType(string $name): Type
|
||||
public function getParamType(string $name) : \PHPStan\Type\Type
|
||||
{
|
||||
$paramTagValueNodes = $this->getParamTagValueByName($name);
|
||||
|
||||
return $this->getTypeOrMixed($paramTagValueNodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParamTagValueNode[]
|
||||
*/
|
||||
public function getParamTagValueNodes(): array
|
||||
public function getParamTagValueNodes() : array
|
||||
{
|
||||
return $this->phpDocNode->getParamTagValues();
|
||||
}
|
||||
|
||||
public function getParamTagValueNodeByName(string $parameterName): ?ParamTagValueNode
|
||||
public function getParamTagValueNodeByName(string $parameterName) : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode
|
||||
{
|
||||
foreach ($this->phpDocNode->getParamTagValues() as $paramTagValueNode) {
|
||||
if ($paramTagValueNode->parameterName !== '$' . $parameterName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $paramTagValueNode;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getVarType(): Type
|
||||
public function getVarType() : \PHPStan\Type\Type
|
||||
{
|
||||
return $this->getTypeOrMixed($this->getVarTagValueNode());
|
||||
}
|
||||
|
||||
public function getReturnType(): Type
|
||||
public function getReturnType() : \PHPStan\Type\Type
|
||||
{
|
||||
return $this->getTypeOrMixed($this->getReturnTagValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<TNode> $type
|
||||
*/
|
||||
public function hasByType(string $type): bool
|
||||
public function hasByType(string $type) : bool
|
||||
{
|
||||
return (bool) $this->getByType($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<class-string<TNode>> $types
|
||||
*/
|
||||
public function hasByTypes(array $types): bool
|
||||
public function hasByTypes(array $types) : bool
|
||||
{
|
||||
foreach ($types as $type) {
|
||||
if ($this->hasByType($type)) {
|
||||
return true;
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return \false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $names
|
||||
*/
|
||||
public function hasByNames(array $names): bool
|
||||
public function hasByNames(array $names) : bool
|
||||
{
|
||||
foreach ($names as $name) {
|
||||
if ($this->hasByName($name)) {
|
||||
return true;
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return \false;
|
||||
}
|
||||
|
||||
public function hasByName(string $name): bool
|
||||
public function hasByName(string $name) : bool
|
||||
{
|
||||
return (bool) $this->getTagsByName($name);
|
||||
}
|
||||
|
||||
public function getByName(string $name): ?Node
|
||||
public function getByName(string $name) : ?\PHPStan\PhpDocParser\Ast\Node
|
||||
{
|
||||
return $this->getTagsByName($name)[0] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $classes
|
||||
*/
|
||||
public function getByAnnotationClasses(array $classes): ?DoctrineAnnotationTagValueNode
|
||||
public function getByAnnotationClasses(array $classes) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
|
||||
{
|
||||
foreach ($classes as $class) {
|
||||
$tagValueNode = $this->getByAnnotationClass($class);
|
||||
if ($tagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||
if ($tagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
return $tagValueNode;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function hasByAnnotationClass(string $class): bool
|
||||
public function hasByAnnotationClass(string $class) : bool
|
||||
{
|
||||
return $this->getByAnnotationClass($class) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $annotationsClasses
|
||||
*/
|
||||
public function hasByAnnotationClasses(array $annotationsClasses): bool
|
||||
public function hasByAnnotationClasses(array $annotationsClasses) : bool
|
||||
{
|
||||
return $this->getByAnnotationClasses($annotationsClasses) !== null;
|
||||
}
|
||||
|
||||
public function getByAnnotationClass(string $desiredClass): ?DoctrineAnnotationTagValueNode
|
||||
public function getByAnnotationClass(string $desiredClass) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
|
||||
{
|
||||
foreach ($this->phpDocNode->children as $phpDocChildNode) {
|
||||
if (! $phpDocChildNode instanceof PhpDocTagNode) {
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// new approach
|
||||
if (! $phpDocChildNode->value instanceof DoctrineAnnotationTagValueNode) {
|
||||
if (!$phpDocChildNode->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$annotationClass = $phpDocChildNode->value->getAnnotationClass();
|
||||
if ($annotationClass === $desiredClass) {
|
||||
return $phpDocChildNode->value;
|
||||
}
|
||||
|
||||
// fnmatch
|
||||
if ($this->isFnmatch($annotationClass, $desiredClass)) {
|
||||
return $phpDocChildNode->value;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<TNode> $type
|
||||
* @return TNode|null
|
||||
|
@ -321,239 +257,188 @@ final class PhpDocInfo
|
|||
public function getByType(string $type)
|
||||
{
|
||||
foreach ($this->phpDocNode->children as $phpDocChildNode) {
|
||||
if (is_a($phpDocChildNode, $type, true)) {
|
||||
if (\is_a($phpDocChildNode, $type, \true)) {
|
||||
return $phpDocChildNode;
|
||||
}
|
||||
|
||||
if (! $phpDocChildNode instanceof PhpDocTagNode) {
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_a($phpDocChildNode->value, $type, true)) {
|
||||
if (!\is_a($phpDocChildNode->value, $type, \true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $phpDocChildNode->value;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated, should accept only strings, to make it useful for developer who don't know internal logics of tag nodes; also not each tag requires node class
|
||||
* @template T of \PHPStan\PhpDocParser\Ast\Node
|
||||
* @param class-string<T> $type
|
||||
*/
|
||||
public function removeByType(string $type): void
|
||||
public function removeByType(string $type) : void
|
||||
{
|
||||
foreach ($this->phpDocNode->children as $key => $phpDocChildNode) {
|
||||
if (is_a($phpDocChildNode, $type, true)) {
|
||||
if (\is_a($phpDocChildNode, $type, \true)) {
|
||||
unset($this->phpDocNode->children[$key]);
|
||||
$this->markAsChanged();
|
||||
}
|
||||
|
||||
if (! $phpDocChildNode instanceof PhpDocTagNode) {
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_a($phpDocChildNode->value, $type, true)) {
|
||||
if (!\is_a($phpDocChildNode->value, $type, \true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
unset($this->phpDocNode->children[$key]);
|
||||
$this->markAsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, Type>
|
||||
*/
|
||||
public function getParamTypesByName(): array
|
||||
public function getParamTypesByName() : array
|
||||
{
|
||||
$paramTypesByName = [];
|
||||
|
||||
foreach ($this->phpDocNode->getParamTagValues() as $paramTagValueNode) {
|
||||
$parameterName = $paramTagValueNode->parameterName;
|
||||
$paramTypesByName[$parameterName] = $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType(
|
||||
$paramTagValueNode,
|
||||
$this->node
|
||||
);
|
||||
$paramTypesByName[$parameterName] = $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($paramTagValueNode, $this->node);
|
||||
}
|
||||
|
||||
return $paramTypesByName;
|
||||
}
|
||||
|
||||
public function addTagValueNode(PhpDocTagValueNode $phpDocTagValueNode): void
|
||||
public function addTagValueNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode) : void
|
||||
{
|
||||
if ($phpDocTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||
$spacelessPhpDocTagNode = new SpacelessPhpDocTagNode(
|
||||
'@\\' . $phpDocTagValueNode->getAnnotationClass(),
|
||||
$phpDocTagValueNode
|
||||
);
|
||||
if ($phpDocTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
$spacelessPhpDocTagNode = new \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode('@\\' . $phpDocTagValueNode->getAnnotationClass(), $phpDocTagValueNode);
|
||||
$this->addPhpDocTagNode($spacelessPhpDocTagNode);
|
||||
return;
|
||||
}
|
||||
|
||||
$name = $this->resolveNameForPhpDocTagValueNode($phpDocTagValueNode);
|
||||
|
||||
$phpDocTagNode = new PhpDocTagNode($name, $phpDocTagValueNode);
|
||||
$phpDocTagNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode($name, $phpDocTagValueNode);
|
||||
$this->addPhpDocTagNode($phpDocTagNode);
|
||||
}
|
||||
|
||||
public function isNewNode(): bool
|
||||
public function isNewNode() : bool
|
||||
{
|
||||
if ($this->phpDocNode->children === []) {
|
||||
return false;
|
||||
return \false;
|
||||
}
|
||||
|
||||
return $this->betterTokenIterator->count() === 0;
|
||||
}
|
||||
|
||||
public function makeSingleLined(): void
|
||||
public function makeSingleLined() : void
|
||||
{
|
||||
$this->isSingleLine = true;
|
||||
$this->isSingleLine = \true;
|
||||
}
|
||||
|
||||
public function isSingleLine(): bool
|
||||
public function isSingleLine() : bool
|
||||
{
|
||||
return $this->isSingleLine;
|
||||
}
|
||||
|
||||
public function hasInvalidTag(string $name): bool
|
||||
public function hasInvalidTag(string $name) : bool
|
||||
{
|
||||
// fallback for invalid tag value node
|
||||
foreach ($this->phpDocNode->children as $phpDocChildNode) {
|
||||
if (! $phpDocChildNode instanceof PhpDocTagNode) {
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($phpDocChildNode->name !== $name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! $phpDocChildNode->value instanceof InvalidTagValueNode) {
|
||||
if (!$phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
return \true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return \false;
|
||||
}
|
||||
|
||||
public function getReturnTagValue(): ?ReturnTagValueNode
|
||||
public function getReturnTagValue() : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode
|
||||
{
|
||||
$returnTagValueNodes = $this->phpDocNode->getReturnTagValues();
|
||||
return $returnTagValueNodes[0] ?? null;
|
||||
}
|
||||
|
||||
public function getParamTagValueByName(string $name): ?ParamTagValueNode
|
||||
public function getParamTagValueByName(string $name) : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode
|
||||
{
|
||||
$desiredParamNameWithDollar = '$' . ltrim($name, '$');
|
||||
|
||||
$desiredParamNameWithDollar = '$' . \ltrim($name, '$');
|
||||
foreach ($this->getParamTagValueNodes() as $paramTagValueNode) {
|
||||
if ($paramTagValueNode->parameterName !== $desiredParamNameWithDollar) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $paramTagValueNode;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateTagValueNode[]
|
||||
*/
|
||||
public function getTemplateTagValueNodes(): array
|
||||
public function getTemplateTagValueNodes() : array
|
||||
{
|
||||
return $this->phpDocNode->getTemplateTagValues();
|
||||
}
|
||||
|
||||
public function hasInheritDoc(): bool
|
||||
public function hasInheritDoc() : bool
|
||||
{
|
||||
return $this->hasByNames(['inheritdoc', 'inheritDoc']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Should be handled by attributes of phpdoc node - if stard_and_end is missing in one of nodes, it has been changed
|
||||
* Similar to missing original node in php-aprser
|
||||
*/
|
||||
public function markAsChanged(): void
|
||||
public function markAsChanged() : void
|
||||
{
|
||||
$this->hasChanged = true;
|
||||
|
||||
$this->hasChanged = \true;
|
||||
$node = $this->currentNodeProvider->getNode();
|
||||
if ($node !== null) {
|
||||
$this->rectorChangeCollector->notifyNodeFileInfo($node);
|
||||
}
|
||||
}
|
||||
|
||||
public function hasChanged(): bool
|
||||
public function hasChanged() : bool
|
||||
{
|
||||
if ($this->isNewNode()) {
|
||||
return true;
|
||||
return \true;
|
||||
}
|
||||
|
||||
if ($this->hasChanged) {
|
||||
return true;
|
||||
return \true;
|
||||
}
|
||||
|
||||
// has a single node with missing start_end
|
||||
$phpDocNodeTraverser = new PhpDocNodeTraverser();
|
||||
$changedPhpDocNodeVisitor = new ChangedPhpDocNodeVisitor();
|
||||
$phpDocNodeTraverser = new \RectorPrefix20210509\Symplify\SimplePhpDocParser\PhpDocNodeTraverser();
|
||||
$changedPhpDocNodeVisitor = new \Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor();
|
||||
$phpDocNodeTraverser->addPhpDocNodeVisitor($changedPhpDocNodeVisitor);
|
||||
$phpDocNodeTraverser->traverse($this->phpDocNode);
|
||||
|
||||
return $changedPhpDocNodeVisitor->hasChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getMethodTagNames(): array
|
||||
public function getMethodTagNames() : array
|
||||
{
|
||||
$methodTagNames = [];
|
||||
foreach ($this->phpDocNode->getMethodTagValues() as $methodTagValueNode) {
|
||||
$methodTagNames[] = $methodTagValueNode->methodName;
|
||||
}
|
||||
|
||||
return $methodTagNames;
|
||||
}
|
||||
|
||||
public function makeMultiLined(): void
|
||||
public function makeMultiLined() : void
|
||||
{
|
||||
$this->isSingleLine = false;
|
||||
$this->isSingleLine = \false;
|
||||
}
|
||||
|
||||
private function getTypeOrMixed(?PhpDocTagValueNode $phpDocTagValueNode): Type
|
||||
private function getTypeOrMixed(?\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode) : \PHPStan\Type\Type
|
||||
{
|
||||
if ($phpDocTagValueNode === null) {
|
||||
return new MixedType();
|
||||
return new \PHPStan\Type\MixedType();
|
||||
}
|
||||
|
||||
return $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($phpDocTagValueNode, $this->node);
|
||||
}
|
||||
|
||||
private function resolveNameForPhpDocTagValueNode(PhpDocTagValueNode $phpDocTagValueNode): string
|
||||
private function resolveNameForPhpDocTagValueNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode) : string
|
||||
{
|
||||
foreach (self::TAGS_TYPES_TO_NAMES as $tagValueNodeType => $name) {
|
||||
/** @var class-string<PhpDocTagNode> $tagValueNodeType */
|
||||
if (is_a($phpDocTagValueNode, $tagValueNodeType, true)) {
|
||||
if (\is_a($phpDocTagValueNode, $tagValueNodeType, \true)) {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotImplementedYetException(get_class($phpDocTagValueNode));
|
||||
throw new \Rector\Core\Exception\NotImplementedYetException(\get_class($phpDocTagValueNode));
|
||||
}
|
||||
|
||||
private function isFnmatch(string $currentValue, string $desiredValue): bool
|
||||
private function isFnmatch(string $currentValue, string $desiredValue) : bool
|
||||
{
|
||||
if (! Strings::contains($desiredValue, '*')) {
|
||||
return false;
|
||||
if (!\RectorPrefix20210509\Nette\Utils\Strings::contains($desiredValue, '*')) {
|
||||
return \false;
|
||||
}
|
||||
|
||||
return fnmatch($desiredValue, $currentValue, FNM_NOESCAPE);
|
||||
return \fnmatch($desiredValue, $currentValue, \FNM_NOESCAPE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDocInfo;
|
||||
|
||||
use PhpParser\Comment\Doc;
|
||||
|
@ -20,58 +19,42 @@ use Rector\ChangesReporting\Collector\RectorChangeCollector;
|
|||
use Rector\Core\Configuration\CurrentNodeProvider;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
|
||||
final class PhpDocInfoFactory
|
||||
{
|
||||
/**
|
||||
* @var PhpDocParser
|
||||
*/
|
||||
private $betterPhpDocParser;
|
||||
|
||||
/**
|
||||
* @var Lexer
|
||||
*/
|
||||
private $lexer;
|
||||
|
||||
/**
|
||||
* @var CurrentNodeProvider
|
||||
*/
|
||||
private $currentNodeProvider;
|
||||
|
||||
/**
|
||||
* @var StaticTypeMapper
|
||||
*/
|
||||
private $staticTypeMapper;
|
||||
|
||||
/**
|
||||
* @var PhpDocNodeMapper
|
||||
*/
|
||||
private $phpDocNodeMapper;
|
||||
|
||||
/**
|
||||
* @var AnnotationNaming
|
||||
*/
|
||||
private $annotationNaming;
|
||||
|
||||
/**
|
||||
* @var RectorChangeCollector
|
||||
*/
|
||||
private $rectorChangeCollector;
|
||||
|
||||
/**
|
||||
* @var array<string, PhpDocInfo>
|
||||
*/
|
||||
private $phpDocInfosByObjectHash = [];
|
||||
|
||||
public function __construct(
|
||||
PhpDocNodeMapper $phpDocNodeMapper,
|
||||
CurrentNodeProvider $currentNodeProvider,
|
||||
Lexer $lexer,
|
||||
BetterPhpDocParser $betterPhpDocParser,
|
||||
StaticTypeMapper $staticTypeMapper,
|
||||
AnnotationNaming $annotationNaming,
|
||||
RectorChangeCollector $rectorChangeCollector
|
||||
) {
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocNodeMapper $phpDocNodeMapper, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \PHPStan\PhpDocParser\Lexer\Lexer $lexer, \Rector\BetterPhpDocParser\PhpDocParser\BetterPhpDocParser $betterPhpDocParser, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\BetterPhpDocParser\Annotation\AnnotationNaming $annotationNaming, \Rector\ChangesReporting\Collector\RectorChangeCollector $rectorChangeCollector)
|
||||
{
|
||||
$this->betterPhpDocParser = $betterPhpDocParser;
|
||||
$this->lexer = $lexer;
|
||||
$this->currentNodeProvider = $currentNodeProvider;
|
||||
|
@ -80,110 +63,77 @@ final class PhpDocInfoFactory
|
|||
$this->annotationNaming = $annotationNaming;
|
||||
$this->rectorChangeCollector = $rectorChangeCollector;
|
||||
}
|
||||
|
||||
public function createFromNodeOrEmpty(Node $node): PhpDocInfo
|
||||
public function createFromNodeOrEmpty(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
{
|
||||
// already added
|
||||
$phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO);
|
||||
if ($phpDocInfo instanceof PhpDocInfo) {
|
||||
$phpDocInfo = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO);
|
||||
if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) {
|
||||
return $phpDocInfo;
|
||||
}
|
||||
|
||||
$phpDocInfo = $this->createFromNode($node);
|
||||
if ($phpDocInfo instanceof PhpDocInfo) {
|
||||
if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) {
|
||||
return $phpDocInfo;
|
||||
}
|
||||
|
||||
return $this->createEmpty($node);
|
||||
}
|
||||
|
||||
public function createFromNode(Node $node): ?PhpDocInfo
|
||||
public function createFromNode(\PhpParser\Node $node) : ?\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
{
|
||||
$objectHash = spl_object_hash($node);
|
||||
$objectHash = \spl_object_hash($node);
|
||||
if (isset($this->phpDocInfosByObjectHash[$objectHash])) {
|
||||
return $this->phpDocInfosByObjectHash[$objectHash];
|
||||
}
|
||||
|
||||
/** needed for @see PhpDocNodeFactoryInterface */
|
||||
$this->currentNodeProvider->setNode($node);
|
||||
|
||||
$docComment = $node->getDocComment();
|
||||
if (! $docComment instanceof Doc) {
|
||||
if (!$docComment instanceof \PhpParser\Comment\Doc) {
|
||||
if ($node->getComments() !== []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// create empty node
|
||||
$content = '';
|
||||
$tokenIterator = new BetterTokenIterator([]);
|
||||
$phpDocNode = new PhpDocNode([]);
|
||||
$tokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator([]);
|
||||
$phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode([]);
|
||||
} else {
|
||||
$content = $docComment->getText();
|
||||
$tokens = $this->lexer->tokenize($content);
|
||||
$tokenIterator = new BetterTokenIterator($tokens);
|
||||
|
||||
$tokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens);
|
||||
$phpDocNode = $this->betterPhpDocParser->parse($tokenIterator);
|
||||
$this->setPositionOfLastToken($phpDocNode);
|
||||
}
|
||||
|
||||
$phpDocInfo = $this->createFromPhpDocNode($phpDocNode, $tokenIterator, $node);
|
||||
$this->phpDocInfosByObjectHash[$objectHash] = $phpDocInfo;
|
||||
|
||||
return $phpDocInfo;
|
||||
}
|
||||
|
||||
public function createEmpty(Node $node): PhpDocInfo
|
||||
public function createEmpty(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
{
|
||||
/** needed for @see PhpDocNodeFactoryInterface */
|
||||
$this->currentNodeProvider->setNode($node);
|
||||
|
||||
$phpDocNode = new PhpDocNode([]);
|
||||
$phpDocInfo = $this->createFromPhpDocNode($phpDocNode, new BetterTokenIterator([]), $node);
|
||||
|
||||
$phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode([]);
|
||||
$phpDocInfo = $this->createFromPhpDocNode($phpDocNode, new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator([]), $node);
|
||||
// multiline by default
|
||||
$phpDocInfo->makeMultiLined();
|
||||
|
||||
return $phpDocInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Needed for printing
|
||||
*/
|
||||
private function setPositionOfLastToken(PhpDocNode $phpDocNode): void
|
||||
private function setPositionOfLastToken(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : void
|
||||
{
|
||||
if ($phpDocNode->children === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
$phpDocChildNodes = $phpDocNode->children;
|
||||
$lastChildNode = array_pop($phpDocChildNodes);
|
||||
|
||||
$startAndEnd = $lastChildNode->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||
|
||||
if ($startAndEnd instanceof StartAndEnd) {
|
||||
$phpDocNode->setAttribute(PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION, $startAndEnd->getEnd());
|
||||
$lastChildNode = \array_pop($phpDocChildNodes);
|
||||
$startAndEnd = $lastChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
||||
if ($startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
|
||||
$phpDocNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION, $startAndEnd->getEnd());
|
||||
}
|
||||
}
|
||||
|
||||
private function createFromPhpDocNode(
|
||||
PhpDocNode $phpDocNode,
|
||||
BetterTokenIterator $betterTokenIterator,
|
||||
Node $node
|
||||
): PhpDocInfo {
|
||||
private function createFromPhpDocNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator, \PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
{
|
||||
$this->phpDocNodeMapper->transform($phpDocNode, $betterTokenIterator);
|
||||
|
||||
$phpDocInfo = new PhpDocInfo(
|
||||
$phpDocNode,
|
||||
$betterTokenIterator,
|
||||
$this->staticTypeMapper,
|
||||
$node,
|
||||
$this->annotationNaming,
|
||||
$this->currentNodeProvider,
|
||||
$this->rectorChangeCollector
|
||||
);
|
||||
|
||||
$node->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo);
|
||||
|
||||
$phpDocInfo = new \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo($phpDocNode, $betterTokenIterator, $this->staticTypeMapper, $node, $this->annotationNaming, $this->currentNodeProvider, $this->rectorChangeCollector);
|
||||
$node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo);
|
||||
return $phpDocInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,56 +1,46 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDocInfo;
|
||||
|
||||
use PHPStan\PhpDocParser\Lexer\Lexer;
|
||||
use PHPStan\PhpDocParser\Parser\TokenIterator;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
|
||||
use Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
|
||||
use RectorPrefix20210509\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
final class TokenIteratorFactory
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const INDEX = 'index';
|
||||
|
||||
/**
|
||||
* @var Lexer
|
||||
*/
|
||||
private $lexer;
|
||||
|
||||
/**
|
||||
* @var PrivatesAccessor
|
||||
*/
|
||||
private $privatesAccessor;
|
||||
|
||||
public function __construct(Lexer $lexer, PrivatesAccessor $privatesAccessor)
|
||||
public function __construct(\PHPStan\PhpDocParser\Lexer\Lexer $lexer, \RectorPrefix20210509\Symplify\PackageBuilder\Reflection\PrivatesAccessor $privatesAccessor)
|
||||
{
|
||||
$this->lexer = $lexer;
|
||||
$this->privatesAccessor = $privatesAccessor;
|
||||
}
|
||||
|
||||
public function create(string $content): BetterTokenIterator
|
||||
public function create(string $content) : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator
|
||||
{
|
||||
$tokens = $this->lexer->tokenize($content);
|
||||
return new BetterTokenIterator($tokens);
|
||||
return new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens);
|
||||
}
|
||||
|
||||
public function createFromTokenIterator(TokenIterator $tokenIterator): BetterTokenIterator
|
||||
public function createFromTokenIterator(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator
|
||||
{
|
||||
if ($tokenIterator instanceof BetterTokenIterator) {
|
||||
if ($tokenIterator instanceof \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator) {
|
||||
return $tokenIterator;
|
||||
}
|
||||
|
||||
$tokens = $this->privatesAccessor->getPrivateProperty($tokenIterator, 'tokens');
|
||||
$betterTokenIterator = new BetterTokenIterator($tokens);
|
||||
|
||||
$betterTokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens);
|
||||
// keep original position
|
||||
$currentIndex = $this->privatesAccessor->getPrivateProperty($tokenIterator, 'index');
|
||||
$this->privatesAccessor->setPrivateProperty($betterTokenIterator, self::INDEX, $currentIndex);
|
||||
|
||||
return $betterTokenIterator;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,116 +1,91 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDocManipulator;
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use RectorPrefix20210509\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher;
|
||||
|
||||
final class PhpDocClassRenamer
|
||||
{
|
||||
/**
|
||||
* @var ClassAnnotationMatcher
|
||||
*/
|
||||
private $classAnnotationMatcher;
|
||||
|
||||
public function __construct(ClassAnnotationMatcher $classAnnotationMatcher)
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher)
|
||||
{
|
||||
$this->classAnnotationMatcher = $classAnnotationMatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Covers annotations like @ORM, @Serializer, @Assert etc
|
||||
* See https://github.com/rectorphp/rector/issues/1872
|
||||
*
|
||||
* @param string[] $oldToNewClasses
|
||||
*/
|
||||
public function changeTypeInAnnotationTypes(Node $node, PhpDocInfo $phpDocInfo, array $oldToNewClasses): void
|
||||
public function changeTypeInAnnotationTypes(\PhpParser\Node $node, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, array $oldToNewClasses) : void
|
||||
{
|
||||
$this->processAssertChoiceTagValueNode($oldToNewClasses, $phpDocInfo);
|
||||
$this->processDoctrineRelationTagValueNode($node, $oldToNewClasses, $phpDocInfo);
|
||||
$this->processSerializerTypeTagValueNode($oldToNewClasses, $phpDocInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
*/
|
||||
private function processAssertChoiceTagValueNode(array $oldToNewClasses, PhpDocInfo $phpDocInfo): void
|
||||
private function processAssertChoiceTagValueNode(array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void
|
||||
{
|
||||
$assertChoiceTagValueNode = $phpDocInfo->getByAnnotationClass('Symfony\Component\Validator\Constraints\Choice');
|
||||
if (! $assertChoiceTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||
$assertChoiceTagValueNode = $phpDocInfo->getByAnnotationClass('Symfony\\Component\\Validator\\Constraints\\Choice');
|
||||
if (!$assertChoiceTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
$callback = $assertChoiceTagValueNode->getValueWithoutQuotes('callback');
|
||||
if ($callback === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($oldToNewClasses as $oldClass => $newClass) {
|
||||
if ($callback[0] !== $oldClass) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$callback[0] = $newClass;
|
||||
|
||||
$assertChoiceTagValueNode->changeValue('callback', $callback);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
*/
|
||||
private function processDoctrineRelationTagValueNode(
|
||||
Node $node,
|
||||
array $oldToNewClasses,
|
||||
PhpDocInfo $phpDocInfo
|
||||
): void {
|
||||
$doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClasses([
|
||||
'Doctrine\ORM\Mapping\OneToMany',
|
||||
'Doctrine\ORM\Mapping\ManyToMany',
|
||||
'Doctrine\ORM\Mapping\Embedded',
|
||||
]);
|
||||
|
||||
if (! $doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||
private function processDoctrineRelationTagValueNode(\PhpParser\Node $node, array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void
|
||||
{
|
||||
$doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClasses(['Doctrine\\ORM\\Mapping\\OneToMany', 'Doctrine\\ORM\\Mapping\\ManyToMany', 'Doctrine\\ORM\\Mapping\\Embedded']);
|
||||
if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->processDoctrineToMany($doctrineAnnotationTagValueNode, $node, $oldToNewClasses);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
*/
|
||||
private function processSerializerTypeTagValueNode(array $oldToNewClasses, PhpDocInfo $phpDocInfo): void
|
||||
private function processSerializerTypeTagValueNode(array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void
|
||||
{
|
||||
$doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('JMS\Serializer\Annotation\Type');
|
||||
if (! $doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||
$doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('JMS\\Serializer\\Annotation\\Type');
|
||||
if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($oldToNewClasses as $oldClass => $newClass) {
|
||||
$className = $doctrineAnnotationTagValueNode->getSilentValue();
|
||||
|
||||
if ($className) {
|
||||
if ($className === $oldClass) {
|
||||
$doctrineAnnotationTagValueNode->changeSilentValue($newClass);
|
||||
continue;
|
||||
}
|
||||
|
||||
$newContent = Strings::replace($className, '#\b' . preg_quote($oldClass, '#') . '\b#', $newClass);
|
||||
$newContent = \RectorPrefix20210509\Nette\Utils\Strings::replace($className, '#\\b' . \preg_quote($oldClass, '#') . '\\b#', $newClass);
|
||||
if ($newContent === $className) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$doctrineAnnotationTagValueNode->changeSilentValue($newContent);
|
||||
continue;
|
||||
}
|
||||
|
||||
$currentType = $doctrineAnnotationTagValueNode->getValueWithoutQuotes('type');
|
||||
if ($currentType === $oldClass) {
|
||||
$doctrineAnnotationTagValueNode->changeValue('type', $newClass);
|
||||
|
@ -118,34 +93,26 @@ final class PhpDocClassRenamer
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
*/
|
||||
private function processDoctrineToMany(
|
||||
DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode,
|
||||
Node $node,
|
||||
array $oldToNewClasses
|
||||
): void {
|
||||
if ($doctrineAnnotationTagValueNode->getAnnotationClass() === 'Doctrine\ORM\Mapping\Embedded') {
|
||||
private function processDoctrineToMany(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, \PhpParser\Node $node, array $oldToNewClasses) : void
|
||||
{
|
||||
if ($doctrineAnnotationTagValueNode->getAnnotationClass() === 'Doctrine\\ORM\\Mapping\\Embedded') {
|
||||
$classKey = 'class';
|
||||
} else {
|
||||
$classKey = 'targetEntity';
|
||||
}
|
||||
|
||||
$targetEntity = $doctrineAnnotationTagValueNode->getValueWithoutQuotes($classKey);
|
||||
if ($targetEntity === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// resolve to FQN
|
||||
$tagFullyQualifiedName = $this->classAnnotationMatcher->resolveTagFullyQualifiedName($targetEntity, $node);
|
||||
|
||||
foreach ($oldToNewClasses as $oldClass => $newClass) {
|
||||
if ($tagFullyQualifiedName !== $oldClass) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$doctrineAnnotationTagValueNode->changeValue($classKey, $newClass);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue