wp-media / backwpup

BackWPup - WordPress Backup Plugin
https://backwpup.com
GNU General Public License v2.0
88 stars 35 forks source link

PHP Error: $this can not be used in static methods #67

Closed alexclst closed 3 years ago

alexclst commented 6 years ago

When opening my development workspace that happens to have BackWPup in it (as it is a clone of a live site) I realized that VS Code is complaining about a use of $this in a static function in BackWPup. See the full error below:

{
    "resource": "app/public/wp-content/plugins/backwpup/inc/class-job.php",
    "owner": "_generated_diagnostic_collection_name_#0",
    "code": "undefined",
    "severity": 8,
    "message": "$this can not be used in static methods.",
    "source": "php",
    "startLineNumber": 1165,
    "startColumn": 5,
    "endLineNumber": 1165,
    "endColumn": 10
}

From my own experience I’m pretty sure that to fix this you need to make the log() function a static. Within static functions you simply cannot use $this, as those are two different scopes/modes of the code.

Anyhow, I thought that I’d mention this, in case it is a real problem that you want to fix.

widoz commented 5 years ago

Hi @alexclst please try with the latest 3.6.7 version. I looked into the class but I haven't found any use of $this within a static context.

cuongdcdev commented 3 years ago

no response so I mark it as closed.