phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

Introduce `__stringnotstringable`

Open VincentLanglet opened this issue 4 months ago • 0 comments

Naming to debate ? __stringwithoutstringable ? __strictstring ?

intval($stringable) is never allowed, even without strict_types.

The current check in FunctionCallParameterCheck is

$this->ruleLevelHelper->accepts($parameterType, $argumentValueType, $scope->isDeclareStrictTypes());

either we're doing something like

$this->ruleLevelHelper->accepts(
      $parameterType,
      $argumentValueType,
      $scope->isDeclareStrictTypes() || in_array($functionName, ['floatval', 'intval', 'doubleval'], true)
);

either we have to introduce the opposite of StringAlwaysAcceptingObjectWithToStringType like I did.

Closes https://github.com/phpstan/phpstan/issues/6560 Closes https://github.com/phpstan/phpstan-src/pull/1005

VincentLanglet avatar Oct 19 '25 18:10 VincentLanglet