Completed
Push — master ( b3c1c7...c901c8 )
by Marcus
02:39
created

Pageadmin::insertLang()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 3
eloc 8
nc 2
nop 0
1
<?php
2
3
/*
4
    HCSF - A multilingual CMS and Shopsystem
5
    Copyright (C) 2014  Marcus Haase - [email protected]
6
7
    This program is free software: you can redistribute it and/or modify
8
    it under the terms of the GNU General Public License as published by
9
    the Free Software Foundation, either version 3 of the License, or
10
    (at your option) any later version.
11
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16
17
    You should have received a copy of the GNU General Public License
18
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
namespace HaaseIT\HCSF\Controller\Admin;
22
23
use HaaseIT\HCSF\HelperConfig;
24
use HaaseIT\HCSF\UserPage;
25
use HaaseIT\HCSF\HardcodedText;
26
use Zend\ServiceManager\ServiceManager;
27
28
/**
29
 * Class Pageadmin
30
 * @package HaaseIT\HCSF\Controller\Admin
31
 */
32
class Pageadmin extends Base
33
{
34
    /**
35
     * @var \Zend\Diactoros\ServerRequest
36
     */
37
    private $request;
38
39
    /**
40
     * @var null|array|object
41
     */
42
    private $post;
43
44
    /**
45
     * @var array
46
     */
47
    private $get;
48
49
    /**
50
     * Pageadmin constructor.
51
     * @param ServiceManager $serviceManager
52
     */
53
    public function __construct(ServiceManager $serviceManager)
54
    {
55
        parent::__construct($serviceManager);
56
        /** @var \Zend\Diactoros\ServerRequest request */
57
        $this->request = $serviceManager->get('request');
58
        $this->post = $this->request->getParsedBody();
59
        $this->get = $this->request->getQueryParams();
60
    }
61
62
    /**
63
     *
64
     */
65
    public function preparePage()
0 ignored issues
show
Coding Style introduced by
preparePage uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
66
    {
67
        $this->P = new \HaaseIT\HCSF\CorePage($this->serviceManager);
68
        $this->P->cb_pagetype = 'content';
69
        $this->P->cb_subnav = 'admin';
70
71
        $this->P->cb_customcontenttemplate = 'pageadmin';
72
73
        // adding language to page here
74
        if (isset($_REQUEST["action"]) && $_REQUEST["action"] === 'insert_lang') {
75
            $this->insertLang();
76
        }
77
78
        if (!isset($this->get["action"])) {
79
            $this->P->cb_customdata["pageselect"] = $this->showPageselect();
80
        } elseif (($this->get["action"] === 'edit' || $this->get["action"] === 'delete') && isset($_REQUEST["page_key"]) && $_REQUEST["page_key"] != '') {
81
            if ($this->get["action"] === 'delete' && isset($this->post["delete"]) && $this->post["delete"] === 'do') {
82
                $this->handleDeletePage();
83
            } else { // edit or update page
84
                $this->handleEditPage();
85
            }
86
        } elseif ($this->get["action"] === 'addpage') {
87
            $this->handleAddPage();
88
        }
89
    }
90
91
    protected function handleDeletePage()
92
    {
93
        // delete and put message in customdata
94
        $Ptodelete = new UserPage($this->serviceManager, $this->get["page_key"], true);
95
        if ($Ptodelete->cb_id != NULL) {
96
            $Ptodelete->remove();
97
        } else {
98
            die(HardcodedText::get('pageadmin_exception_pagetodeletenotfound'));
0 ignored issues
show
Coding Style Compatibility introduced by
The method handleDeletePage() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
99
        }
100
        $this->P->cb_customdata["deleted"] = true;
101
    }
102
103
    protected function handleAddPage()
104
    {
105
        $aErr = [];
106
        if (isset($this->post["addpage"]) && $this->post["addpage"] === 'do') {
107
            $sPagekeytoadd = \trim(\filter_input(INPUT_POST, 'pagekey', FILTER_SANITIZE_SPECIAL_CHARS));
108
109
            if (mb_substr($sPagekeytoadd, 0, 2) === '/_') {
110
                $aErr["reservedpath"] = true;
111
            } elseif (strlen($sPagekeytoadd) < 4) {
112
                $aErr["keytooshort"] = true;
113
            } else {
114
                $Ptoadd = new UserPage($this->serviceManager, $sPagekeytoadd, true);
115
                if ($Ptoadd->cb_id == NULL) {
116
                    if ($Ptoadd->insert($sPagekeytoadd)) {
117
                        header('Location: /_admin/pageadmin.html?page_key='.$sPagekeytoadd.'&action=edit');
118
                        die();
0 ignored issues
show
Coding Style Compatibility introduced by
The method handleAddPage() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
119
                    } else {
120
                        die(HardcodedText::get('pageadmin_exception_couldnotinsertpage'));
0 ignored issues
show
Coding Style Compatibility introduced by
The method handleAddPage() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
121
                    }
122
                } else {
123
                    $aErr["keyalreadyinuse"] = true;
124
                }
125
            }
126
            $this->P->cb_customdata["err"] = $aErr;
127
            unset($aErr);
128
        }
129
        $this->P->cb_customdata["showaddform"] = true;
130
    }
131
132
    /**
133
     * @return array
134
     */
135
    protected function showPageselect() {
136
        $aGroups = [];
137
        foreach (HelperConfig::$core["admin_page_groups"] as $sValue) {
138
            $TMP = explode('|', $sValue);
139
            $aGroups[$TMP[0]] = $TMP[1];
140
        }
141
142
        $dbal = $this->serviceManager->get('dbal');
143
144
        /** @var \Doctrine\DBAL\Query\QueryBuilder $queryBuilder */
145
        $queryBuilder = $dbal->createQueryBuilder();
146
        $queryBuilder
147
            ->select('*')
148
            ->from('content_base')
149
            ->orderBy('cb_key')
150
        ;
151
        $statement = $queryBuilder->execute();
152
153
        while ($aResult = $statement->fetch()) {
154
            if (isset($aGroups[$aResult["cb_group"]])) {
155
                $aTree[$aResult["cb_group"]][] = $aResult;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aTree was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aTree = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
156
            } else {
157
                $aTree["_"][] = $aResult;
0 ignored issues
show
Bug introduced by
The variable $aTree does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
158
            }
159
        }
160
161
        foreach ($aGroups as $sKey => $sValue) {
162
            if (isset($aTree[$sKey])) {
163
                $aOptions_g[] = $sKey.'|'.$sValue;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aOptions_g was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aOptions_g = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
164
            }
165
        }
166
167
        return [
168
            'options_groups' => isset($aOptions_g) ? $aOptions_g : [],
169
            'tree' => isset($aTree) ? $aTree : [],
170
        ];
171
    }
172
173
    protected function insertLang()
0 ignored issues
show
Coding Style introduced by
insertLang uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
174
    {
175
        $Ptoinsertlang = new UserPage($this->serviceManager, $_REQUEST["page_key"], true);
176
177
        if ($Ptoinsertlang->cb_id != NULL && $Ptoinsertlang->oPayload->cl_id == NULL) {
0 ignored issues
show
Bug introduced by
The property cl_id does not seem to exist in HaaseIT\HCSF\PagePayload.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
178
            $Ptoinsertlang->oPayload->insert($Ptoinsertlang->cb_id);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class HaaseIT\HCSF\PagePayload as the method insert() does only exist in the following sub-classes of HaaseIT\HCSF\PagePayload: HaaseIT\HCSF\UserPagePayload. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
179
            header('Location: /_admin/pageadmin.html?page_key='.$Ptoinsertlang->cb_key.'&action=edit');
180
            die();
0 ignored issues
show
Coding Style Compatibility introduced by
The method insertLang() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
181
        } else {
182
            die(HardcodedText::get('pageadmin_exception_couldnotinsertlang'));
0 ignored issues
show
Coding Style Compatibility introduced by
The method insertLang() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
183
        }
184
    }
185
186
    protected function handleEditPage()
0 ignored issues
show
Coding Style introduced by
handleEditPage uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
187
    {
188
        if (isset($_REQUEST["page_key"]) && $Ptoedit = new UserPage($this->serviceManager, $_REQUEST["page_key"], true)) {
189
            if (isset($_REQUEST["action_a"]) && $_REQUEST["action_a"] === 'true') {
190
                $Ptoedit = $this->updatePage($Ptoedit);
191
            }
192
            $this->P->cb_customdata["page"] = $Ptoedit;
193
            $this->P->cb_customdata["admin_page_types"] = HelperConfig::$core["admin_page_types"];
194
            $this->P->cb_customdata["admin_page_groups"] = HelperConfig::$core["admin_page_groups"];
195
            $aOptions = [''];
196
            foreach (HelperConfig::$navigation as $sKey => $aValue) {
197
                if ($sKey === 'admin') {
198
                    continue;
199
                }
200
                $aOptions[] = $sKey;
201
            }
202
            $this->P->cb_customdata["subnavarea_options"] = $aOptions;
203
            unset($aOptions);
204
205
            // show archived versions of this page
206
            if ($Ptoedit->oPayload->cl_id != NULL) {
207
208
                $dbal = $this->serviceManager->get('dbal');
209
210
                /** @var \Doctrine\DBAL\Query\QueryBuilder $queryBuilder */
211
                $queryBuilder = $dbal->createQueryBuilder();
212
                $queryBuilder
213
                    ->select('*')
214
                    ->from('content_lang_archive')
215
                    ->where('cl_id = ?')
216
                    ->andWhere('cl_lang = ?')
217
                    ->setParameter(0, $Ptoedit->oPayload->cl_id)
0 ignored issues
show
Bug introduced by
The property cl_id does not seem to exist in HaaseIT\HCSF\PagePayload.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
218
                    ->setParameter(1, HelperConfig::$lang)
219
                    ->orderBy('cla_timestamp', 'DESC')
220
                ;
221
                $statement = $queryBuilder->execute();
222
                $iArchivedRows = $statement->rowCount();
223
224
                if ($iArchivedRows > 0) {
225
                    $aListSetting = [
226
                        ['title' => 'cla_timestamp', 'key' => 'cla_timestamp', 'width' => '15%', 'linked' => false,],
227
                        ['title' => 'cl_html', 'key' => 'cl_html', 'width' => '40%', 'linked' => false, 'escapehtmlspecialchars' => true,],
228
                        ['title' => 'cl_keywords', 'key' => 'cl_keywords', 'width' => '15%', 'linked' => false, 'escapehtmlspecialchars' => true,],
229
                        ['title' => 'cl_description', 'key' => 'cl_description', 'width' => '15%', 'linked' => false, 'escapehtmlspecialchars' => true,],
230
                        ['title' => 'cl_title', 'key' => 'cl_title', 'width' => '15%', 'linked' => false, 'escapehtmlspecialchars' => true,],
231
                    ];
232
                    $aData = $statement->fetchAll();
233
                    $this->P->cb_customdata['archived_list'] = \HaaseIT\Toolbox\Tools::makeListtable(
234
                        $aListSetting,
235
                        $aData,
236
                        $this->serviceManager->get('twig')
237
                    );
238
                }
239
            }
240
        } else {
241
            die(HardcodedText::get('pageadmin_exception_pagenotfound'));
0 ignored issues
show
Coding Style Compatibility introduced by
The method handleEditPage() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
242
        }
243
    }
244
245
    protected function updatePage(UserPage $Ptoedit)
0 ignored issues
show
Coding Style introduced by
updatePage uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
246
    {
247
        if (HelperConfig::$core['pagetext_enable_purifier']) {
248
            $purifier = \HaaseIT\HCSF\Helper::getPurifier('page');
249
        } else {
250
            $purifier = false;
251
        }
252
253
        $Ptoedit->cb_pagetype = $this->post['page_type'];
254
        $Ptoedit->cb_group = $this->post['page_group'];
255
        $Ptoedit->cb_pageconfig = $this->post['page_config'];
256
        $Ptoedit->cb_subnav = $this->post['page_subnav'];
257
        $Ptoedit->purifier = $purifier;
258
        $Ptoedit->write();
259
260
        if ($Ptoedit->oPayload->cl_id != NULL) {
0 ignored issues
show
Bug introduced by
The property cl_id does not seem to exist in HaaseIT\HCSF\PagePayload.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
261
            $Ptoedit->oPayload->cl_html = $this->post['page_html'];
262
            $Ptoedit->oPayload->cl_title = $this->post['page_title'];
263
            $Ptoedit->oPayload->cl_description = $this->post['page_description'];
264
            $Ptoedit->oPayload->cl_keywords = $this->post['page_keywords'];
265
            $Ptoedit->oPayload->purifier = $purifier;
0 ignored issues
show
Bug introduced by
The property purifier does not seem to exist in HaaseIT\HCSF\PagePayload.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
266
            $Ptoedit->oPayload->write();
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class HaaseIT\HCSF\PagePayload as the method write() does only exist in the following sub-classes of HaaseIT\HCSF\PagePayload: HaaseIT\HCSF\UserPagePayload. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
267
        }
268
269
        $Ptoedit = new UserPage($this->serviceManager, $_REQUEST["page_key"], true);
270
        $this->P->cb_customdata["updated"] = true;
271
272
        return $Ptoedit;
273
    }
274
}