for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
/**
* @license http://opensource.org/licenses/mit-license.php MIT
* @link https://github.com/nicoSWD
* @author Nicolas Oelgart <[email protected]>
*/
namespace nicoSWD\Rule\Grammar\JavaScript\Methods;
use nicoSWD\Rule\Grammar\CallableFunction;
use nicoSWD\Rule\TokenStream\Token\BaseToken;
use nicoSWD\Rule\TokenStream\Token\TokenString;
final class Substr extends CallableFunction
{
public function call(?BaseToken ...$parameters): BaseToken
$params = [];
$start = $this->parseParameter($parameters, numParam: 0);
if (!$start) {
$params[] = 0;
} else {
$params[] = (int) $start->getValue();
}
$offset = $this->parseParameter($parameters, numParam: 1);
if ($offset) {
$params[] = (int) $offset->getValue();
$value = substr($this->token->getValue(), ...$params);
$params
$offset
substr()
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
$value = substr($this->token->getValue(), /** @scrutinizer ignore-type */ ...$params);
token
nicoSWD\Rule\Grammar\JavaScript\Methods\Substr
return new TokenString((string) $value);