WordPress.org

Make WordPress Core

Ticket #6821: 6821.reabstract.diff

File 6821.reabstract.diff, 10.3 KB (added by mikeschroder, 7 years ago)

Re-add Abstract methods. Add lots of PHPDoc, and PHPDoc Fixes.

  • wp-includes/class-wp-image-editor-gd.php

    diff --git wp-includes/class-wp-image-editor-gd.php wp-includes/class-wp-image-editor-gd.php
    index 3e7e43f..ca76006 100644
    class WP_Image_Editor_GD extends WP_Image_Editor { 
    2525        }
    2626
    2727        /**
    28          * Checks to see if current environment supports GD
     28         * Checks to see if current environment supports GD.
    2929         *
    3030         * @since 3.5.0
    3131         * @access public
    class WP_Image_Editor_GD extends WP_Image_Editor { 
    4040        }
    4141
    4242        /**
    43          * Loads image from $this->file into new GD Resource
     43         * Loads image from $this->file into new GD Resource.
    4444         *
    45          * @since 3.5
     45         * @since 3.5.0
    4646         * @access protected
    4747         *
    4848         * @return boolean|\WP_Error
    class WP_Image_Editor_GD extends WP_Image_Editor { 
    7272        }
    7373
    7474        /**
    75          * Sets or updates current image size
     75         * Sets or updates current image size.
    7676         *
    7777         * @since 3.5.0
    7878         * @access protected
    class WP_Image_Editor_GD extends WP_Image_Editor { 
    9191        }
    9292
    9393        /**
    94          * Checks to see if editor supports mime-type specified
     94         * Checks to see if editor supports the mime-type specified.
    9595         *
    9696         * @since 3.5.0
    9797         * @access public
    class WP_Image_Editor_GD extends WP_Image_Editor { 
    107107
    108108        /**
    109109         * Resizes current image.
    110          * Wrapper around _resize, since _resize returns a GD Resource
     110         * Wraps _resize, since _resize returns a GD Resource.
     111         *
     112         * @since 3.5.0
     113         * @access public
    111114         *
    112115         * @param int $max_w
    113116         * @param int $max_h
    class WP_Image_Editor_GD extends WP_Image_Editor { 
    153156         * Processes current image and saves to disk
    154157         * multiple sizes from single source.
    155158         *
     159         * @since 3.5.0
     160         * @access public
     161         *
    156162         * @param array $sizes { {width, height}, ... }
    157163         * @return array
    158164         */
    class WP_Image_Editor_GD extends WP_Image_Editor { 
    192198         * @param int $src_h The height to crop.
    193199         * @param int $dst_w Optional. The destination width.
    194200         * @param int $dst_h Optional. The destination height.
    195          * @param int $src_abs Optional. If the source crop points are absolute.
     201         * @param boolean $src_abs Optional. If the source crop points are absolute.
    196202         * @return boolean|WP_Error
    197203         */
    198204        public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) {
    class WP_Image_Editor_GD extends WP_Image_Editor { 
    250256        }
    251257
    252258        /**
    253          * Flips current image
     259         * Flips current image.
     260         *
     261         * @since 3.5.0
     262         * @access public
    254263         *
    255264         * @param boolean $horz Horizonal Flip
    256265         * @param boolean $vert Vertical Flip
    class WP_Image_Editor_GD extends WP_Image_Editor { 
    277286        }
    278287
    279288        /**
    280          * Saves current in-memory image to file
     289         * Saves current in-memory image to file.
     290         *
     291         * @since 3.5.0
     292         * @access public
    281293         *
    282294         * @param string $destfilename
    283295         * @param string $mime_type
    class WP_Image_Editor_GD extends WP_Image_Editor { 
    335347        }
    336348
    337349        /**
    338          * Returns stream of current image
     350         * Returns stream of current image.
     351         *
     352         * @since 3.5.0
     353         * @access public
    339354         *
    340355         * @param string $mime_type
    341356         */
  • wp-includes/class-wp-image-editor-imagick.php

    diff --git wp-includes/class-wp-image-editor-imagick.php wp-includes/class-wp-image-editor-imagick.php
    index 1f137fd..601b99b 100644
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    4444        }
    4545
    4646        /**
    47          * Loads image from $this->file into new Imagick Object
     47         * Loads image from $this->file into new Imagick Object.
    4848         *
    4949         * @since 3.5.0
    5050         * @access protected
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    109109        }
    110110
    111111        /**
    112          * Sets or updates current image size
     112         * Sets or updates current image size.
    113113         *
    114114         * @since 3.5.0
    115115         * @access protected
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    138138        }
    139139
    140140        /**
    141          * Checks to see if editor supports mime-type specified
     141         * Checks to see if editor supports the mime-type specified.
    142142         *
    143143         * @since 3.5.0
    144144         * @access public
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    163163        /**
    164164         * Resizes current image.
    165165         *
     166         * @since 3.5.0
     167         * @access public
     168         *
    166169         * @param int $max_w
    167170         * @param int $max_h
    168171         * @param boolean $crop
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    199202         * Processes current image and saves to disk
    200203         * multiple sizes from single source.
    201204         *
     205         * @since 3.5.0
     206         * @access public
     207         *
    202208         * @param array $sizes
    203209         * @return array
    204210         */
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    246252         * @param int $src_h The height to crop.
    247253         * @param int $dst_w Optional. The destination width.
    248254         * @param int $dst_h Optional. The destination height.
    249          * @param int $src_abs Optional. If the source crop points are absolute.
     255         * @param boolean $src_abs Optional. If the source crop points are absolute.
    250256         * @return boolean|WP_Error
    251257         */
    252258        public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) {
    253                 // Not sure this is compatible.
    254259                if ( $src_abs ) {
    255260                        $src_w -= $src_x;
    256261                        $src_h -= $src_y;
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    302307        }
    303308
    304309        /**
    305          * Flips current image
     310         * Flips current image.
    306311         *
    307312         * @since 3.5.0
    308313         * @access public
    309314         *
    310          * @param boolean $horz Horizontal Flip
     315         * @param boolean $horz Horizonal Flip
    311316         * @param boolean $vert Vertical Flip
    312          * @returns boolean
     317         * @returns boolean|WP_Error
    313318         */
    314319        public function flip( $horz, $vert ) {
    315320                try {
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    326331        }
    327332
    328333        /**
    329          * Saves current image to file
     334         * Saves current image to file.
     335         *
     336         * @since 3.5.0
     337         * @access public
    330338         *
    331339         * @param string $destfilename
    332340         * @param string $mime_type
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    385393        }
    386394
    387395        /**
    388          * Streams current image to browser
     396         * Streams current image to browser.
     397         *
     398         * @since 3.5.0
     399         * @access public
    389400         *
    390401         * @param string $mime_type
    391402         * @return boolean|WP_Error
  • wp-includes/class-wp-image-editor.php

    diff --git wp-includes/class-wp-image-editor.php wp-includes/class-wp-image-editor.php
    index 4c227a2..920e4a4 100644
    abstract class WP_Image_Editor { 
    6262                        array( 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD' ) );
    6363
    6464                if ( ! $required_methods )
    65                         $required_methods = apply_filters( 'wp_image_editor_default_methods',
    66                                 array( 'resize', 'multi_resize', 'crop', 'rotate', 'flip', 'stream' ) );
     65                        $required_methods = array();
    6766
    6867                // Loop over each editor on each request looking for one which will serve this request's needs
    6968                foreach ( $request_order as $editor ) {
    abstract class WP_Image_Editor { 
    8079                return false;
    8180        }
    8281
    83         abstract protected function load(); // returns bool|WP_Error
     82        /**
     83         * Loads image from $this->file into editor.
     84         *
     85         * @since 3.5.0
     86         * @access protected
     87         * @abstract
     88         *
     89         * @return boolean|WP_Error True if loaded; WP_Error on failure.
     90         */
     91        abstract protected function load();
     92
     93        /**
     94         * Saves current image to file.
     95         *
     96         * @since 3.5.0
     97         * @access public
     98         * @abstract
     99         *
     100         * @param string $destfilename
     101         * @param string $mime_type
     102         * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}
     103         */
    84104        abstract public function save( $destfilename = null, $mime_type = null );
    85105
    86106        /**
    87          * Implement all of the below to support natively used functions:
    88          *
    89          * public function resize( $max_w, $max_h, $crop = false )
    90          * public function multi_resize( $sizes )
    91          * public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false )
    92          * public function rotate( $angle )
    93          * public function flip( $horz, $vert )
    94          * public function stream( $mime_type = null )
     107         * Resizes current image.
     108         *
     109         * @since 3.5.0
     110         * @access public
     111         * @abstract
     112         *
     113         * @param int $max_w
     114         * @param int $max_h
     115         * @param boolean $crop
     116         * @return boolean|WP_Error
     117         */
     118        abstract public function resize( $max_w, $max_h, $crop = false );
     119
     120        /**
     121         * Processes current image and saves to disk
     122         * multiple sizes from single source.
     123         *
     124         * @since 3.5.0
     125         * @access public
     126         * @abstract
     127         *
     128         * @param array $sizes
     129         * @return array
     130         */
     131        abstract public function multi_resize( $sizes );
     132
     133        /**
     134         * Crops Image.
     135         *
     136         * @since 3.5.0
     137         * @access public
     138         * @abstract
     139         *
     140         * @param string|int $src The source file or Attachment ID.
     141         * @param int $src_x The start x position to crop from.
     142         * @param int $src_y The start y position to crop from.
     143         * @param int $src_w The width to crop.
     144         * @param int $src_h The height to crop.
     145         * @param int $dst_w Optional. The destination width.
     146         * @param int $dst_h Optional. The destination height.
     147         * @param boolean $src_abs Optional. If the source crop points are absolute.
     148         * @return boolean|WP_Error
     149         */
     150        abstract public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false );
     151
     152        /**
     153         * Rotates current image counter-clockwise by $angle.
     154         *
     155         * @since 3.5.0
     156         * @access public
     157         * @abstract
     158         *
     159         * @param float $angle
     160         * @return boolean|WP_Error
     161         */
     162        abstract public function rotate( $angle );
     163
     164        /**
     165         * Flips current image.
     166         *
     167         * @since 3.5.0
     168         * @access public
     169         * @abstract
     170         *
     171         * @param boolean $horz Horizonal Flip
     172         * @param boolean $vert Vertical Flip
     173         * @return boolean|WP_Error
     174         */
     175        abstract public function flip( $horz, $vert );
     176
     177        /**
     178         * Streams current image to browser.
     179         *
     180         * @since 3.5.0
     181         * @access public
     182         * @abstract
     183         *
     184         * @param string $mime_type
     185         * @return boolean|WP_Error
    95186         */
     187        abstract public function stream( $mime_type = null );
    96188
    97189        /**
    98190         * Checks to see if current environment supports the editor chosen.
    abstract class WP_Image_Editor { 
    110202        }
    111203
    112204        /**
    113          * Checks to see if editor supports mime-type specified
     205         * Checks to see if editor supports the mime-type specified.
    114206         * Must be overridden in a sub-class.
    115207         *
    116208         * @since 3.5.0
    abstract class WP_Image_Editor { 
    125217        }
    126218
    127219        /**
    128          * Gets dimensions of image
     220         * Gets dimensions of image.
    129221         *
    130222         * @since 3.5.0
    131223         * @access public
    abstract class WP_Image_Editor { 
    137229        }
    138230
    139231        /**
    140          * Sets current image size
     232         * Sets current image size.
    141233         *
    142234         * @since 3.5.0
    143235         * @access protected