Use new static self in s3 plugin

Created on 9 May 2024, 7 months ago
Updated 10 June 2024, 6 months ago

Problem/Motivation

In Drupal core, the best practice is to use new static in general (instead of new self). Previously, using new static was detected as a security issue.

We had a problem extending the class \Drupal\flysystem_s3\Flysystem\S3.
Due to the new self usage, it would now be necessary to (over)write the create() method, which would be an identical copy of the parent's class.

Steps to reproduce

Try to extend the S3 class; as a result, you will see that an instance of \Drupal\flysystem_s3\Flysystem\S3 will always be returned unless you copy-paste the create method.

Proposed resolution

Adhere to Drupal core best practices, and use return new static().

🐛 Bug report
Status

RTBC

Version

2.1

Component

Code

Created by

🇳🇱Netherlands Richard Hoogstad

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024