Make WordPress Core


Ignore:
Timestamp:
02/02/2024 08:22:11 PM (17 months ago)
Author:
gziolo
Message:

Editor: Refactor the way block bindings sources are handled

It fixes the coding style issues reported. It goes further and improves the code quality it other places where the logic for block bindings was added.

Follow-up for [57514].
Props: gziolo, mukesh27, youknowriad, santosguillamot.
See #60282.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block-bindings-registry.php

    r57514 r57526  
    5858     *                                                                              i.e. {"key": "foo"}.
    5959     *                                            - @param WP_Block $block_instance The block instance.
    60      *                                            - @param string   $attribute_name The name of an attribute .
     60     *                                            - @param string   $attribute_name The name of the target attribute.
    6161     *                                        The callback has a mixed return type; it may return a string to override
    6262     *                                        the block's original value, null, false to remove an attribute, etc.
     
    6464     * @return array|false Source when the registration was successful, or `false` on failure.
    6565     */
    66     public function register( $source_name, array $source_properties ) {
     66    public function register( string $source_name, array $source_properties ) {
    6767        if ( ! is_string( $source_name ) ) {
    6868            _doing_it_wrong(
     
    121121     * @return array|false The unregistered block bindings source on success and `false` otherwise.
    122122     */
    123     public function unregister( $source_name ) {
     123    public function unregister( string $source_name ) {
    124124        if ( ! $this->is_registered( $source_name ) ) {
    125125            _doing_it_wrong(
     
    157157     * @return array|null The registered block bindings source, or `null` if it is not registered.
    158158     */
    159     public function get_registered( $source_name ) {
     159    public function get_registered( string $source_name ) {
    160160        if ( ! $this->is_registered( $source_name ) ) {
    161161            return null;
Note: See TracChangeset for help on using the changeset viewer.