Git Product home page Git Product logo

rector-training's Introduction

Rector Training Step by Step

A. Theory

  • what Rector is (why it was created - story!)
  • how it works & what it uses (AST, nikic/php-parser, PHPStan)
  • how to configure it (rector.yaml)
  • simple to use!

Workflow

  • show on 1 practical example
    • use coding standard
    • instant refactoring/upgrades
    • why keep manual and automated changes separated

Is it safe to Automatically Refactor?

(ask people)

  • the most common fears

    • will it break my code
    • how does is know the context (vs. coding standrards + regulars)
    • what will be the output
    • my code is too complicated/huge/ugly/old to automatically refactor
  • insure

    • driven by community
    • x contributors
    • used by big companies (Glami, Spaceflow, Entrydo any millions others but we don't have space for them here :)
    • runs on PHPStan
    • --dry-run
    • start with 1 rule

B. Practice

1. Install Rector

  1. clone this repository :check:
    git clone [email protected]:rectorphp/rector-training.git
  2. run composer install

2. First Changes

(2-3 general examples)

  • how to rename a class in whole project (with rector.yaml) - instant upgrade (we know what must be changed, e.g. PHP deprecations)
  • rename function (mt_rand() โ†’ random_int())

3. More Complex Problems

  • instant refactoring (we have to figure out the result - now together!)

  • complete PHP 7.1 type declarations - return type, param type, @param array โ†’ @param int[]

  • how to get to PSR-4

    • theory (from what code)
    • practical (show it in example - class without namespace, 2 classes in one file, wrong namespace, underscored_namespace)

4. Your Real Problems

  • your own fist rule
  • @todo build from answers

rector-training's People

Contributors

janmikes avatar tomasvotruba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rector-training's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.