Menu

#1337 Using $this when not in object context

None
closed-fixed
php (58)
5
2021-12-29
2013-09-30
No

I am getting the following error:

$ php -d enable_dl=On test.php
PHP Fatal error: Using $this when not in object context in demo.php on line 90

swig generates:

static function create_concrete() {
    $r=base_create_concrete();
    $this->_cPtr = $r;
    return $this;
}

for the following input C++ code:

struct base
{
virtual void foo() = 0;
static base * create_concrete();
};

Full example is at:
https://github.com/malaterre/PublicRep/tree/master/SWIG/virtualbase

Discussion

  • Olly Betts

    Olly Betts - 2013-12-12

    I'm not really clear how this differs from #1338 - you seem to have linked to the same example code from both...

    It would make investigating easier if the code to reproduce was minimal, and included in the ticket, rather than on some external site as part of a larger codebase.

     
  • Olly Betts

    Olly Betts - 2013-12-12
    • labels: --> php
    • assigned_to: Olly Betts
    • Group: -->
     
  • Olly Betts

    Olly Betts - 2021-12-29
    • status: open --> closed-fixed
     
  • Olly Betts

    Olly Betts - 2021-12-29

    We no longer generate this PHP code (or indeed any PHP code) not use a special _cPtr property, so this will have been fixed by the change to use PHP's C API to wrap classes.

     

Log in to post a comment.