Skip to content

Fix PHP Deprecation warnings in PHP8+ - #1046

Open
mike-healy wants to merge 3 commits into
archetyped:developfrom
mike-healy:develop
Open

Fix PHP Deprecation warnings in PHP8+#1046
mike-healy wants to merge 3 commits into
archetyped:developfrom
mike-healy:develop

Conversation

@mike-healy

Copy link
Copy Markdown

PHP 8.1 & 8.2 issue some deprecation notices when using Simple Lightbox.
This fixes those warnings without changing functionality.

@bit9labs

Copy link
Copy Markdown

👍 Here for this. Let's fix these bugs instead of saying the solution is to turn off deprecation notices.

function &add( $id, $properties = array(), $update = false ) {
// Create item
$args = func_get_args();
$ret = call_user_func_array( array( 'parent', 'add' ), $args );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I resolved this with this code:

$ret = parent::add(...func_get_args());

I was coming to see if it was implemented.. but I guess both ways work. Cheers!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes, both seem to work. I don't mind updating my PR to that style.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@archetyped do you have a preference, and are you interested in merging this PR?

@digitaldonkey digitaldonkey Apr 17, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I can confirm this being helpful.

But My IDE wants me to change Return type too:

	/**
	 * Add option to collection
	 * @uses SLB_Field_Collection::add() to add item
	 * @param string $id Unique item ID
	 * @param array $properties Item properties
	 * @param bool $update (optional) Should item be updated or overwritten (Default: FALSE)
	 * @return false|object|SLB_Field Option instance
	 */
	function &add( $id, $properties = array(), $update = false ) {
		// Create item
        $ret = parent::add(...func_get_args());
		return $ret;
	}

@EarthmanWeb EarthmanWeb Dec 11, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I addressed this simply as

$ret  = parent::add( ...$args );

In this PR:
#1110

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.

5 participants