Completed
Pull Request — master (#16)
by Michael
01:51
created

MyXoopsStory::title()   B

Complexity

Conditions 6
Paths 10

Size

Total Lines 20
Code Lines 15

Duplication

Lines 20
Ratio 100 %

Importance

Changes 0
Metric Value
cc 6
eloc 15
nc 10
nop 1
dl 20
loc 20
rs 8.8571
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 28 and the first side effect is on line 22.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * XOOPS news story
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright       XOOPS Project (https://xoops.org)
13
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14
 * @package         kernel
15
 * @since           2.0.0
16
 * @author          Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/
17
 * @deprecated
18
 */
19
20
// defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
21
//$GLOBALS['xoopsLogger']->addDeprecated("'/class/xoopsstory.php' is deprecated since XOOPS 2.5.4, please create your own class instead.");
22
require_once XOOPS_ROOT_PATH . '/modules/news/class/xoopstopic.php';
23
require_once XOOPS_ROOT_PATH . '/kernel/user.php';
24
25
/**
26
 * Class MyXoopsStory
27
 */
28
class MyXoopsStory
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
29
{
30
    public $table;
31
    public $storyid;
32
    public $topicid;
33
    public $uid;
34
    public $title;
35
    public $hometext;
36
    public $bodytext  = '';
37
    public $counter;
38
    public $created;
39
    public $published;
40
    public $expired;
41
    public $hostname;
42
    public $nohtml    = 0;
43
    public $nosmiley  = 0;
44
    public $ihome     = 0;
45
    public $notifypub = 0;
46
    public $type;
47
    public $approved;
48
    public $topicdisplay;
49
    public $topicalign;
50
    public $db;
51
    public $topicstable;
52
    public $comments;
53
54
    /**
55
     * @param $storyid
56
     */
57
    public function Story($storyid = -1)
58
    {
59
        $this->db          = XoopsDatabaseFactory::getDatabaseConnection();
60
        $this->table       = '';
61
        $this->topicstable = '';
62 View Code Duplication
        if (is_array($storyid)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
63
            $this->makeStory($storyid);
64
        } elseif ($storyid != -1) {
65
            $this->getStory((int)$storyid);
66
        }
67
    }
68
69
    /**
70
     * @param $value
71
     */
72
    public function setStoryId($value)
73
    {
74
        $this->storyid = (int)$value;
75
    }
76
77
    /**
78
     * @param $value
79
     */
80
    public function setTopicId($value)
81
    {
82
        $this->topicid = (int)$value;
83
    }
84
85
    /**
86
     * @param $value
87
     */
88
    public function setUid($value)
89
    {
90
        $this->uid = (int)$value;
91
    }
92
93
    /**
94
     * @param $value
95
     */
96
    public function setTitle($value)
97
    {
98
        $this->title = $value;
99
    }
100
101
    /**
102
     * @param $value
103
     */
104
    public function setHometext($value)
105
    {
106
        $this->hometext = $value;
107
    }
108
109
    /**
110
     * @param $value
111
     */
112
    public function setBodytext($value)
113
    {
114
        $this->bodytext = $value;
115
    }
116
117
    /**
118
     * @param $value
119
     */
120
    public function setPublished($value)
121
    {
122
        $this->published = (int)$value;
123
    }
124
125
    /**
126
     * @param $value
127
     */
128
    public function setExpired($value)
129
    {
130
        $this->expired = (int)$value;
131
    }
132
133
    /**
134
     * @param $value
135
     */
136
    public function setHostname($value)
137
    {
138
        $this->hostname = $value;
139
    }
140
141
    /**
142
     * @param int $value
143
     */
144
    public function setNohtml($value = 0)
145
    {
146
        $this->nohtml = $value;
147
    }
148
149
    /**
150
     * @param int $value
151
     */
152
    public function setNosmiley($value = 0)
153
    {
154
        $this->nosmiley = $value;
155
    }
156
157
    /**
158
     * @param $value
159
     */
160
    public function setIhome($value)
161
    {
162
        $this->ihome = $value;
163
    }
164
165
    /**
166
     * @param $value
167
     */
168
    public function setNotifyPub($value)
169
    {
170
        $this->notifypub = $value;
171
    }
172
173
    /**
174
     * @param $value
175
     */
176
    public function setType($value)
177
    {
178
        $this->type = $value;
179
    }
180
181
    /**
182
     * @param $value
183
     */
184
    public function setApproved($value)
185
    {
186
        $this->approved = (int)$value;
187
    }
188
189
    /**
190
     * @param $value
191
     */
192
    public function setTopicdisplay($value)
193
    {
194
        $this->topicdisplay = $value;
195
    }
196
197
    /**
198
     * @param $value
199
     */
200
    public function setTopicalign($value)
201
    {
202
        $this->topicalign = $value;
203
    }
204
205
    /**
206
     * @param $value
207
     */
208
    public function setComments($value)
209
    {
210
        $this->comments = (int)$value;
211
    }
212
213
    /**
214
     * @param bool $approved
215
     *
216
     * @return bool
217
     */
218
    public function store($approved = false)
0 ignored issues
show
Unused Code introduced by
The parameter $approved is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
219
    {
220
        //$newpost = 0;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
221
        $myts     = MyTextSanitizer::getInstance();
222
        $title    = $myts->censorString($this->title);
223
        $hometext = $myts->censorString($this->hometext);
224
        $bodytext = $myts->censorString($this->bodytext);
225
        $title    = $myts->addSlashes($title);
226
        $hometext = $myts->addSlashes($hometext);
227
        $bodytext = $myts->addSlashes($bodytext);
228
        if (!isset($this->nohtml) || 1 != $this->nohtml) {
229
            $this->nohtml = 0;
230
        }
231
        if (!isset($this->nosmiley) || 1 != $this->nosmiley) {
232
            $this->nosmiley = 0;
233
        }
234
        if (!isset($this->notifypub) || 1 != $this->notifypub) {
235
            $this->notifypub = 0;
236
        }
237
        if (!isset($this->topicdisplay) || 0 != $this->topicdisplay) {
238
            $this->topicdisplay = 1;
239
        }
240
        $expired = !empty($this->expired) ? $this->expired : 0;
241
        if (!isset($this->storyid)) {
242
            //$newpost = 1;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
243
            $newstoryid = $this->db->genId($this->table . '_storyid_seq');
244
            $created    = time();
245
            $published  = $this->approved ? $this->published : 0;
246
247
            $sql = sprintf(
248
                "INSERT INTO %s (storyid, uid, title, created, published, expired, hostname, nohtml, nosmiley, hometext, bodytext, counter, topicid, ihome, notifypub, story_type, topicdisplay, topicalign, comments) VALUES (%u, %u, '%s', %u, %u, %u, '%s', %u, %u, '%s', '%s', %u, %u, %u, %u, '%s', %u, '%s', %u)",
249
                           $this->table,
250
                $newstoryid,
251
                $this->uid,
252
                $title,
253
                $created,
254
                $published,
255
                $expired,
256
                $this->hostname,
257
                $this->nohtml,
258
                $this->nosmiley,
259
                $hometext,
260
                $bodytext,
261
                0,
262
                $this->topicid,
263
                $this->ihome,
264
                $this->notifypub,
265
                $this->type,
266
                $this->topicdisplay,
267
                $this->topicalign,
268
                $this->comments
269
            );
270
        } else {
271
            if ($this->approved) {
272
                $sql = sprintf(
273
                    "UPDATE %s SET title = '%s', published = %u, expired = %u, nohtml = %u, nosmiley = %u, hometext = '%s', bodytext = '%s', topicid = %u, ihome = %u, topicdisplay = %u, topicalign = '%s', comments = %u WHERE storyid = %u",
274
                    $this->table,
275
                    $title,
276
                    $this->published,
277
                    $expired,
278
                               $this->nohtml,
279
                    $this->nosmiley,
280
                    $hometext,
281
                    $bodytext,
282
                    $this->topicid,
283
                    $this->ihome,
284
                    $this->topicdisplay,
285
                    $this->topicalign,
286
                    $this->comments,
287
                    $this->storyid
288
                );
289
            } else {
290
                $sql = sprintf(
291
                    "UPDATE %s SET title = '%s', expired = %u, nohtml = %u, nosmiley = %u, hometext = '%s', bodytext = '%s', topicid = %u, ihome = %u, topicdisplay = %u, topicalign = '%s', comments = %u WHERE storyid = %u",
292
                    $this->table,
293
                    $title,
294
                    $expired,
295
                    $this->nohtml,
296
                    $this->nosmiley,
297
                               $hometext,
298
                    $bodytext,
299
                    $this->topicid,
300
                    $this->ihome,
301
                    $this->topicdisplay,
302
                    $this->topicalign,
303
                    $this->comments,
304
                    $this->storyid
305
                );
306
            }
307
            $newstoryid = $this->storyid;
308
        }
309
        if (!$result = $this->db->query($sql)) {
310
            return false;
311
        }
312
        if (empty($newstoryid)) {
313
            $newstoryid    = $this->db->getInsertId();
314
            $this->storyid = $newstoryid;
315
        }
316
317
        return $newstoryid;
318
    }
319
320
    /**
321
     * @param $storyid
322
     */
323 View Code Duplication
    public function getStory($storyid)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
324
    {
325
        $storyid = (int)$storyid;
326
        $sql     = 'SELECT * FROM ' . $this->table . ' WHERE storyid=' . $storyid . '';
327
        $array   = $this->db->fetchArray($this->db->query($sql));
328
        $this->makeStory($array);
329
    }
330
331
    /**
332
     * @param $array
333
     */
334
    public function makeStory($array)
335
    {
336
        foreach ($array as $key => $value) {
337
            $this->$key = $value;
338
        }
339
    }
340
341
    /**
342
     * @return bool
343
     */
344 View Code Duplication
    public function delete()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
345
    {
346
        $sql = sprintf('DELETE FROM %s WHERE storyid = %u', $this->table, $this->storyid);
347
        if (!$result = $this->db->query($sql)) {
348
            return false;
349
        }
350
351
        return true;
352
    }
353
354
    /**
355
     * @return bool
356
     */
357 View Code Duplication
    public function updateCounter()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
358
    {
359
        $sql = sprintf('UPDATE %s SET counter = counter+1 WHERE storyid = %u', $this->table, $this->storyid);
360
        if (!$result = $this->db->queryF($sql)) {
361
            return false;
362
        }
363
364
        return true;
365
    }
366
367
    /**
368
     * @param $total
369
     *
370
     * @return bool
371
     */
372 View Code Duplication
    public function updateComments($total)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
373
    {
374
        $sql = sprintf('UPDATE %s SET comments = %u WHERE storyid = %u', $this->table, $total, $this->storyid);
375
        if (!$result = $this->db->queryF($sql)) {
376
            return false;
377
        }
378
379
        return true;
380
    }
381
382
    public function topicid()
383
    {
384
        return $this->topicid;
385
    }
386
387
    /**
388
     * @return MyXoopsTopic
389
     */
390
    public function topic()
391
    {
392
        return new MyXoopsTopic($this->topicstable, $this->topicid);
393
    }
394
395
    public function uid()
396
    {
397
        return $this->uid;
398
    }
399
400
    /**
401
     * @return string
402
     */
403
    public function uname()
404
    {
405
        return XoopsUser::getUnameFromId($this->uid);
406
    }
407
408
    /**
409
     * @param string $format
410
     *
411
     * @return mixed
412
     */
413 View Code Duplication
    public function title($format = 'Show')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
414
    {
415
        $myts   = MyTextSanitizer::getInstance();
416
        $smiley = 1;
0 ignored issues
show
Unused Code introduced by
$smiley is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
417
        if ($this->nosmiley()) {
418
            $smiley = 0;
0 ignored issues
show
Unused Code introduced by
$smiley is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
419
        }
420
        switch ($format) {
421
            case 'Show':
422
            case 'Edit':
423
                $title = $myts->htmlSpecialChars($this->title);
424
                break;
425
            case 'Preview':
426
            case 'InForm':
427
                $title = $myts->htmlSpecialChars($myts->stripSlashesGPC($this->title));
428
                break;
429
        }
430
431
        return $title;
0 ignored issues
show
Bug introduced by
The variable $title 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...
432
    }
433
434
    /**
435
     * @param string $format
436
     *
437
     * @return string
438
     */
439 View Code Duplication
    public function hometext($format = 'Show')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
440
    {
441
        $myts   = MyTextSanitizer::getInstance();
442
        $html   = 1;
443
        $smiley = 1;
444
        $xcodes = 1;
445
        if ($this->nohtml()) {
446
            $html = 0;
447
        }
448
        if ($this->nosmiley()) {
449
            $smiley = 0;
450
        }
451
        switch ($format) {
452
            case 'Show':
453
                $hometext = $myts->displayTarea($this->hometext, $html, $smiley, $xcodes);
454
                break;
455
            case 'Edit':
456
                $hometext = htmlspecialchars($this->hometext, ENT_QUOTES);
457
                break;
458
            case 'Preview':
459
                $hometext = $myts->previewTarea($this->hometext, $html, $smiley, $xcodes);
460
                break;
461
            case 'InForm':
462
                $hometext = htmlspecialchars($myts->stripSlashesGPC($this->hometext), ENT_QUOTES);
463
                break;
464
        }
465
466
        return $hometext;
0 ignored issues
show
Bug introduced by
The variable $hometext 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...
467
    }
468
469
    /**
470
     * @param string $format
471
     *
472
     * @return string
473
     */
474 View Code Duplication
    public function bodytext($format = 'Show')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
475
    {
476
        $myts   = MyTextSanitizer::getInstance();
477
        $html   = 1;
478
        $smiley = 1;
479
        $xcodes = 1;
480
        if ($this->nohtml()) {
481
            $html = 0;
482
        }
483
        if ($this->nosmiley()) {
484
            $smiley = 0;
485
        }
486
        switch ($format) {
487
            case 'Show':
488
                $bodytext = $myts->displayTarea($this->bodytext, $html, $smiley, $xcodes);
489
                break;
490
            case 'Edit':
491
                $bodytext = htmlspecialchars($this->bodytext, ENT_QUOTES);
492
                break;
493
            case 'Preview':
494
                $bodytext = $myts->previewTarea($this->bodytext, $html, $smiley, $xcodes);
495
                break;
496
            case 'InForm':
497
                $bodytext = htmlspecialchars($myts->stripSlashesGPC($this->bodytext), ENT_QUOTES);
498
                break;
499
        }
500
501
        return $bodytext;
0 ignored issues
show
Bug introduced by
The variable $bodytext 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...
502
    }
503
504
    public function counter()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
505
    {
506
        return $this->counter;
507
    }
508
509
    public function created()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
510
    {
511
        return $this->created;
512
    }
513
514
    public function published()
515
    {
516
        return $this->published;
517
    }
518
519
    public function expired()
520
    {
521
        return $this->expired;
522
    }
523
524
    public function hostname()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
525
    {
526
        return $this->hostname;
527
    }
528
529
    public function storyid()
530
    {
531
        return $this->storyid;
532
    }
533
534
    /**
535
     * @return int
536
     */
537
    public function nohtml()
538
    {
539
        return $this->nohtml;
540
    }
541
542
    /**
543
     * @return int
544
     */
545
    public function nosmiley()
546
    {
547
        return $this->nosmiley;
548
    }
549
550
    /**
551
     * @return int
552
     */
553
    public function notifypub()
554
    {
555
        return $this->notifypub;
556
    }
557
558
    public function type()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
559
    {
560
        return $this->type;
561
    }
562
563
    /**
564
     * @return int
565
     */
566
    public function ihome()
567
    {
568
        return $this->ihome;
569
    }
570
571
    public function topicdisplay()
572
    {
573
        return $this->topicdisplay;
574
    }
575
576
    /**
577
     * @param bool $astext
578
     *
579
     * @return string
580
     */
581
    public function topicalign($astext = true)
582
    {
583
        if ($astext) {
584
            if ('R' === $this->topicalign) {
585
                $ret = 'right';
586
            } else {
587
                $ret = 'left';
588
            }
589
590
            return $ret;
591
        }
592
593
        return $this->topicalign;
594
    }
595
596
    public function comments()
597
    {
598
        return $this->comments;
599
    }
600
}
601