Giter Site home page Giter Site logo

lx-utils's Introduction

lx-utils

Code Clean Up

Recursively clean up all files in a PHP project by assigning clean up tasks. Clean up tasks available:

  • add/remove custom doc block headers for PHP files
  • clean up undefined constants in array square brakets
    • beginning with PHP 7.2 unquoted array keys produce the Warning "Use of undefined constant ..." and in future versions this will trigger a hard error)
    • automatically quote all strings which are undefined constants used inside square brackets as array keys
    • old style array usage like $a[key1] will be automatically transformed into $a['key1']
    • also parse and compute a list of defined constants in the project/root path specified, and whitelist them them for usage without quotes as array keys
    • add curly brackets around arrays used inside double quote and heredoc string definitions

Notice

  • It's recommended to run it for your project on DEV first, check functionality and then push to LIVE.
  • When running on a real project, it's a good idea to backup the project files first, just to be sure that what you are doing matches what you're expecting.

Usage

  • Install
git clone https://github.com/eyroot/lx-utils lx-utils
cd lx-utils
composer install --no-dev
  • Console command
$ php run/cleanUpSquareBrackets.php /path/you/want/to/clean/up
  • Project/Library
use Lx\Utils\CodeCleanUp\CodeCleanUp;

$result = (new CodeCleanUp())
    ->addFilePath($pathToCleanUp)
    ->addFileExtension('php')
    ->addTask(CodeCleanUp::TASK_QUOTE_UNDEFINED_CONSTANTS_IN_SQUARE_BRACKETS)
    ->run()
;

// Available information:
// $result->filesChanged - list of files which were changed
// $result->errors - list of errors

Development set-up

  • Clone project locally:
git clone https://github.com/eyroot/lx-utils lx-utils
cd lx-utils
  • Set-up project and install composer deps:
composer install
  • Run unit testing:
mkdir -p testing/data/Utils/tmp
cd testing/
../vendor/bin/phpunit
  • Check the code coverage of tests by opening in browser:
file:///tmp/coverage-lx-utils/index.html

lx-utils's People

Contributors

eyroot avatar

Watchers

 avatar  avatar

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.