我正在尝试在SVN中构建一个预提交脚本,我想仅在修改的行上运行PHP_CodeSniffer (而不是整个文件).到目前为止,我有这个脚本:
#!/bin/sh
REPOS="$1"
TXN="$2"
# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | \
grep "[a-zA-Z0-9]" > /dev/null || exit 1
# Check for code validation before commiting the script using PHP_CodeSniffer
/tmp/pear/download/PHP_CodeSniffer-1.4.3/scripts/phpcs-svn-pre-commit "$REPOS" -t "$TXN" >&2 || exit 1
# All checks passed, so allow the commit.
exit 0
Run Code Online (Sandbox Code Playgroud) 我有一个带5个参数的函数,随着应用程序的增长,我们需要添加更多的参数,这些参数最终有9个参数,其中4个参数有默认值.
我想知道传递这样的参数或使用数组更好吗?
我更喜欢这样
fun(array(
'par1' => 'x',
'par2' => 'y',
.....
)
)
Run Code Online (Sandbox Code Playgroud)
绝缘
func($par1, $par2, $par3, ...);
Run Code Online (Sandbox Code Playgroud)
你怎么看?