Skip to content

Commit

Permalink
Remove array syntax changes, remove extends from class definition
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell authored and ockham committed Feb 21, 2023
1 parent 2bbf3b2 commit 53fa006
Showing 1 changed file with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* Example:
* ```php
* $tags = new WP_HTML_Tag_Processor( $html );
* if ( $tags->next_tag( [ 'tag_name' => 'option' ] ) ) {
* if ( $tags->next_tag( array( 'tag_name' => 'option' ) ) ) {
* $tags->set_attribute( 'selected', true );
* }
* ```
Expand All @@ -61,9 +61,9 @@
* | Goal | Query |
* |-----------------------------------------------------------|----------------------------------------------------------------------------|
* | Find any tag. | `$tags->next_tag();` |
* | Find next image tag. | `$tags->next_tag( [ 'tag_name' => 'img' ] );` |
* | Find next tag containing the `fullwidth` CSS class. | `$tags->next_tag( [ 'class_name' => 'fullwidth' ] );` |
* | Find next image tag containing the `fullwidth` CSS class. | `$tags->next_tag( [ 'tag_name' => 'img', 'class_name' => 'fullwidth' ] );` |
* | Find next image tag. | `$tags->next_tag( array( 'tag_name' => 'img' ) );` |
* | Find next tag containing the `fullwidth` CSS class. | `$tags->next_tag( array( 'class_name' => 'fullwidth' ) );` |
* | Find next image tag containing the `fullwidth` CSS class. | `$tags->next_tag( array( 'tag_name' => 'img', 'class_name' => 'fullwidth' ) );` |
*
* If a tag was found meeting your criteria then `next_tag()`
* will return `true` and you can proceed to modify it. If it
Expand Down Expand Up @@ -116,7 +116,7 @@
*
* Example:
* ```php
* if ( $tags->next_tag( [ 'class' => 'wp-group-block' ] ) ) {
* if ( $tags->next_tag( array( 'class' => 'wp-group-block' ) ) ) {
* $tags->set_attribute( 'title', 'This groups the contained content.' );
* $tags->remove_attribute( 'data-test-id' );
* }
Expand Down Expand Up @@ -185,9 +185,9 @@
*
* ```php
* $total_todos = 0;
* while ( $p->next_tag( [ 'tag_name' => 'UL', 'class_name' => 'todo' ] ) ) {
* while ( $p->next_tag( array( 'tag_name' => 'UL', 'class_name' => 'todo' ) ) ) {
* $p->set_bookmark( 'list-start' );
* while ( $p->next_tag( [ 'tag_closers' => 'visit' ] ) ) {
* while ( $p->next_tag( array( 'tag_closers' => 'visit' ) ) ) {
* if ( 'UL' === $p->get_tag() && $p->is_tag_closer() ) {
* $p->set_bookmark( 'list-end' );
* $p->seek( 'list-start' );
Expand Down Expand Up @@ -247,7 +247,7 @@
*
* @since 6.2.0
*/
class Gutenberg_HTML_Tag_Processor_6_3 extends WP_HTML_Tag_Processor {
class Gutenberg_HTML_Tag_Processor_6_3 {
/**
* The maximum number of bookmarks allowed to exist at
* any given time.
Expand Down Expand Up @@ -424,16 +424,16 @@ class Gutenberg_HTML_Tag_Processor_6_3 extends WP_HTML_Tag_Processor {
* // and stops after recognizing the `id` attribute
* // <div id="test-4" class=outline title="data:text/plain;base64=asdk3nk1j3fo8">
* // ^ parsing will continue from this point
* $this->attributes = [
* $this->attributes = array(
* 'id' => new WP_HTML_Attribute_Match( 'id', null, 6, 17 )
* ];
* );
*
* // when picking up parsing again, or when asking to find the
* // `class` attribute we will continue and add to this array
* $this->attributes = [
* $this->attributes = array(
* 'id' => new WP_HTML_Attribute_Match( 'id', null, 6, 17 ),
* 'class' => new WP_HTML_Attribute_Match( 'class', 'outline', 18, 32 )
* ];
* );
*
* // Note that only the `class` attribute value is stored in the index.
* // That's because it is the only value used by this class at the moment.
Expand All @@ -458,11 +458,11 @@ class Gutenberg_HTML_Tag_Processor_6_3 extends WP_HTML_Tag_Processor {
* Example:
* ```php
* // Add the `wp-block-group` class, remove the `wp-group` class.
* $classname_updates = [
* $classname_updates = array(
* // Indexed by a comparable class name
* 'wp-block-group' => WP_HTML_Tag_Processor::ADD_CLASS,
* 'wp-group' => WP_HTML_Tag_Processor::REMOVE_CLASS
* ];
* );
* ```
*
* @since 6.2.0
Expand Down Expand Up @@ -518,9 +518,9 @@ class Gutenberg_HTML_Tag_Processor_6_3 extends WP_HTML_Tag_Processor {
* $modifications[] = new WP_HTML_Text_Replacement( $start, $end, $new_value );
*
* // Correspondingly, something like this will appear in this array.
* $lexical_updates = [
* $lexical_updates = array(
* WP_HTML_Text_Replacement( 14, 28, 'https://my-site.my-domain/wp-content/uploads/2014/08/kittens.jpg' )
* ];
* );
* ```
*
* @since 6.2.0
Expand Down Expand Up @@ -660,7 +660,7 @@ public function next_tag( $query = null ) {
*
* $p = new WP_HTML_Tag_Processor( $html );
* $in_list = false;
* while ( $p->next_tag( [ 'tag_closers' => $in_list ? 'visit' : 'skip' ] ) ) {
* while ( $p->next_tag( array( 'tag_closers' => $in_list ? 'visit' : 'skip' ) ) ) {
* if ( 'UL' === $p->get_tag() ) {
* if ( $p->is_tag_closer() ) {
* $in_list = false;
Expand Down Expand Up @@ -1603,12 +1603,12 @@ private function get_enqueued_attribute_value( $comparable_name ) {
* Example:
* ```php
* $p = new WP_HTML_Tag_Processor( '<div enabled class="test" data-test-id="14">Test</div>' );
* $p->next_tag( [ 'class_name' => 'test' ] ) === true;
* $p->next_tag( array( 'class_name' => 'test' ) ) === true;
* $p->get_attribute( 'data-test-id' ) === '14';
* $p->get_attribute( 'enabled' ) === true;
* $p->get_attribute( 'aria-label' ) === null;
*
* $p->next_tag( [] ) === false;
* $p->next_tag( array() ) === false;
* $p->get_attribute( 'class' ) === null;
* ```
*
Expand Down Expand Up @@ -1686,10 +1686,10 @@ public function get_attribute( $name ) {
* Example:
* ```php
* $p = new WP_HTML_Tag_Processor( '<div data-ENABLED class="test" DATA-test-id="14">Test</div>' );
* $p->next_tag( [ 'class_name' => 'test' ] ) === true;
* $p->next_tag( array( 'class_name' => 'test' ) ) === true;
* $p->get_attribute_names_with_prefix( 'data-' ) === array( 'data-enabled', 'data-test-id' );
*
* $p->next_tag( [] ) === false;
* $p->next_tag( array() ) === false;
* $p->get_attribute_names_with_prefix( 'data-' ) === null;
* ```
*
Expand Down Expand Up @@ -1720,10 +1720,10 @@ function get_attribute_names_with_prefix( $prefix ) {
* Example:
* ```php
* $p = new WP_HTML_Tag_Processor( '<DIV CLASS="test">Test</DIV>' );
* $p->next_tag( [] ) === true;
* $p->next_tag( array() ) === true;
* $p->get_tag() === 'DIV';
*
* $p->next_tag( [] ) === false;
* $p->next_tag( array() ) === false;
* $p->get_tag() === null;
* ```
*
Expand All @@ -1747,10 +1747,10 @@ public function get_tag() {
* Example:
* ```php
* $p = new WP_HTML_Tag_Processor( '<div></div>' );
* $p->next_tag( [ 'tag_name' => 'div', 'tag_closers' => 'visit' ] );
* $p->next_tag( array( 'tag_name' => 'div', 'tag_closers' => 'visit' ) );
* $p->is_tag_closer() === false;
*
* $p->next_tag( [ 'tag_name' => 'div', 'tag_closers' => 'visit' ] );
* $p->next_tag( array( 'tag_name' => 'div', 'tag_closers' => 'visit' ) );
* $p->is_tag_closer() === true;
* ```
*
Expand Down

0 comments on commit 53fa006

Please sign in to comment.