Giter Club home page Giter Club logo

detectobr's Introduction

DETECTOBR (Detect Optional Before Required utility)

In php 8 declaring a function with an optional parameter before a required one results in a "Deprecated" warning which can break some views or API responses.

Its easy to resolve this issue when located, but in big old projects can be a nightmare to search this type of declarations in thousands of scripts.

This script helps to locate automatically all these declarations in a whole project.

How to use

Simply place detectobr.php in the root folder (or subfolder) of the project in which you want to scan files and then execute it with:

php -f detectobr.php

The script will scan all php files in the same folder and all subfolders and will notice you with all declarations that have optional parameters before required parameters, showing you the file and line where it occurs.

Then, you only need to resolve the deprecated code and scan again until nothing is found.

Considerations

Nullable parameters

This script respects nullable parameters as the interpreter does not show deprecated warning when nullable parameter with declared type preceeds a required parameter. So this declaration will be accepted as valid:

function (string $nullableParameter = null, $required)

Test declarations

This script comes with three declarations to test the script, because it scans itself too.

You can play with this script by adding more test declarations inside it or creating any other script with your tests.

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.