laminas-code icon indicating copy to clipboard operation
laminas-code copied to clipboard

Fix PropertyTag::setPropertyName() deprecation warning

Open lifinsky opened this issue 1 year ago • 2 comments

ErrorException: Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated
#18 /vendor/laminas/laminas-code/src/Generator/DocBlock/Tag/ParamTag.php(55): Laminas\Code\Generator\DocBlock\Tag\ParamTag::setVariableName
#17 /vendor/laminas/laminas-code/src/Generator/DocBlock/TagManager.php(59): Laminas\Code\Generator\DocBlock\TagManager::createTagFromReflection
#16 /vendor/laminas/laminas-code/src/Generator/DocBlockGenerator.php(48): Laminas\Code\Generator\DocBlockGenerator::fromReflection
#15 /vendor/laminas/laminas-code/src/Generator/MethodGenerator.php(47): Laminas\Code\Generator\MethodGenerator::fromReflection

lifinsky avatar Feb 27 '25 19:02 lifinsky

@alexmerlin

lifinsky avatar Apr 03 '25 07:04 lifinsky

@Ocramius are you able to help to push that forward?

dgafka avatar Apr 18 '25 16:04 dgafka

@gsteel

lifinsky avatar Oct 21 '25 00:10 lifinsky

@lifinsky null is not an acceptable parameter here.

Simply casting with (string) because it might receive a null argument introduces the probability that someone will send an array and we'll have a PHP warning for array to string conversion.

Done

lifinsky avatar Oct 21 '25 21:10 lifinsky

@gsteel The linter didn’t allow casting to (string) because it’s redundant — PHPDoc already defines it as a string. I replaced it with !empty, as done elsewhere.

lifinsky avatar Oct 21 '25 21:10 lifinsky

@gsteel use cast is needed to keep existing behaviour, except it needs to go to 4.0.0

samsonasik avatar Nov 01 '25 09:11 samsonasik

I am going to close this, this is expected, as signature is string, which not allow null, even docblock should be respected by the app that uses it.

The refactor will require major version.

Thank you for understanding.

samsonasik avatar Nov 04 '25 12:11 samsonasik