simplesamlphp 解析エラーをテストしようとしたときにこのエラーを受け取りました: 構文エラー、139 行目の /simplesamlphp/modules/core/lib/Auth/Process/GenerateGroups.php の予期しない T_FUNCTION
これは何が原因ですか?
私はPHP 5.2を実行しています
simplesamlphp 解析エラーをテストしようとしたときにこのエラーを受け取りました: 構文エラー、139 行目の /simplesamlphp/modules/core/lib/Auth/Process/GenerateGroups.php の予期しない T_FUNCTION
これは何が原因ですか?
私はPHP 5.2を実行しています
これは、無名関数を使用しているためです。このメソッドを以下のメソッドと追加のメソッドに置き換えたところ、5.2 で正しく動作するようになりました。SimplesamlPHP の要件には、PHP 5.1 または 5.2 のみが必要であると記載されていますが、このコード変更がなければ、これは明らかに正しくありません。
/**
* Escape special characters in a string.
*
* This function is similar to urlencode, but encodes many more characters.
* This function takes any characters not in [a-zA-Z0-9_@=.] and encodes them with as
* %<hex version>. For example, it will encode '+' as '%2b' and '%' as '%25'.
*
* @param string $string The string which should be escaped.
* @return string The escaped string.
*/
private static function escapeIllegalChars($string) {
assert('is_string($string)');
return preg_replace_callback('/([^a-zA-Z0-9_@=.])/',
array(self,escapeIllegalCharsPregCallback),
$string);
}
private static function escapeIllegalCharsPregCallback($m) {
return sprintf("%%%02x", ord($m[1]));
}