Merge "Use PHP 7 '??' operator instead of '?:' (round 2)"
[lhc/web/wiklou.git] / includes / htmlform / HTMLFormField.php
index f5d6e8c..8902995 100644 (file)
@@ -462,6 +462,16 @@ abstract class HTMLFormField {
                if ( isset( $params['hide-if'] ) ) {
                        $this->mHideIf = $params['hide-if'];
                }
+
+               if ( isset( $this->mParams['notice-message'] ) ) {
+                       wfDeprecated( "'notice-message' parameter in HTMLForm", '1.32' );
+               }
+               if ( isset( $this->mParams['notice-messages'] ) ) {
+                       wfDeprecated( "'notice-messages' parameter in HTMLForm", '1.32' );
+               }
+               if ( isset( $this->mParams['notice'] ) ) {
+                       wfDeprecated( "'notice' parameter in HTMLForm", '1.32' );
+               }
        }
 
        /**
@@ -607,7 +617,7 @@ abstract class HTMLFormField {
                        $error = new OOUI\HtmlSnippet( $error );
                }
 
-               $notices = $this->getNotices();
+               $notices = $this->getNotices( 'skip deprecation' );
                foreach ( $notices as &$notice ) {
                        $notice = new OOUI\HtmlSnippet( $notice );
                }
@@ -861,15 +871,20 @@ abstract class HTMLFormField {
         * @return bool
         */
        public function isHelpInline() {
-               return isset( $this->mParams['help-inline'] ) ? $this->mParams['help-inline'] : true;
+               return $this->mParams['help-inline'] ?? true;
        }
 
        /**
         * Determine form errors to display and their classes
         * @since 1.20
         *
+        * phan-taint-check gets confused with returning both classes
+        * and errors and thinks double escaping is happening, so specify
+        * that return value has no taint.
+        *
         * @param string $value The value of the input
         * @return array array( $errors, $errorClass )
+        * @return-taint none
         */
        public function getErrorsAndErrorClass( $value ) {
                $errors = $this->validate( $value, $this->mParent->mFieldData );
@@ -915,9 +930,16 @@ abstract class HTMLFormField {
         * Determine notices to display for the field.
         *
         * @since 1.28
+        * @deprecated since 1.32
+        * @param string $skipDeprecation Pass 'skip deprecation' to avoid the deprecation
+        *   warning (since 1.32)
         * @return string[]
         */
-       public function getNotices() {
+       public function getNotices( $skipDeprecation = null ) {
+               if ( $skipDeprecation !== 'skip deprecation' ) {
+                       wfDeprecated( __METHOD__, '1.32' );
+               }
+
                $notices = [];
 
                if ( isset( $this->mParams['notice-message'] ) ) {
@@ -1132,6 +1154,12 @@ abstract class HTMLFormField {
         * Formats one or more errors as accepted by field validation-callback.
         *
         * @param string|Message|array $errors Array of strings or Message instances
+        * To work around limitations in phan-taint-check the calling
+        * class has taintedness disabled. So instead we pretend that
+        * this method outputs html, since the result is eventually
+        * outputted anyways without escaping and this allows us to verify
+        * stuff is safe even though the caller has taintedness cleared.
+        * @param-taint $errors exec_html
         * @return string HTML
         * @since 1.18
         */