Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Call php-cs-fixer by automatically locating the configuration file
@echo off
setlocal enabledelayedexpansion
if "%~1" equ "" (
echo Missing file name>&2
goto :eof
if "%~2" neq "" (
echo Too many arguments>&2
goto :eof
if not exist "%~1" (
echo File not found: %~1>&2
goto :eof
if exist "%~1\*.*" (
echo File needed: %~1 is a directory>&2
goto :eof
set FILENAME=%~dpnx1
set DIRNAME=%~dp1
set CONFIG=%DIRNAME%\.php_cs
if exist "%CONFIG%" goto :found
call :getParent %DIRNAME% DIRNAME
if "%DIRNAME%" equ "." (
echo Configuration file not found>&2
goto :eof
goto checkParent
C:\Dev\PHP7.0-64\php.exe "%~dp0php-cs-fixer.phar" fix --config-file="%CONFIG%" "%FILENAME%"
goto :eof
set %2=.
if "%1" equ "." exit /b
if "%1" equ "" exit /b
set P1=%~dp1
set P2=%P1:~0,-1%
if "%P2:~0,2%" equ "%P2:~0,3%" exit /b
set %2=%P2%
exit /b

This comment has been minimized.

Copy link

@WinterSilence WinterSilence commented Mar 13, 2020

notepad nppExec

php -f "scripts/php-cs-fixer.phar" fix "$(FULL_CURRENT_PATH)" --config="scripts/.php_cs.dist" --diff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment