Parse error on line (new());

Hello group,
i have a parse error saying “(” not expected.
i modified the line with

new $thisInstance ;

error fixed but i would like to understand better.

Question #1 -
i understand the comment syntax as /* blablabla /
but
using a /
* to start a long comment, make some parameter in color in VSCode
WHY?

Question #2 -
In the Class registry below,

why 3 SELF are used ???

Thank’s in advance.

class Registry {
public $factory = null;
public $data = array( );
public $db = null;
public $config = null;
public $language = null;

/**
 * Load the factory
 * @param object $factory
 * @return Registry
 */
function __construct($factory) {
	$this->factory = $factory;
}

/**
 * Get the registry instance
 * @return Registry
 */
function getInstance() {
	self;

	if ($thisInstance == null) {
		self;
		Registry;
		Factory;
		( new (  ) );
		$thisInstance = new null;
	}

	self;
	return $thisInstance;
}

The code you’ve given isn’t valid PHP. Where did you find it?

Also, // in PHP will comment out one line. /* … */ will comment out multiple lines inclusive.

from my wordpress files after upgrade of php and wordpress somehow

understand but why if i do /** to start multiline comments, i have vscode color some first line saying they are @parameter objects and @ return to registry with color indication?

What do you mean “vscode”??? Are you using Visual Studio to edit your code with?
@ at a beginning of a line usually means to SUPPRESS errors for that line. In a comment, I have no idea what it might mean. I do not understand why someone would suppress something inside of a comment.
Makes no sense…

yes i am using Visual Studio Code and @ starting line showed me color

Well, that is NOT a PHP code. You need to use a PHP IDE instead. Or remove all the illegal PHP code.
If you have money, use PHPStorm or for free use Netbeans. You can use VS, but, colors mean little in PHP. And, you can not just add @'s at the beginning of PHP code. It is not valid. Well, it does work on some lines where you load data from files, but, not the way you have it listed.
And, this line: ( new ( ) ); Is not a valid line. And, the "self; " is not a command. It is, but not the way you have it. Are you converting someone else’s code?

And, what are you attempting to do? Getting an instance from a function or store data in a construct.
If you are trying to save your data in a class to use elsewhere, here is an example of how one person did it. I am weak with classes, but, someone else can probably assist. registry-class

Hi Skawid , any idea how to fix this issue? from php upgrade 5 to 7 i start to have trouble to access my admin directory to get access to my database than error saying ioncube encription in ver5 not giving access. I finally decripted all those file to be able to read them and the issue above is coming from there.

i simply do not understand the 3 time self used there

Well, ioncube encryption protects your files on your server, it is aimed at a certain version of PHP. So, moving from PHP5 to PHP7, you might need to reinstall ioncube. I looked at the forum.ioncube.com and others have had this problem when they upgraded to PHP 7. They mentioned that you should get the error messages from PHP/ioncube and open a support ticket showing the errors.

Good luck…

The three time self is invalid PHP. The rest of the code is either invalid or incomprehensible. It literally makes no sense at all. I think the code is trying to implement a singleton pattern, but that’s just from the variable and class names.

Oh, VS just auto-formatted it and caused the “colors”. He should switch to a real PHP editor and see what his errors are and fix them.

Thank you ErnieAlex , i will check on this. :grinning:

Sponsor our Newsletter | Privacy Policy | Terms of Service