日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > php >内容正文

php

php强制对齐,[强迫症福利] 使用 PHPStorm 对齐数组的键值对

發(fā)布時(shí)間:2023/12/4 php 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php强制对齐,[强迫症福利] 使用 PHPStorm 对齐数组的键值对 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

用 php-cs-fixer 自動(dòng)格式化,一個(gè)配置配合 Git 自動(dòng)格式化,補(bǔ)充樓上。

示例 Git Hook

忽略前端的代碼格式化,修改一下就可以用。

#!/bin/bash

#

# check PHP code syntax error and standard with phpcs

# https://blog.csdn.net/xsgnzb/article/details/52222366?locationNum=4&fps=1

# https://blog.csdn.net/ljihe/article/details/80826071

# =================== how to use ====================

# cp ./build/pre-commit.sh ./.git/hooks/pre-commit

# chmod 777 ./.git/hooks/pre-commit

# git commit -h

# git commit -n -m 'pass hook' #bypass pre-commit and commit-msg hooks

# ==================== end ==========================

PROJECT=$(git rev-parse --show-toplevel)

cd $PROJECT

SFILES=$(git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\.php$)

# Determine if a file list is passed

if [ "$#" -ne 0 ]

then

exit 0

fi

echo "Checking PHP Lint..."

for FILE in $SFILES

do

php -l -d display_errors=0 $FILE

if [ $? != 0 ]

then

echo "Fix the php error before commit."

exit 1

fi

FILES="$FILES $PROJECT/$FILE"

done

phpcsfixer_path=$(cd `dirname $0`; pwd)"/../../build/php-cs-fixer"

gulp_path=$(cd `dirname $0`; pwd)"/../../frontend/node_modules/.bin/gulp"

prettier_path=$(cd `dirname $0`; pwd)"/../../frontend/node_modules/.bin/prettier"

# format code style

if [ "$FILES" != "" ]

then

echo "Running Code Sniffer..."

isCheck=""

for FILE in $SFILES

do

IGNORE_PATH=(

'vendor'

)

for IGNORE_ITEM in ${IGNORE_PATH[@]}

do

if [[ ${FILE} =~ ${IGNORE_ITEM} ]]

then

echo "Ignore file of "${IGNORE_ITEM}

continue 2

fi

done

#result=`~/.composer/vendor/bin/php-cs-fixer fix $FILE --config=.php_cs.dist`

#result=`php-cs-fixer fix $FILE --config=.php_cs.dist`

result=`php $phpcsfixer_path fix $FILE --config=.php_cs.dist`

if [ "$result" != "" ]

then

echo $result

isCheck=$result

git add $FILE

fi

done

if [ "$isCheck" != "" ]

then

echo "The file has been automatically formatted."

fi

fi

# for js

jsfiles=$(git diff --cached --name-only --diff-filter=ACM "*.js" "*.jsx" "*.vue" "*.css" "*.less" | tr '\n' ' ')

[ -z "$jsfiles" ] && exit 0

# format iview

$gulp_path iview --gulpfile frontend/gulpfile.js

# Prettify all staged .js files

echo "$jsfiles" | xargs $prettier_path --config frontend/.prettierrc.js --ignore-path frontend/.prettierignore --write

# Add back the modified/prettified files to staging

echo "$jsfiles" | xargs git add

git update-index -g

exit $?

總結(jié)

以上是生活随笔為你收集整理的php强制对齐,[强迫症福利] 使用 PHPStorm 对齐数组的键值对的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。