for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* DatabagData.php
*
* Databag metadata for Jaxon classes.
* @package jaxon-core
* @author Thierry Feuzeu <[email protected]>
* @copyright 2025 Thierry Feuzeu <[email protected]>
* @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
* @link https://github.com/jaxon-php/jaxon-core
*/
namespace Jaxon\App\Metadata\Data;
use Jaxon\Exception\SetupException;
use function array_map;
use function preg_match;
class DatabagData extends AbstractData
{
* The databag names
* @var string
protected $aNames = [];
* @return string
public function getName(): string
return 'bags';
}
* @return mixed
public function getValue(): mixed
return $this->aNames;
* @param string $sName
* @return void
protected function validateName(string $sName): void
if(preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sName) > 0)
return;
throw new SetupException("$sName is not a valid \"name\" value for databag");
public function addValue(string $sName): void
$this->validateName($sName);
$this->aNames[] = $sName;
* @inheritDoc
public function encode(string $sVarName): array
return array_map(fn($sName) => "{$sVarName}->addValue('$sName');", $this->aNames);
$this->aNames
string
array
$array
array_map()
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
return array_map(fn($sName) => "{$sVarName}->addValue('$sName');", /** @scrutinizer ignore-type */ $this->aNames);