privateconstERR_UNTRANSLATED_INCOMPATIBLE_ARGUMENT=1306;// E.g. passing a string where an int is expected
privateconstERR_UNTRANSLATED_INCOMPATIBLE_ARGUMENT_WEAK=1307;// E.g. passing an int where a string is expected
privateconstERR_UNTRANSLATED_WIDTH_INSTEAD_OF_POSITION=1308;// e.g. _('%1s'). Change to _('%1$1s' if you really mean that the width is 1, add positions for others ('%2$s', etc.)
"Format string {STRING_LITERAL} contains something that is not a percent sign, it will be treated as a format string '{STRING_LITERAL}' with padding of \"{STRING_LITERAL}\" and alignment of '{STRING_LITERAL}' but no width. Use {DETAILS} for a literal percent sign, or '{STRING_LITERAL}' to be less ambiguous",
'Format string {STRING_LITERAL} refers to argument #{INDEX} as {DETAILS}, so type {TYPE} is expected. However, {FUNCTION} was passed the type {TYPE} (which is weaker than {TYPE})',
[
self::encodeString($fmt_str),
$i,
self::getSpecStringsRepresentation($spec_group),
$expected_union_type_string,
$function->getName(),
(string)$actual_union_type,
$expected_union_type_string,
],
Issue::SEVERITY_LOW,
self::ERR_UNTRANSLATED_INCOMPATIBLE_ARGUMENT_WEAK
);
}else{
// This can be resolved by casting the arg to (int) manually in printf.
$emit_issue(
'PhanPluginPrintfIncompatibleArgumentType',
'Format string {STRING_LITERAL} refers to argument #{INDEX} as {DETAILS}, so type {TYPE} is expected, but {FUNCTION} was passed incompatible type {TYPE}',
[
self::encodeString($fmt_str),
$i,
self::getSpecStringsRepresentation($spec_group),
$expected_union_type_string,
$function->getName(),
(string)$actual_union_type,
],
Issue::SEVERITY_LOW,
self::ERR_UNTRANSLATED_INCOMPATIBLE_ARGUMENT
);
}
}
}
// Make sure the translations are compatible with this format string.
// In order to take advantage of the ability to analyze translations, override gettextForAllLocales
'Translated string {STRING_LITERAL} has local {DETAILS} which refers to argument #{INDEX} as {STRING_LITERAL}, but the original format string treats it as {DETAILS} (ORIGINAL: {STRING_LITERAL}, TRANSLATION: {STRING_LITERAL})',
[
self::encodeString($fmt_str),
$locale,
$i,
$canonical,
$expected_types,
self::encodeString($fmt_str),
self::encodeString($translated_fmt_str),
],
$severity,
Issue::REMEDIATION_B,
$issue_type_id
);
}
}
}
}
}
}
/**
* Represents the information we have about the result of evaluating an expression.
* Currently, used only for printf arguments.
*/
classPrimitiveValue
{
/** @var array|int|string|float|bool|null The primitive value of the expression if it could be determined. */
public$value;
/** @var bool Whether or not the expression value was translated. */