php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79454 transliterator_get_error_message arginfo is incorrect
Submitted: 2020-04-07 08:53 UTC Modified: 2020-04-07 18:47 UTC
From: glen at pld-linux dot org Assigned: cmb (profile)
Status: Closed Package: intl (PECL)
PHP Version: 7.4.4 OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: glen at pld-linux dot org
New email:
PHP Version: OS:

 

 [2020-04-07 08:53 UTC] glen at pld-linux dot org
Description:
------------
the https://www.php.net/manual/en/transliterator.geterrormessage.php is described to be called as static method, but it is not declared static and therefore can't be used why Transliterator::createFromRules for example failed.

and transliterator_get_error_message() method won't help either, as it wants an transit object as argument, but I have none as it failed to be created.


example with class method:
➔ php74 -n -r 'var_dump(Transliterator::createFromRules("Any-Latin")); var_dump(Transliterator::getErrorMessage());'
NULL

Fatal error: Uncaught Error: Non-static method Transliterator::getErrorMessage() cannot be called statically in Command line code:1
Stack trace:
#0 {main}
  thrown in Command line code on line 1


example with procedural mode:
➔ php74 -n -r 'var_dump(Transliterator::createFromRules("Any-Latin")); var_dump(transliterator_get_error_message());'
NULL

Warning: transliterator_get_error_message() expects exactly 1 parameter, 0 given in Command line code on line 1
bool(false)


Test script:
---------------
var_dump(Transliterator::getErrorMessage());

Expected result:
----------------
Transliterator::createFromRules should perhaps throw, as there's no other way to pass error


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-04-07 09:12 UTC] requinix@php.net
-Summary: Transliterator::getErrorMessage is non-static and unusable for error checking +Summary: transliterator_get_error_message arginfo is incorrect -Status: Open +Status: Verified -Package: *General Issues +Package: intl
 [2020-04-07 09:12 UTC] requinix@php.net
getErrorMessage() is not documented as a static method.

The documentation for the function form, and the source used to generate some of the documentation, is incorrect: it takes an argument of a Transliterator object. This function is specifically for error information related to a particular Transliterator instance, and you are right that you cannot use it to get an error from a failed call to a static method like createFromRules...

...because the error information for that case is stored elsewhere. See the generic intl functions:
https://www.php.net/manual/en/ref.intl.php
 [2020-04-07 09:20 UTC] cmb@php.net
-Type: Bug +Type: Documentation Problem
 [2020-04-07 14:58 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=349637
Log: Fix #79454: transliterator_get_error_message arginfo is incorrect
 [2020-04-07 15:00 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-04-07 15:00 UTC] cmb@php.net
@requinix, I the arginfo looks correct (PHP 7.3):

D:\Users\cmb>php --rf transliterator_get_error_code
Function [ <internal:intl> function transliterator_get_error_code ] {

  - Parameters [1] {
    Parameter #0 [ <required> Transliterator $trans ]
  }
}


D:\Users\cmb>php --rf transliterator_get_error_message
Function [ <internal:intl> function transliterator_get_error_message ] {

  - Parameters [1] {
    Parameter #0 [ <required> Transliterator $trans ]
  }
}
 [2020-04-07 15:00 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=2d7f05b10ee065e4c52317712afc88cae2171315
Log: Fix #79454: transliterator_get_error_message arginfo is incorrect
 [2020-04-07 16:44 UTC] mumumu@php.net
Automatic comment from SVN on behalf of mumumu
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=349639
Log: Fix #79454: transliterator_get_error_message arginfo is incorrect
 [2020-04-07 16:45 UTC] phpdocbot@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=1cb83bfe5e2fc931f4fc7c88158564c2ac220bc2
Log: Fix #79454: transliterator_get_error_message arginfo is incorrect
 [2020-04-07 18:47 UTC] requinix@php.net
> @requinix, I the arginfo looks correct (PHP 7.3):
Yeah, I misread it. Looks weird copying the constructor, but no arguments is no arguments.
 [2020-12-30 11:59 UTC] nikic@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=044e07afb02b865301d977c4b3c42c52299dc6df
Log: Fix #79454: transliterator_get_error_message arginfo is incorrect
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC