Use "string|false" as @return instead of "string|bool" where appropiate
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 1 Apr 2015 08:48:30 +0000 (09:48 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Wed, 1 Apr 2015 08:48:30 +0000 (09:48 +0100)
This makes sure static analyzers don't warn for supposedly unsafe
code accessing variables as strings when they could be boolean after
having only checked against false.

https://github.com/scrutinizer-ci/php-analyzer/issues/605

Change-Id: Idb676de7587f1eccb46c12de0131bea4489a0785

includes/exception/MWExceptionHandler.php
includes/json/FormatJson.php

index 7110361..ed0f3c2 100644 (file)
@@ -349,7 +349,7 @@ TXT;
         * returns the requested URL. Otherwise, returns false.
         *
         * @since 1.23
-        * @return string|bool
+        * @return string|false
         */
        public static function getURL() {
                global $wgRequest;
@@ -428,7 +428,7 @@ TXT;
         * @param Exception $e
         * @param bool $pretty Add non-significant whitespace to improve readability (default: false).
         * @param int $escaping Bitfield consisting of FormatJson::.*_OK class constants.
-        * @return string|bool JSON string if successful; false upon failure
+        * @return string|false JSON string if successful; false upon failure
         */
        public static function jsonSerializeException( Exception $e, $pretty = false, $escaping = 0 ) {
                global $wgLogExceptionBacktrace;
index f27194a..095811f 100644 (file)
@@ -122,7 +122,7 @@ class FormatJson {
         *   readability, using that string for indentation. If true, use the default indent
         *   string (four spaces).
         * @param int $escaping Bitfield consisting of _OK class constants
-        * @return string|bool: String if successful; false upon failure
+        * @return string|false String if successful; false upon failure
         */
        public static function encode( $value, $pretty = false, $escaping = 0 ) {
                if ( !is_string( $pretty ) ) {
@@ -232,7 +232,7 @@ class FormatJson {
         * @param mixed $value
         * @param string|bool $pretty
         * @param int $escaping
-        * @return string|bool
+        * @return string|false
         */
        private static function encode54( $value, $pretty, $escaping ) {
                static $bug66021;
@@ -284,7 +284,7 @@ class FormatJson {
         * @param mixed $value
         * @param string|bool $pretty
         * @param int $escaping
-        * @return string|bool
+        * @return string|false
         */
        private static function encode53( $value, $pretty, $escaping ) {
                $options = ( $escaping & self::XMLMETA_OK ) ? 0 : ( JSON_HEX_TAG | JSON_HEX_AMP );