Download the PHP package palantirnet/drupal-rector without Composer

On this page you can find all versions of the php package palantirnet/drupal-rector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package drupal-rector

Drupal Rector

Automate fixing deprecated Drupal code.

Status

Packagist Version Functional test: Rector examples Unit tests PHPStan

Release notes

Note that GitHub does not let us have different default homepage and merge branches. If you checked out the project using packagist/composer, read the docs for your version.

Introduction

You can read more details in the following blog post:

https://www.palantir.net/blog/jumpstart-your-drupal-9-upgrade-drupal-rector

Documentation

Development guides, individual deprecation overviews, and other resources can be found here:

https://www.palantir.net/rector

List of all rules with examples:

Rule overview in docs/rules_overview.md

Scope and limitations

The development of this tool is prioritized by the perceived impact of the deprecations and updates. There are many deprecations that often involve several components and for each of these there are several ways to address the deprecation.

We've tried to determine impact based on:

So, high impact (the code works in newer versions of Drupal for a large number of people), low effort (we can develop the rule based on our knowledge of Rector).

Common limitations

Known limitations are listed in the comment documentation for each rule.

Common limitations include:

Our hope is that as we learn more about Rector, we may be able to update these rules to add these features.

Issues are managed on drupal.org

https://www.drupal.org/project/issues/rector

For contribution suggestions, please see the later section of this document.

Installation

NOTE: To have the best experience with Drupal Rector, your Drupal site should be running version 8.9 or higher.

Install Drupal Rector inside a Drupal project.

Create a configuration file in your project

You will need to have a rector.php configuration in the root of your repository. This should sit beside your document root such as web or docroot.

This project uses webflo/drupal-finder to find your document root that contains Drupal.

To get started, copy the rector.php configuration file provided by this package:

By default, Drupal Rector will fix deprecated code for all versions of Drupal. If you want to change this behavior, modify the sets used in the rector.php config. For example, if your site is still on Drupal 9.3, and you cannot fix deprecations made in Drupal 9.4, use the following configuration:

This is more granular than the Drupal9SetList::DRUPAL_9 set.

Suggested workflow

  1. Analyze your code with Rector and review suggested changes:

  2. Apply suggested changes:

You can find more information about Rector here.

Troubleshooting

PhpStan composer issues

You may need to upgrade phpstan/phpstan with Composer before installing this package.

Rector itself has conflicts with older versions of PhpStan.

Unable to find Rector rule classes

If you are getting errors like

[ERROR] Class "DrupalRector\Drupal8\Rector\Deprecation\EntityManagerRector" was not found while loading

You may need to rebuild your autoload file.

composer dump-autoload

FileLocator::locate() must be compatible with FileLocatorInterface::locate()

If you are getting errors like

You may need to check that you are

Sometimes people install composer dependencies from one machine (host machine) and run Drupal Rector from another (such as a Lando VM).

If you are having these issues try running Rector from the environment that has Php 7.2 or greater. Drupal Rector does not need a fully functional web server, it only (more or less) needs Php and access to a standard Drupal set of files.

Iconv error when running Rector in Alpine Docker

If you are getting errors like

iconv(): Wrong charset, conversion from UTF-8 to ASCII//TRANSLIT//IGNORE is not allowed

You can fix it in Dockerfile with

Credits to @zolotov88 in https://github.com/nunomaduro/phpinsights/issues/43#issuecomment-498108857

Development and contribution suggestions

Thanks for your interest in contributing!

Our goal is to make contributing to this project easy for people. While we've made certain architectural decisions here to hopefully achieve that goal, it's a work in progress and feedback is appreciated.

Development environment

See the instructions in README

Adding a Rector rule

If you would like to submit a Rector rule, we are looking for the following:

Guides

A few guides are currently available and we encourage people to create additional guides to provide their perspective and help us better understand this tool together.

Video guide on creating a rector rule

https://www.palantir.net/rector/creating-drupal-rector-rule

Additional documentation and links

https://www.palantir.net/rector

Quick(?) overview

Create a Rector rule class

Rector rules should be named after the deprecation, including the class name.

Drupal::url() -> DrupalUrlRector.php drupal_set_message() -> DrupalSetMessageRector.php

We would like one Rector rule per deprecation. Some deprecations include updating multiple things and those would be separate rules.

To avoid duplication, we have created base classes for simple repeated patterns where possible. These end in Base.php and are located in /src/Rector/Deprecation/Base. In many of these rules, you will extend the base class, define class properties, add a class comment, and define the definition.

Rector supports passing parameters to rules and you can also define your rules in a variety of ways. To avoid confusion for new developers, we're trying to avoid these advanced features so that someone with limited familiarity with the tool can easily determine where things are located and what they are doing. If the copy & paste challenge isn't worth this trade-off, we can re-evaluate it as we go. Suggestions appreciated.

Create examples

We are creating pairs of example files.

These should be named the same thing as the deprecation. So, DrupalUrlRector has a rector_examples/drupal_url.php example. An example rector_examples_updated/drupal_url.php should also be created to show the updated code. You can run Drupal Rector on this file to show the update.

Example

DrupalUrlRector -> rector_examples/drupal_url.php and rector_examples_updated/drupal_url.php

If you would like to show how the code is used in a class, you can add the class to the appropriate place in the /rector_examples/src or /rector_examples/test directories. Most of the examples in the example module are services in that they are stand alone classes.

Since these classes can use static calls, dependency injection, or traits to get access to services, constants, etc, we have added more details to some class names. For example, *Static to indicate that the class is not using dependency injection.

Example

DrupalUrlRector -> rector_examples/src/DrupalUrlStatic.php and rector_examples_updated/src/DrupalUrlStatic.php

Create / Update a configuration file

The configuration files in /config/drupal-8 are broken down by Drupal minor versions.

Add your Rector rule to the relevant file.

The key is the fully qualified class name of the Rector rule. The key is the yaml null value ~.

Update the index file

The index file is used in part to provide automated updates to https://dev.acquia.com/drupal9/deprecation_status/errors which is a helpful way to track coverage. The PHPStan messages are listed there as well as in the change record comments throughout the Drupal codebase.

Pinning dev dependencies

If there are conflicts with Rector, the package version can be conflicted with conflict on rector/rector and phpstan/phpstan.

Credits

Current development is sponsored by Palantir.net.
Initial development is sponsored by Pronovix.


All versions of drupal-rector with dependencies

PHP Build Version
Package Version
Requires rector/rector Version ^1.0
webflo/drupal-finder Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package palantirnet/drupal-rector contains the following files

Loading the files please wait ....