php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77895 IntlDateFormatter::create fails in strict mode if $locale = null
Submitted: 2019-04-15 11:51 UTC Modified: 2019-04-15 13:20 UTC
From: misley dot marton at webdream dot hu Assigned: nikic (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 7.2.17 OS: docker php:7.2-apache
Private report: No CVE-ID: None
 [2019-04-15 11:51 UTC] misley dot marton at webdream dot hu
Description:
------------
https://www.php.net/manual/en/intldateformatter.create.php
In the docs it sais at parameters section:

"locale: Locale to use when formatting or parsing or NULL to use the value specified in the ini setting intl.default_locale."


If you try to use strict mode with locale = null, the script fails with

"PHP Fatal error:  Uncaught TypeError: IntlDateFormatter::create() expects parameter 1 to be string, null given in ..."




Test script:
---------------
<?php

declare(strict_types=1);

$format =  $formatter = \IntlDateFormatter::create(null, \IntlDateFormatter::NONE, \IntlDateFormatter::NONE);



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-04-15 11:53 UTC] misley dot marton at webdream dot hu
phpcode without the double assign

<?php

declare(strict_types=1);

$formatter = \IntlDateFormatter::create(null, \IntlDateFormatter::NONE, \IntlDateFormatter::NONE);
 [2019-04-15 13:20 UTC] nikic@php.net
-Assigned To: +Assigned To: nikic
 [2019-04-15 13:28 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=619c4e9f2e772557d3bdaa4e23f8392dc7f4c499
Log: Fixed bug #77895
 [2019-04-15 13:28 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 17:01:30 2024 UTC