?
avatar pablogadino
pablogadino
12 Jan 2020

Steps to reproduce the issue

use Joomla\CMS\Factory;
$input = Factory::getApplication()->input;
$input->set('p1', "poronga");
$p1AsStr = $input->getString('p1'); // 'poronga',ok
$p1AsInt = $input->getInt('p1'); // 0, ok
$input->set('p2', ["poronga","pirincho"]);
$p2AsArr = $input->getArray('p2'); // ['poronga','pirincho'], ok
$p2AsStr = $input->getString('p2');

Expected result

string

Actual result

['poronga','pirincho']

System information (as much as possible)

PHP Built On Linux Linux-4 5.0.0-37-generic #40~18.04.1-Ubuntu SMP Thu Nov 14 12:06:39 UTC 2019 x86_64
Database Type mysql
Database Version 5.7.28-0ubuntu0.18.04.4
Database Collation latin1_swedish_ci
Database Connection Collation utf8mb4_general_ci
PHP Version 7.2.24-0ubuntu0.18.04.1
Web Server Apache/2.4.29 (Ubuntu)
WebServer to PHP Interface apache2handler
Joomla! Version Joomla! 3.9.14 Stable [ Amani ] 17-December-2019 15:00 GMT
Joomla! Platform Version Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT

Additional comments

api.joomla.org/cms-3/classes/Joomla.Input.Input.html#method_getString says:
getString(mixed $name, = $default) : string

some on getInt

avatar pablogadino pablogadino - open - 12 Jan 2020
avatar joomla-cms-bot joomla-cms-bot - labeled - 12 Jan 2020
avatar mbabker
mbabker - comment - 12 Jan 2020

The filter API supports being given an array and applying the selected filter to all elements within it. So, the input API behavior is correct.

avatar pablogadino
pablogadino - comment - 12 Jan 2020

¿doc is wrong?

avatar HLeithner HLeithner - change - 13 Jan 2020
Status New Closed
Closed_Date 0000-00-00 00:00:00 2020-01-13 08:23:09
Closed_By HLeithner
avatar HLeithner
HLeithner - comment - 13 Jan 2020
avatar HLeithner HLeithner - close - 13 Jan 2020
avatar mbabker
mbabker - comment - 13 Jan 2020

The PHP doc blocks should be updated in the Joomla\CMS\Input\Input and Joomla\Input\Input classes to reflect that Joomla\Filter\InputFilter can return arrays, it's not only the docs wiki that needs this update.

Add a Comment

Login with GitHub to post a comment