•  
      request #44436 Disallow usage of self:: to call non-static expectations
    Infos
    #44436
    Joris MASSON (jmasson)
    2025-08-21 09:54
    2025-08-20 15:13
    46148
    Details
    Disallow usage of self:: to call non-static expectations

    In PHPUnit, since the version bumps, some methods have probably changed from static to non-static. It is common to find calls such as the following:

    self::expectException(SomeException::class);
    self::expectExceptionMessage('Some message');
    self::expectExceptionCode(400);
    

    Each of these calls "works" but those functions are not static, so it is technically calling an instance method. The [EA] inspections in PHPStorm IDE raises a warning on this, stating that $this-> should be used instead.

    We should add a PHPCS sniff and fixer to automatically disallow that.

    Follow-up of request #42633.

    Dev tools
    All
    Empty
    • [ ] enhancement
    • [x] internal improvement
    Empty
    Stage
    Joris MASSON (jmasson)
    Closed
    2025-08-21
    Attachments
    Empty
    References

    Follow-ups

    User avatar
    Joris MASSON (jmasson)2025-08-20 16:37

    • Status changed from Under implementation to Under review
    • Is an Enhancement or an internal improvement? set to internal improvement