Skip to content
New issue

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

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

Already on GitHub? Sign in 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
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
…::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
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants