Best practice depends on where the code is placed.

OOP Code

Use $this->t()

See 8 - Best practice: $this->t() versus t() - Drupal Answers

Comments

lolandese created an issue. See original summary.

sergiu stici’s picture

In static function we can not use "$this" because object does not exist.

liam morland’s picture

Status: Active » Closed (duplicate)

I think these have all been fixed, such as by #2948324: Fix Drupal best practices in code. If not, please re-open and use an issue fork and merge request.