Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix PHP8.1 sfForm - Unsupported operand types: array + null on sfForm #281

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

Tybaze
Copy link
Collaborator

@Tybaze Tybaze commented Feb 14, 2023

Fix PHP8.1 sfForm - Unsupported operand types: array + null on sfForm::updateValues()

Avoid error :
Fatal error: Uncaught TypeError: Unsupported operand types: array + null in lib\form\sfForm.class.php:319

Step to reproduce :
$form = new sfForm();
$form->updateValues(array('foo' => 'value'));

PHP 5.3 coding style

May use sfForm::getValues(), but as sfForm::updateValues() is a hack, it could be used before bind ($this->isBound = true);

@@ -316,7 +316,7 @@ public function isBound()
*/
public function updateValues(array $values)
{
$this->values = $values + $this->values;
$this->values = $values + (isset($this->values) ? $this->values : array());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about setting the initial value of $values to array()?

protected $values = null;

@thePanz thePanz force-pushed the fix_sfform_php8.1 branch from c8cadb4 to 7f4be9b Compare January 3, 2024 10:47
@thePanz
Copy link
Member

thePanz commented Jan 3, 2024

@Tybaze I updated this PR according to the comments (and rebased on the latest master branch)
Let me know if this fixes the error on your side and can be merged

@thePanz thePanz requested review from thirsch and connorhu and removed request for thirsch January 3, 2024 10:52
@thePanz thePanz force-pushed the fix_sfform_php8.1 branch from 7f4be9b to accb231 Compare January 3, 2024 14:35
@thePanz thePanz force-pushed the fix_sfform_php8.1 branch from accb231 to 141129d Compare January 3, 2024 15:55
…::updateValues()

Avoid error:
Fatal error: Uncaught TypeError: Unsupported operand types: array + null in lib\form\sfForm.class.php:319

Step to reproduce :
$form = new sfForm();
$form->updateValues(array('foo' => 'value'));

PHP 5.3 coding style

May use sfForm::getValues(), but as sfForm::updateValues() is a hack, it could be used before bind ($this->isBound = true);
@thePanz thePanz merged commit b88d698 into FriendsOfSymfony1:master Jan 17, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants