selfthinker / dokuwiki_plugin_wrap

Wrap Plugin for DokuWiki: Universal plugin which combines functionalities of many other plugins. Wrap wiki text inside containers (divs or spans) and give them a class (choose from a variety of preset classes), a width and/or a language with its associated text direction.
http://www.dokuwiki.org/plugin:wrap
GNU General Public License v2.0
41 stars 33 forks source link

Fixed issue #267: PHP warnings about margins in helper.php. #268

Closed nerun closed 1 year ago

nerun commented 1 year ago
PHP Warning:  Undefined array key "padding-left" in .../public_html/wiki/lib/plugins/wrap/helper.php on line 398
PHP Warning:  Undefined array key "margin-left" in .../public_html/wiki/lib/plugins/wrap/helper.php on line 466
PHP Warning:  Undefined array key "margin-right" in .../public_html/wiki/lib/plugins/wrap/helper.php on line 467
PHP Warning:  Undefined array key "margin-top" in .../public_html/wiki/lib/plugins/wrap/helper.php on line 468
PHP Warning:  Undefined array key "margin-bottom" in .../public_html/wiki/lib/plugins/wrap/helper.php on line 469
fiwswe commented 1 year ago

Wouldn't it be easier and shorter to use the Null Coalescing Operator here?

E.g. instead of:

        if ( isset($properties ['margin-left']) ) {
            $properties ['padding-left'] = $properties ['margin-left'];
        } else {
            $properties ['padding-left'] = null;
        }

the same functionality can be expressed as:

        $properties ['padding-left'] = $properties ['margin-left'] ?? null;
nerun commented 1 year ago

Thank you, i am very new in php.