Batch script to replace PHP short open tags with <?php

前端 未结 13 1824
轻奢々
轻奢々 2020-11-30 01:49

I have a large collection of php files written over the years and I need to properly replace all the short open tags into proper explicit open tags.

change \         


        
13条回答
  •  执念已碎
    2020-11-30 02:34

    The problem has been solved as a fixer in the php-cs-fixer tool which can be easily installed and which is tested and maintained.

    Fixing then is easy:

    $ php-cs-fixer fix  --rules=full_opening_tag,no_short_echo_tag --diff --dry-run
    

    Just replace with the path to the directory or file you'd like to change. The command as given is to review first (--dry-run and --diff parameters).

    Installing php-cs-fixer is as easy as

    $ composer global require friendsofphp/php-cs-fixer
    

    if you've got composer installed with global composer bin directory in your path (recommended).

提交回复
热议问题