Skip to content

Commit

Permalink
Merge branch '4.4-dev' into providers/plugins/system
Browse files Browse the repository at this point in the history
  • Loading branch information
laoneo committed Apr 12, 2023
2 parents e2f068a + 73793b3 commit 0f8ccc7
Show file tree
Hide file tree
Showing 38 changed files with 278 additions and 139 deletions.
7 changes: 3 additions & 4 deletions administrator/components/com_admin/src/Model/HelpModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class HelpModel extends BaseDatabaseModel
* @var array
* @since 1.6
*/
protected $toc = null;
protected $toc = [];

/**
* URL for the latest version check
Expand Down Expand Up @@ -128,7 +128,7 @@ public function getLangTag()
*/
public function &getToc()
{
if (!\is_null($this->toc)) {
if (\count($this->toc)) {
return $this->toc;
}

Expand All @@ -152,8 +152,7 @@ public function &getToc()
}

// Get Help files
$files = Folder::files(JPATH_BASE . '/help/' . $lang_tag, '\.xml$|\.html$');
$this->toc = [];
$files = Folder::files(JPATH_BASE . '/help/' . $lang_tag, '\.xml$|\.html$');

foreach ($files as $file) {
$buffer = file_get_contents(JPATH_BASE . '/help/' . $lang_tag . '/' . $file);
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_finder/src/Indexer/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public static function addContentType($title, $mime = null)
*/
public static function isCommon($token, $lang)
{
static $data, $default, $multilingual;
static $data = [], $default, $multilingual;

if (is_null($multilingual)) {
$multilingual = Multilanguage::isEnabled();
Expand Down Expand Up @@ -348,7 +348,7 @@ public static function getDefaultLanguage()
*/
public static function getPrimaryLanguage($lang)
{
static $data;
static $data = [];

// Only parse the identifier if necessary.
if (!isset($data[$lang])) {
Expand Down
10 changes: 3 additions & 7 deletions components/com_contact/src/Model/ContactModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class ContactModel extends FormModel
/**
* A loaded item
*
* @var \stdClass
* @var \stdClass[]
* @since 1.6
*/
protected $_item = null;
protected $_item = [];

/**
* Model context string.
Expand Down Expand Up @@ -111,7 +111,7 @@ public function getForm($data = [], $loadData = true)
}

$temp = clone $this->getState('params');
$contact = $this->_item[$this->getState('contact.id')];
$contact = $this->getItem($this->getState('contact.id'));
$active = Factory::getContainer()->get(SiteApplication::class)->getMenu()->getActive();

if ($active) {
Expand Down Expand Up @@ -177,10 +177,6 @@ public function getItem($pk = null)
{
$pk = $pk ?: (int) $this->getState('contact.id');

if ($this->_item === null) {
$this->_item = [];
}

if (!isset($this->_item[$pk])) {
try {
$db = $this->getDatabase();
Expand Down
8 changes: 4 additions & 4 deletions libraries/src/Client/FtpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ public function listDetails($path = null, $type = 'all')
// Here is where it is going to get dirty....
if ($osType === 'UNIX' || $osType === 'MAC') {
foreach ($contents as $file) {
$tmp_array = null;
$tmp_array = [];

if (@preg_match($regexp, $file, $regs)) {
$fType = (int) strpos('-dl', $regs[1][0]);
Expand Down Expand Up @@ -1523,13 +1523,13 @@ public function listDetails($path = null, $type = 'all')
continue;
}

if (\is_array($tmp_array) && $tmp_array['name'] != '.' && $tmp_array['name'] != '..') {
if (\count($tmp_array) && $tmp_array['name'] != '.' && $tmp_array['name'] != '..') {
$dir_list[] = $tmp_array;
}
}
} else {
foreach ($contents as $file) {
$tmp_array = null;
$tmp_array = [];

if (@preg_match($regexp, $file, $regs)) {
$fType = (int) ($regs[7] === '<DIR>');
Expand Down Expand Up @@ -1558,7 +1558,7 @@ public function listDetails($path = null, $type = 'all')
continue;
}

if (\is_array($tmp_array) && $tmp_array['name'] != '.' && $tmp_array['name'] != '..') {
if (\count($tmp_array) && $tmp_array['name'] != '.' && $tmp_array['name'] != '..') {
$dir_list[] = $tmp_array;
}
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Document/OpensearchDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class OpensearchDocument extends Document
*
* optional
*
* @var object
* @var object[]
* @since 1.7.0
*/
private $_images = [];
Expand Down
4 changes: 2 additions & 2 deletions libraries/src/Filter/InputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,9 @@ protected static function decodeFileData(array $data)
*/
protected function decode($source)
{
static $ttr;
static $ttr = [];

if (!\is_array($ttr)) {
if (!\count($ttr)) {
// Entity decode
$trans_tbl = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT, 'ISO-8859-1');

Expand Down
50 changes: 25 additions & 25 deletions libraries/src/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Form
/**
* The form object errors array.
*
* @var array
* @var \Exception[]
* @since 1.7.0
*/
protected $errors = [];
Expand Down Expand Up @@ -184,7 +184,7 @@ protected function bindLevel($group, $data)
/**
* Return all errors, if any.
*
* @return array Array of error messages or RuntimeException objects.
* @return \Exception[] Array of error messages or RuntimeException objects.
*
* @since 1.7.0
*/
Expand Down Expand Up @@ -303,7 +303,7 @@ public function getFieldset($set = null)
*
* @param string $group The dot-separated form group path on which to filter the fieldsets.
*
* @return array The array of fieldset objects.
* @return object[] The array of fieldset objects.
*
* @since 1.7.0
*/
Expand Down Expand Up @@ -570,10 +570,10 @@ public function renderFieldset($name, $options = [])
* field being loaded. If it is false, then the new field being loaded will be ignored and the
* method will move on to the next field to load.
*
* @param string $data The name of an XML string or object.
* @param boolean $replace Flag to toggle whether form fields should be replaced if a field
* already exists with the same group/name.
* @param string $xpath An optional xpath to search for the fields.
* @param string|\SimpleXMLElement $data The name of an XML string or object.
* @param boolean $replace Flag to toggle whether form fields should be replaced if a field
* already exists with the same group/name.
* @param string $xpath An optional xpath to search for the fields.
*
* @return boolean True on success, false otherwise.
*
Expand All @@ -582,7 +582,7 @@ public function renderFieldset($name, $options = [])
public function load($data, $replace = true, $xpath = null)
{
// If the data to load isn't already an XML element or string return false.
if ((!($data instanceof \SimpleXMLElement)) && (!\is_string($data))) {
if (!($data instanceof \SimpleXMLElement) && !\is_string($data)) {
return false;
}

Expand Down Expand Up @@ -908,10 +908,10 @@ public function setFieldAttribute($name, $attribute, $value, $group = null)
* the fields will be set whether they already exists or not. If it isn't set, then the fields
* will not be replaced if they already exist.
*
* @param array &$elements The array of XML element object representations of the form fields.
* @param string $group The optional dot-separated form group path on which to set the fields.
* @param boolean $replace True to replace existing fields if they already exist.
* @param string $fieldset The name of the fieldset we are adding the field to.
* @param \SimpleXMLElement[] &$elements The array of XML element object representations of the form fields.
* @param string $group The optional dot-separated form group path on which to set the fields.
* @param boolean $replace True to replace existing fields if they already exist.
* @param string $fieldset The name of the fieldset we are adding the field to.
*
* @return boolean True on success.
*
Expand Down Expand Up @@ -1130,7 +1130,7 @@ public function validate($data, $group = null)
$this->errors[] = $valid;
$return = false;
}
} elseif (!$fieldObj && $input->exists($key)) {
} elseif ($input->exists($key)) {
// The field returned false from setup and shouldn't be included in the page body - yet we received
// a value for it. This is probably some sort of injection attack and should be rejected
$this->errors[] = new \RuntimeException(Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', $key));
Expand Down Expand Up @@ -1377,7 +1377,7 @@ protected function &findGroup($group)
// Make sure there is actually a group to find.
$group = explode('.', $group);

if (!empty($group)) {
if (count($group)) {
// Get any fields elements with the correct group name.
$elements = $this->xml->xpath('//fields[@name="' . (string) $group[0] . '" and not(ancestor::field/form/*)]');

Expand Down Expand Up @@ -1429,9 +1429,9 @@ protected function &findGroup($group)
/**
* Method to load, setup and return a FormField object based on field data.
*
* @param string $element The XML element object representation of the form field.
* @param string $group The optional dot-separated form group path on which to find the field.
* @param mixed $value The optional value to use as the default for the field.
* @param string|\SimpleXMLElement $element The XML element object representation of the form field.
* @param string $group The optional dot-separated form group path on which to find the field.
* @param mixed $value The optional value to use as the default for the field.
*
* @return FormField|boolean The FormField object for the field or boolean false on error.
*
Expand Down Expand Up @@ -1595,9 +1595,9 @@ protected function syncPaths()
/**
* Proxy for {@link FormHelper::addFieldPath()}.
*
* @param mixed $new A path or array of paths to add.
* @param string|string[] $new A path or array of paths to add.
*
* @return array The list of paths that have been added.
* @return string[] The list of paths that have been added.
*
* @since 1.7.0
*/
Expand All @@ -1609,9 +1609,9 @@ public static function addFieldPath($new = null)
/**
* Proxy for FormHelper::addFormPath().
*
* @param mixed $new A path or array of paths to add.
* @param string|string[] $new A path or array of paths to add.
*
* @return array The list of paths that have been added.
* @return string[] The list of paths that have been added.
*
* @see FormHelper::addFormPath()
* @since 1.7.0
Expand All @@ -1624,9 +1624,9 @@ public static function addFormPath($new = null)
/**
* Proxy for FormHelper::addRulePath().
*
* @param mixed $new A path or array of paths to add.
* @param string|string[] $new A path or array of paths to add.
*
* @return array The list of paths that have been added.
* @return string[] The list of paths that have been added.
*
* @see FormHelper::addRulePath()
* @since 1.7.0
Expand All @@ -1639,9 +1639,9 @@ public static function addRulePath($new = null)
/**
* Proxy for FormHelper::addFilterPath().
*
* @param mixed $new A path or array of paths to add.
* @param string|string[] $new A path or array of paths to add.
*
* @return array The list of paths that have been added.
* @return string[] The list of paths that have been added.
*
* @see FormHelper::addFilterPath()
* @since 4.0.0
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/FormFactoryAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function getFormFactory(): FormFactoryInterface
/**
* Set the form factory to use.
*
* @param FormFactoryInterface $formFactory The form factory to use.
* @param ?FormFactoryInterface $formFactory The form factory to use.
*
* @return $this
*
Expand Down
26 changes: 13 additions & 13 deletions libraries/src/Form/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ protected function getLabel()
$data = $this->getLayoutData();

// Forcing the Alias field to display the tip below
$position = $this->element['name'] === 'alias' ? ' data-bs-placement="bottom" ' : '';
$position = ((string) $this->element['name']) === 'alias' ? ' data-bs-placement="bottom" ' : '';

// Here mainly for B/C with old layouts. This can be done in the layouts directly
$extraData = [
Expand Down Expand Up @@ -1039,10 +1039,10 @@ public function renderField($options = [])
/**
* Method to filter a field value.
*
* @param mixed $value The optional value to use as the default for the field.
* @param string $group The optional dot-separated form group path on which to find the field.
* @param Registry $input An optional Registry object with the entire data set to filter
* against the entire form.
* @param mixed $value The optional value to use as the default for the field.
* @param string $group The optional dot-separated form group path on which to find the field.
* @param ?Registry $input An optional Registry object with the entire data set to filter
* against the entire form.
*
* @return mixed The filtered value.
*
Expand Down Expand Up @@ -1118,10 +1118,10 @@ public function filter($value, $group = null, Registry $input = null)
/**
* Method to validate a FormField object based on field data.
*
* @param mixed $value The optional value to use as the default for the field.
* @param string $group The optional dot-separated form group path on which to find the field.
* @param Registry $input An optional Registry object with the entire data set to validate
* against the entire form.
* @param mixed $value The optional value to use as the default for the field.
* @param string $group The optional dot-separated form group path on which to find the field.
* @param ?Registry $input An optional Registry object with the entire data set to validate
* against the entire form.
*
* @return boolean|\Exception Boolean true if field value is valid, Exception on failure.
*
Expand Down Expand Up @@ -1229,10 +1229,10 @@ public function validate($value, $group = null, Registry $input = null)
/**
* Method to post-process a field value.
*
* @param mixed $value The optional value to use as the default for the field.
* @param string $group The optional dot-separated form group path on which to find the field.
* @param Registry $input An optional Registry object with the entire data set to filter
* against the entire form.
* @param mixed $value The optional value to use as the default for the field.
* @param string $group The optional dot-separated form group path on which to find the field.
* @param ?Registry $input An optional Registry object with the entire data set to filter
* against the entire form.
*
* @return mixed The processed value.
*
Expand Down
4 changes: 2 additions & 2 deletions libraries/src/Form/FormFilterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ interface FormFilterInterface
* @param string $group The field name group control value. This acts as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param Registry $input An optional Registry object with the entire data set to validate against the entire form.
* @param Form $form The form object for which the field is being tested.
* @param ?Registry $input An optional Registry object with the entire data set to validate against the entire form.
* @param ?Form $form The form object for which the field is being tested.
*
* @return mixed The filtered value.
*
Expand Down

0 comments on commit 0f8ccc7

Please sign in to comment.