From 9c9753d6eadb7a5b7495594bd7f1bc4480edd4a2 Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Fri, 12 May 2017 15:21:20 +0200
Subject: [PATCH] replace some var keywords

This should fix some tests on PHP 7.1. The work is far from done, we
still have a lot of variables without proper accessibility defined.
---
 _test/tests/inc/auth_aclcheck.test.php        |  2 +-
 _test/tests/inc/auth_password.test.php        |  2 +-
 _test/tests/inc/blowfish.test.php             | 33 -------------------
 .../tests/inc/pageutils_findnearest.test.php  |  2 +-
 _test/tests/inc/remote.test.php               |  4 +--
 _test/tests/inc/utf8_utf16be.test.php         |  4 +--
 inc/cache.php                                 |  8 ++---
 inc/events.php                                | 28 +++++++++++++---
 inc/form.php                                  |  8 ++---
 inc/plugin.php                                |  8 ++---
 inc/utf8.php                                  |  4 +--
 .../usermanager/_test/csv_import.test.php     |  2 +-
 lib/plugins/usermanager/_test/mocks.class.php |  3 ++
 13 files changed, 48 insertions(+), 60 deletions(-)
 delete mode 100644 _test/tests/inc/blowfish.test.php

diff --git a/_test/tests/inc/auth_aclcheck.test.php b/_test/tests/inc/auth_aclcheck.test.php
index b128b7871..8c9b37536 100644
--- a/_test/tests/inc/auth_aclcheck.test.php
+++ b/_test/tests/inc/auth_aclcheck.test.php
@@ -2,7 +2,7 @@
 
 class auth_acl_test extends DokuWikiTest {
 
-    var $oldAuthAcl;
+    protected $oldAuthAcl;
 
     function setUp() {
         parent::setUp();
diff --git a/_test/tests/inc/auth_password.test.php b/_test/tests/inc/auth_password.test.php
index b2d0df0d7..4f872eb51 100644
--- a/_test/tests/inc/auth_password.test.php
+++ b/_test/tests/inc/auth_password.test.php
@@ -3,7 +3,7 @@
 class auth_password_test extends DokuWikiTest {
 
     // hashes for the password foo$method, using abcdefgh12345678912345678912345678 as salt
-    var $passes = array(
+    protected $passes = array(
         'smd5'  => '$1$abcdefgh$SYbjm2AEvSoHG7Xapi8so.',
         'apr1'  => '$apr1$abcdefgh$C/GzYTF4kOVByYLEoD5X4.',
         'md5'   => '8fa22d62408e5351553acdd91c6b7003',
diff --git a/_test/tests/inc/blowfish.test.php b/_test/tests/inc/blowfish.test.php
deleted file mode 100644
index 972df11f4..000000000
--- a/_test/tests/inc/blowfish.test.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/**
- * Test for blowfish encryption.
- */
-class blowfish_test extends DokuWikiTest {
-    public function testEncryptDecryptNumbers() {
-        $secret = '$%ÄüfuDFRR';
-        $string = '12345678';
-        $this->assertEquals(
-            $string,
-            PMA_blowfish_decrypt(PMA_blowfish_encrypt($string, $secret), $secret)
-        );
-    }
-
-    public function testEncryptDecryptChars() {
-        $secret = '$%ÄüfuDFRR';
-        $string = 'abcDEF012!"§$%&/()=?`´"\',.;:-_#+*~öäüÖÄÜ^°²³';
-        $this->assertEquals(
-            $string,
-            PMA_blowfish_decrypt(PMA_blowfish_encrypt($string, $secret), $secret)
-        );
-    }
-
-    // FS#1690 FS#1713
-    public function testEncryptDecryptBinary() {
-        $secret = '$%ÄüfuDFRR';
-        $string = "this is\0binary because of\0zero bytes";
-        $this->assertEquals(
-            $string,
-            PMA_blowfish_decrypt(PMA_blowfish_encrypt($string, $secret), $secret)
-        );
-    }
-}
diff --git a/_test/tests/inc/pageutils_findnearest.test.php b/_test/tests/inc/pageutils_findnearest.test.php
index d62d3dd78..c2815a06c 100644
--- a/_test/tests/inc/pageutils_findnearest.test.php
+++ b/_test/tests/inc/pageutils_findnearest.test.php
@@ -2,7 +2,7 @@
 
 class pageutils_findnearest_test extends DokuWikiTest {
 
-    var $oldAuthAcl;
+    protected $oldAuthAcl;
 
     function setUp() {
         parent::setUp();
diff --git a/_test/tests/inc/remote.test.php b/_test/tests/inc/remote.test.php
index 316f12e8a..ee040f09a 100644
--- a/_test/tests/inc/remote.test.php
+++ b/_test/tests/inc/remote.test.php
@@ -129,10 +129,10 @@ class remote_plugin_testplugin2 extends DokuWiki_Remote_Plugin {
 
 class remote_test extends DokuWikiTest {
 
-    var $userinfo;
+    protected $userinfo;
 
     /** @var  RemoteAPI */
-    var $remote;
+    protected $remote;
 
     function setUp() {
         parent::setUp();
diff --git a/_test/tests/inc/utf8_utf16be.test.php b/_test/tests/inc/utf8_utf16be.test.php
index 6a12a01fd..943ebeffc 100644
--- a/_test/tests/inc/utf8_utf16be.test.php
+++ b/_test/tests/inc/utf8_utf16be.test.php
@@ -5,8 +5,8 @@ if(!defined('UTF8_NOMBSTRING')) define('UTF8_NOMBSTRING',1);
 
 class utf8_utf16be_test extends DokuWikiTest {
     // some chars from various code regions
-    var $utf8  = '鈩ℵŁöx';
-    var $utf16 = "\x92\x29\x21\x35\x1\x41\x0\xf6\x0\x78";
+    protected $utf8  = '鈩ℵŁöx';
+    protected $utf16 = "\x92\x29\x21\x35\x1\x41\x0\xf6\x0\x78";
 
     /**
      * Convert from UTF-8 to UTF-16BE
diff --git a/inc/cache.php b/inc/cache.php
index 9375dc86b..8589d91ba 100644
--- a/inc/cache.php
+++ b/inc/cache.php
@@ -18,9 +18,9 @@ class cache {
     public $depends = array(); // array containing cache dependency information,
                                //   used by _useCache to determine cache validity
 
-    var $_event = '';       // event to be triggered during useCache
-    var $_time;
-    var $_nocache = false;  // if set to true, cache will not be used or stored
+    public $_event = '';       // event to be triggered during useCache
+    public $_time;
+    public $_nocache = false;  // if set to true, cache will not be used or stored
 
     /**
      * @param string $key primary identifier
@@ -180,7 +180,7 @@ class cache_parser extends cache {
     public $mode = '';       // input mode (represents the processing the input file will undergo)
     public $page = '';
 
-    var $_event = 'PARSER_CACHE_USE';
+    public $_event = 'PARSER_CACHE_USE';
 
     /**
      *
diff --git a/inc/events.php b/inc/events.php
index 35d55d0e3..af26b08a8 100644
--- a/inc/events.php
+++ b/inc/events.php
@@ -22,8 +22,8 @@ class Doku_Event {
     public $canPreventDefault = true; // READONLY  if true, event handlers can prevent the events default action
 
     // private properties, event handlers can effect these through the provided methods
-    var $_default = true;     // whether or not to carry out the default action associated with the event
-    var $_continue = true;    // whether or not to continue propagating the event to other handlers
+    protected $_default = true;     // whether or not to carry out the default action associated with the event
+    protected $_continue = true;    // whether or not to continue propagating the event to other handlers
 
     /**
      * event constructor
@@ -123,18 +123,36 @@ class Doku_Event {
      * stop any further processing of the event by event handlers
      * this function does not prevent the default action taking place
      */
-    function stopPropagation() {
+    public function stopPropagation() {
         $this->_continue = false;
     }
 
+    /**
+     * may the event propagate to the next handler?
+     *
+     * @return bool
+     */
+    public function mayPropgate() {
+        return $this->_continue;
+    }
+
     /**
      * preventDefault
      *
      * prevent the default action taking place
      */
-    function preventDefault() {
+    public function preventDefault() {
         $this->_default = false;
     }
+
+    /**
+     * should the default action be executed?
+     *
+     * @return bool
+     */
+    public function mayRunDefault() {
+        return $this->_default;
+    }
 }
 
 /**
@@ -211,7 +229,7 @@ class Doku_Event_Handler {
                         $obj->$method($event, $param);
                     }
 
-                    if (!$event->_continue) return;
+                    if (!$event->mayPropgate()) return;
                 }
             }
         }
diff --git a/inc/form.php b/inc/form.php
index 46cc8fe6b..caf12c019 100644
--- a/inc/form.php
+++ b/inc/form.php
@@ -28,17 +28,17 @@ if(!defined('DOKU_INC')) die('meh.');
 class Doku_Form {
 
     // Form id attribute
-    var $params = array();
+    protected $params = array();
 
     // Draw a border around form fields.
     // Adds <fieldset></fieldset> around the elements
-    var $_infieldset = false;
+    protected $_infieldset = false;
 
     // Hidden form fields.
-    var $_hidden = array();
+    protected $_hidden = array();
 
     // Array of pseudo-tags
-    var $_content = array();
+    protected $_content = array();
 
     /**
      * Constructor
diff --git a/inc/plugin.php b/inc/plugin.php
index fb6bb0b37..8a90c0a6e 100644
--- a/inc/plugin.php
+++ b/inc/plugin.php
@@ -12,10 +12,10 @@
  */
 class DokuWiki_Plugin {
 
-    var $localised = false;        // set to true by setupLocale() after loading language dependent strings
-    var $lang = array();           // array to hold language dependent strings, best accessed via ->getLang()
-    var $configloaded = false;     // set to true by loadConfig() after loading plugin configuration variables
-    var $conf = array();           // array to hold plugin settings, best accessed via ->getConf()
+    protected $localised = false;        // set to true by setupLocale() after loading language dependent strings
+    protected $lang = array();           // array to hold language dependent strings, best accessed via ->getLang()
+    protected $configloaded = false;     // set to true by loadConfig() after loading plugin configuration variables
+    protected $conf = array();           // array to hold plugin settings, best accessed via ->getConf()
 
     /**
      * General Info
diff --git a/inc/utf8.php b/inc/utf8.php
index 794db2bb5..f82a663e4 100644
--- a/inc/utf8.php
+++ b/inc/utf8.php
@@ -357,7 +357,7 @@ if(!function_exists('utf8_strtolower')){
      */
     function utf8_strtolower($string){
         if(UTF8_MBSTRING) {
-            if (class_exists("Normalizer", $autoload = false)) 
+            if (class_exists("Normalizer", $autoload = false))
                 return normalizer::normalize(mb_strtolower($string,'utf-8'));
             else
                 return (mb_strtolower($string,'utf-8'));
@@ -636,7 +636,7 @@ if(!class_exists('utf8_entity_decoder')){
      * Encapsulate HTML entity decoding tables
      */
     class utf8_entity_decoder {
-        var $table;
+        protected $table;
 
         /**
          * Initializes the decoding tables
diff --git a/lib/plugins/usermanager/_test/csv_import.test.php b/lib/plugins/usermanager/_test/csv_import.test.php
index 1f0ee7436..299e0183d 100644
--- a/lib/plugins/usermanager/_test/csv_import.test.php
+++ b/lib/plugins/usermanager/_test/csv_import.test.php
@@ -103,7 +103,7 @@ importuser,"Ford Prefect",ford@example.com,user
 ';
         $failures = array(
             '2' => array(
-                'error' => $this->usermanager->lang['import_error_create'],
+                'error' => $this->usermanager->getLang('import_error_create'),
                 'user'  => array(
                     'importuser',
                     'Ford Prefect',
diff --git a/lib/plugins/usermanager/_test/mocks.class.php b/lib/plugins/usermanager/_test/mocks.class.php
index f3cc72c27..e524e451b 100644
--- a/lib/plugins/usermanager/_test/mocks.class.php
+++ b/lib/plugins/usermanager/_test/mocks.class.php
@@ -12,6 +12,9 @@ class admin_mock_usermanager extends admin_plugin_usermanager {
     public $mock_email_notifications = true;
     public $mock_email_notifications_sent = 0;
 
+    public $localised;
+    public $lang;
+
     public function getImportFailures() {
         return $this->_import_failures;
     }
-- 
GitLab