Issues

ZF-11324: Example in docs throws a warning in constructor on PHP 5.3

Issue Type: Docs: Problem Created: 2011-04-24T15:07:39.000+0000 Last Updated: 2013-01-17T12:48:32.000+0000 Status: Resolved Fix version(s): - 1.12.2 (25/Feb/13)

Reporter: Hagen Hübel (haghue) Assignee: Frank Brückner (frosch) Tags: - Zend_Locale

Related issues: Attachments:

Description

The following example from official docu-site 0 ends up with a php-warning:

Code: $d = new \Zend_Date('13.04.2006', array('date_format' => 'dd.MM.yyyy'));

Warning: defined() expects parameter 1 to be string, array given in /usr/share/php/libzend-framework-php/Zend/Date.php on line 155

After studying the source code, i think the documentation is not right at this point.

The following example works perfectly:

$d = new \Zend_Date('13.04.2006', 'dd.MM.yyyy');

it seems for me, the date-format must be a string, an array with named options is not wanted here.

So only the documentation should be changed. Regards, Hagen

php -v

PHP 5.3.2-1ubuntu4.7 with Suhosin-Patch (cli) (built: Jan 12 2011 18:36:55) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans with Suhosin v0.9.29, Copyright (c) 2007, by SektionEins GmbH

Zend-Version: 1.10.3

Comments

Posted by Hagen Hübel (haghue) on 2011-04-24T15:24:36.000+0000

After studying the source code, i think the documentation is not right at this point (link was postet in the issue-body).

The following example works perfectly:

$d = new \Zend_Date('13.04.2006', 'dd.MM.yyyy');

it seems for me, the date-format must be a string, an array with named options is not wanted here.

So only the documentation should be changed. Regards, Hagen

Posted by Thomas Weidner (thomas) on 2011-04-26T20:02:40.000+0000

The attached docu page is from Zend_Locale and not from Zend_Date. The given parameters work for Zend_Locale but for Zend_Date only the first parameter is allowed to be an array.

Posted by Hagen Hübel (haghue) on 2011-04-26T20:08:28.000+0000

Hi Thomas, thanx for reply.

you're right, but the docu has still the wrong example code using an array as second parameter for Zend_Date (and this is the point i told you from):

Line 7: $dateObject = Zend_Date('13.04.2006', array('date_format' => 'dd.MM.yyyy'));

Posted by Thomas Weidner (thomas) on 2011-04-26T20:18:23.000+0000

Changing issue type from "bug" to "docs problem"

Posted by Frank Brückner (frosch) on 2013-01-17T12:48:32.000+0000

Fixed on trunk (25220) and release-1.12 (25221)

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts