php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73730 textdomain(null) throws in strict mode
Submitted: 2016-12-13 07:29 UTC Modified: 2017-09-10 16:48 UTC
From: enhanced dot ttssd+php at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Gettext related
PHP Version: 7.0.14 OS: CentOS Linux release 7.2.1511 (C
Private report: No CVE-ID: None
 [2016-12-13 07:29 UTC] enhanced dot ttssd+php at gmail dot com
Description:
------------
textdomain(null) throws a TypeError when strict_types is declared.

Doc:
https://secure.php.net/manual/en/function.textdomain.php#refsect1-function.textdomain-parameters

> Parameters
>  text_domain
>    The new message domain, or NULL to get the current setting without changing it

Without strict_types, it works fine(returns current setting).

Test script:
---------------
<?php
declare(strict_types=1);

var_dump(textdomain(null));


https://3v4l.org/BRUYj

https://3v4l.org/eCF0b

Expected result:
----------------
string(8) "messages"

Actual result:
--------------
PHP Fatal error:  Uncaught TypeError: textdomain() expects parameter 1 to be string, null given

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-13 10:18 UTC] cmb@php.net
-Status: Open +Status: Analyzed
 [2016-12-13 10:18 UTC] cmb@php.net
Indeed, the arginfo[1] is insufficient.

[1] <https://github.com/php/php-src/blob/PHP-7.0.14/ext/gettext/gettext.c#L35>
 [2016-12-13 10:58 UTC] nikic@php.net
This is not related to arginfo, the zpp signature does not allow it: https://github.com/php/php-src/blob/PHP-7.0.14/ext/gettext/gettext.c#L167

It should be "s?". Currently it handles the NULL case through a coercion to "".
 [2017-09-10 16:48 UTC] cmb@php.net
-Summary: textdomain(null) throws a TypeError when strict_types is declared +Summary: textdomain(null) throws in strict mode -Assigned To: +Assigned To: cmb
 [2017-09-10 16:48 UTC] cmb@php.net
> This is not related to arginfo, […]

Of course!  Thanks.
 [2017-09-10 16:55 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4b746fce1c6f873a696ace4c98e0981a059f35c9
Log: Fixed bug #73730 (textdomain(null) throws in strict mode)
 [2017-09-10 16:56 UTC] cmb@php.net
-Status: Analyzed +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 04:01:38 2024 UTC