[wp-trac] [WordPress Trac] #61374: HTML Processor: ::create_fragment returns self when subclassed
WordPress Trac
noreply at wordpress.org
Wed Jun 5 07:43:54 UTC 2024
#61374: HTML Processor: ::create_fragment returns self when subclassed
--------------------------+-----------------------------
Reporter: jonsurrell | Owner: jonsurrell
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: HTML API | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
In a subclass of `WP_HTML_Processor` when an instance is created from the
static `::create_fragment` method the instance will be an instance of
`WP_HTML_Processor` and ''not'' and instance of the subclass:
{{{#!php
<?php
class Sub extends WP_HTML_Processor {}
$processor = Sub::create_fragment( '<div>' );
get_class( $processor ); // "WP_HTML_Processor" !!
}}}
It's very unlikely that the parent class instance is intended to be
created from the subclass.
This can be fixed by creating `static` from the `::create_fragment`
method.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61374>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list