From ec4d5f07df5b765845a504826cd8beafca1709bd Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 16 Sep 2023 18:45:17 +0900 Subject: [PATCH] Add friendly help message for "unexpected end of file" errors (fix #2180) --- modules/message/lang/en.php | 1 + modules/message/lang/ko.php | 1 + modules/message/message.view.php | 1 + 3 files changed, 3 insertions(+) diff --git a/modules/message/lang/en.php b/modules/message/lang/en.php index 52f263b6a..d18fedd1d 100644 --- a/modules/message/lang/en.php +++ b/modules/message/lang/en.php @@ -6,3 +6,4 @@ $lang->error_help['baseobject'] = 'Object → BaseObject conversion is required $lang->error_help['undef_constant'] = 'This error occurs because of missing "quotes". This syntax was often used in the past, but it is not allowed in recent versions of PHP. Please fix the incorrect syntax by consulting the file name and line number shown above.'; $lang->error_help['undef_object'] = 'This code is trying to add an attribute to an undefined object. This coding style was often used in the past, but it is not allowed in recent versions of PHP. Please fix the incorrect code by consulting the file name and line number shown above.'; $lang->error_help['not_array'] = 'This code is trying to use an array function on something that is not an array. This coding style was often used in the past, but it is not allowed in recent versions of PHP. Please fix the incorrect code by consulting the file name and line number shown above.'; +$lang->error_help['unexpected_eof'] = 'There is an unclosed parenthesis somewhere in this file. The error message will point to the end of the file, but you must find the opening parenthesis.'; diff --git a/modules/message/lang/ko.php b/modules/message/lang/ko.php index 473a94113..823e0b9bb 100644 --- a/modules/message/lang/ko.php +++ b/modules/message/lang/ko.php @@ -6,3 +6,4 @@ $lang->error_help['baseobject'] = 'Object → BaseObject 변환이 필요한 서 $lang->error_help['undef_constant'] = '문자열을 따옴표로 감싸지 않아서 발생하는 오류입니다. 오래된 자료에서 종종 사용하던 문법이나 최근 PHP에서는 허용되지 않으니, 에러 메시지에 포함된 파일명과 줄 번호를 참고하여 수정하세요.'; $lang->error_help['undef_object'] = '객체를 먼저 선언하지 않고 속성을 추가하려 하고 있습니다. 오래된 자료에서 종종 사용하던 코딩 방식이나 최근 PHP에서는 허용되지 않으니, 에러 메시지에 포함된 파일명과 줄 번호를 참고하여 수정하세요.'; $lang->error_help['not_array'] = '배열이 아닌 변수에 배열 함수를 사용하려 하고 있습니다. 오래된 자료에서 종종 사용하던 코딩 방식이나 최근 PHP에서는 허용되지 않으니, 에러 메시지에 포함된 파일명과 줄 번호를 참고하여 수정하세요.'; +$lang->error_help['unexpected_eof'] = '조건문이나 템플릿 문법 등에서 괄호의 짝이 맞지 않아 발생하는 오류입니다. 표시되는 위치는 파일의 맨 마지막 줄이지만, 괄호를 열었던 곳을 찾아 수정해야 합니다.'; diff --git a/modules/message/message.view.php b/modules/message/message.view.php index bfc313fd9..ace9da181 100644 --- a/modules/message/message.view.php +++ b/modules/message/message.view.php @@ -109,6 +109,7 @@ class MessageView extends Message '/Undefined constant [\'"][^\'"]+?[\'"]/' => 'undef_constant', '/Attempt to assign property [\'"][^\'"]+?[\'"] on null/' => 'undef_object', '/Argument #\d+ \(\$\w+\) must be of type (Countable\|)?array, \w+ given ?/' => 'not_array', + '/Syntax error, unexpected end of file\b/i' => 'unexpected_eof', ]; foreach ($regexp_list as $regexp => $key)