Issues (733)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

class/pear/Calendar/Decorator.php (8 issues)

1
<?php
2
3
/* vim: set expandtab tabstop=4 shiftwidth=4: */
4
5
/**
6
 * Contains the Calendar_Decorator class.
7
 *
8
 * PHP versions 4 and 5
9
 *
10
 * LICENSE: Redistribution and use in source and binary forms, with or without
11
 * modification, are permitted provided that the following conditions are met:
12
 * 1. Redistributions of source code must retain the above copyright
13
 *    notice, this list of conditions and the following disclaimer.
14
 * 2. Redistributions in binary form must reproduce the above copyright
15
 *    notice, this list of conditions and the following disclaimer in the
16
 *    documentation and/or other materials provided with the distribution.
17
 * 3. The name of the author may not be used to endorse or promote products
18
 *    derived from this software without specific prior written permission.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
21
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23
 * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
24
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
 *
31
 * @category  Date and Time
32
 *
33
 * @author    Harry Fuecks <[email protected]>
34
 * @copyright 2003-2007 Harry Fuecks
35
 * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
36
 *
37
 * @link      http://pear.php.net/package/Calendar
38
 */
39
40
/**
41
 * Decorates any calendar class.
42
 * Create a subclass of this class for your own "decoration".
43
 * Used for "selections"
44
 * <code>
45
 * class DayDecorator extends Calendar_Decorator
46
 * {
47
 *     function thisDay($format = 'int')
48
 *     {
49
 * .*         $day = parent::thisDay('timestamp');
50
 * .*         return date('D', $day);
51
 *     }
52
 * }
53
 * $Day = new Calendar_Day(2003, 10, 25);
54
 * $DayDecorator = new DayDecorator($Day);
55
 * echo $DayDecorator->thisDay(); // Outputs "Sat"
56
 * </code>.
57
 *
58
 * @category  Date and Time
59
 *
60
 * @author    Harry Fuecks <[email protected]>
61
 * @copyright 2003-2007 Harry Fuecks
62
 * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
63
 *
64
 * @link      http://pear.php.net/package/Calendar
65
 * @abstract
66
 */
67
class Calendar_Decorator
68
{
69
    /**
70
     * Subclass of Calendar being decorated.
71
     *
72
     * @var object
73
     */
74
    public $calendar;
75
76
    /**
77
     * Constructs the Calendar_Decorator.
78
     *
79
     * @param object &$calendar subclass to Calendar to decorate
80
     */
81
    public function __construct(&$calendar)
82
    {
83
        $this->calendar = &$calendar;
84
    }
85
86
    /**
87
     * Defines the calendar by a Unix timestamp, replacing values
88
     * passed to the constructor.
89
     *
90
     * @param int $ts Unix timestamp
91
     */
92
    public function setTimestamp($ts)
93
    {
94
        $this->calendar->setTimestamp($ts);
95
    }
96
97
    /**
98
     * Returns a timestamp from the current date / time values. Format of
99
     * timestamp depends on Calendar_Engine implementation being used.
100
     *
101
     * @return int $ts timestamp
102
     */
103
    public function getTimestamp()
104
    {
105
        return $this->calendar->getTimestamp();
106
    }
107
108
    /**
109
     * Defines calendar object as selected (e.g. for today).
110
     *
111
     * @param bool $state whether Calendar subclass must be selected
112
     */
113
    public function setSelected($state = true)
0 ignored issues
show
The parameter $state is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

113
    public function setSelected(/** @scrutinizer ignore-unused */ $state = true)

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

Loading history...
114
    {
115
        $this->calendar->setSelected($state = true);
116
    }
117
118
    /**
119
     * True if the calendar subclass object is selected (e.g. today).
120
     *
121
     * @return bool
122
     */
123
    public function isSelected()
124
    {
125
        return $this->calendar->isSelected();
126
    }
127
128
    /**
129
     * Adjusts the date (helper method).
130
     */
131
    public function adjust()
132
    {
133
        $this->calendar->adjust();
134
    }
135
136
    /**
137
     * Returns the date as an associative array (helper method).
138
     *
139
     * @param mixed $stamp timestamp (leave empty for current timestamp)
140
     *
141
     * @return array
142
     */
143
    public function toArray($stamp = null)
144
    {
145
        return $this->calendar->toArray($stamp);
146
    }
147
148
    /**
149
     * Returns the value as an associative array (helper method).
150
     *
151
     * @param string $returnType type of date object that return value represents
152
     * @param string $format     ['int'|'timestamp'|'object'|'array']
153
     * @param mixed  $stamp      timestamp (depending on Calendar engine being used)
154
     * @param int    $default    default value (i.e. give me the answer quick)
155
     *
156
     * @return mixed
157
     */
158
    public function returnValue($returnType, $format, $stamp, $default)
159
    {
160
        return $this->calendar->returnValue($returnType, $format, $stamp, $default);
161
    }
162
163
    /**
164
     * Defines Day object as first in a week
165
     * Only used by Calendar_Month_Weekdays::build().
166
     *
167
     * @param bool $state whether it's first or not
168
     */
169
    public function setFirst($state = true)
170
    {
171
        if (method_exists($this->calendar, 'setFirst')) {
172
            $this->calendar->setFirst($state);
173
        }
174
    }
175
176
    /**
177
     * Defines Day object as last in a week
178
     * Used only following Calendar_Month_Weekdays::build().
179
     *
180
     * @param bool $state whether it's last or not
181
     */
182
    public function setLast($state = true)
183
    {
184
        if (method_exists($this->calendar, 'setLast')) {
185
            $this->calendar->setLast($state);
186
        }
187
    }
188
189
    /**
190
     * Returns true if Day object is first in a Week
191
     * Only relevant when Day is created by Calendar_Month_Weekdays::build().
192
     *
193
     * @return bool
194
     */
195
    public function isFirst()
196
    {
197
        if (method_exists($this->calendar, 'isFirst')) {
198
            return $this->calendar->isFirst();
199
        }
200
    }
201
202
    /**
203
     * Returns true if Day object is last in a Week
204
     * Only relevant when Day is created by Calendar_Month_Weekdays::build().
205
     *
206
     * @return bool
207
     */
208
    public function isLast()
209
    {
210
        if (method_exists($this->calendar, 'isLast')) {
211
            return $this->calendar->isLast();
212
        }
213
    }
214
215
    /**
216
     * Defines Day object as empty
217
     * Only used by Calendar_Month_Weekdays::build().
218
     *
219
     * @param bool $state whether it's empty or not
220
     */
221
    public function setEmpty($state = true)
222
    {
223
        if (method_exists($this->calendar, 'setEmpty')) {
224
            $this->calendar->setEmpty($state);
225
        }
226
    }
227
228
    /**
229
     * Check if the current object is empty.
230
     *
231
     * @return bool
232
     */
233
    public function isEmpty()
234
    {
235
        if (method_exists($this->calendar, 'isEmpty')) {
236
            return $this->calendar->isEmpty();
237
        }
238
    }
239
240
    /**
241
     * Build the children.
242
     *
243
     * @param array $sDates array containing Calendar objects to select (optional)
244
     *
245
     * @abstract
246
     */
247
    public function build($sDates = [])
248
    {
249
        $this->calendar->build($sDates);
250
    }
251
252
    /**
253
     * Iterator method for fetching child Calendar subclass objects
254
     * (e.g. a minute from an hour object). On reaching the end of
255
     * the collection, returns false and resets the collection for
256
     * further iteratations.
257
     *
258
     * @return mixed either an object subclass of Calendar or false
259
     */
260
    public function fetch()
261
    {
262
        return $this->calendar->fetch();
263
    }
264
265
    /**
266
     * Fetches all child from the current collection of children.
267
     *
268
     * @return array
269
     */
270
    public function fetchAll()
271
    {
272
        return $this->calendar->fetchAll();
273
    }
274
275
    /**
276
     * Get the number Calendar subclass objects stored in the internal collection.
277
     *
278
     * @return int
279
     */
280
    public function size()
281
    {
282
        return $this->calendar->size();
283
    }
284
285
    /**
286
     * Determine whether this date is valid, with the bounds determined by
287
     * the Calendar_Engine. The call is passed on to Calendar_Validator::isValid.
288
     *
289
     * @return bool
290
     */
291
    public function isValid()
292
    {
293
        return $this->calendar->isValid();
294
    }
295
296
    /**
297
     * Returns an instance of Calendar_Validator.
298
     *
299
     * @return Calendar_Validator
300
     */
301
    public function &getValidator()
302
    {
303
        $validator = $this->calendar->getValidator();
304
305
        return $validator;
306
    }
307
308
    /**
309
     * Returns a reference to the current Calendar_Engine being used. Useful
310
     * for Calendar_Table_Helper and Calendar_Validator.
311
     *
312
     * @return object implementing Calendar_Engine_Inteface
313
     */
314
    public function &getEngine()
315
    {
316
        $engine = $this->calendar->getEngine();
317
318
        return $engine;
319
    }
320
321
    /**
322
     * Returns the value for the previous year.
323
     *
324
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
325
     *
326
     * @return int e.g. 2002 or timestamp
327
     */
328
    public function prevYear($format = 'int')
329
    {
330
        return $this->calendar->prevYear($format);
331
    }
332
333
    /**
334
     * Returns the value for this year.
335
     *
336
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
337
     *
338
     * @return int e.g. 2003 or timestamp
339
     */
340
    public function thisYear($format = 'int')
341
    {
342
        return $this->calendar->thisYear($format);
343
    }
344
345
    /**
346
     * Returns the value for next year.
347
     *
348
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
349
     *
350
     * @return int e.g. 2004 or timestamp
351
     */
352
    public function nextYear($format = 'int')
353
    {
354
        return $this->calendar->nextYear($format);
355
    }
356
357
    /**
358
     * Returns the value for the previous month.
359
     *
360
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
361
     *
362
     * @return int e.g. 4 or Unix timestamp
363
     */
364
    public function prevMonth($format = 'int')
365
    {
366
        return $this->calendar->prevMonth($format);
367
    }
368
369
    /**
370
     * Returns the value for this month.
371
     *
372
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
373
     *
374
     * @return int e.g. 5 or timestamp
375
     */
376
    public function thisMonth($format = 'int')
377
    {
378
        return $this->calendar->thisMonth($format);
379
    }
380
381
    /**
382
     * Returns the value for next month.
383
     *
384
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
385
     *
386
     * @return int e.g. 6 or timestamp
387
     */
388
    public function nextMonth($format = 'int')
389
    {
390
        return $this->calendar->nextMonth($format);
391
    }
392
393
    /**
394
     * Returns the value for the previous week.
395
     *
396
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
397
     *
398
     * @return int e.g. 4 or Unix timestamp
399
     */
400
    public function prevWeek($format = 'n_in_month')
401
    {
402
        if (method_exists($this->calendar, 'prevWeek')) {
403
            return $this->calendar->prevWeek($format);
404
        }
405
        require_once __DIR__ . '/PEAR.php';
406
        PEAR::raiseError('Cannot call prevWeek on Calendar object of type: ' . get_class($this->calendar), 133, PEAR_ERROR_TRIGGER, E_USER_NOTICE, 'Calendar_Decorator::prevWeek()');
0 ignored issues
show
The type PEAR was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
The constant PEAR_ERROR_TRIGGER was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
407
408
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type integer.
Loading history...
409
    }
410
411
    /**
412
     * Returns the value for this week.
413
     *
414
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
415
     *
416
     * @return int e.g. 5 or timestamp
417
     */
418
    public function thisWeek($format = 'n_in_month')
419
    {
420
        if (method_exists($this->calendar, 'thisWeek')) {
421
            return $this->calendar->thisWeek($format);
422
        }
423
        require_once __DIR__ . '/PEAR.php';
424
        PEAR::raiseError('Cannot call thisWeek on Calendar object of type: ' . get_class($this->calendar), 133, PEAR_ERROR_TRIGGER, E_USER_NOTICE, 'Calendar_Decorator::thisWeek()');
0 ignored issues
show
The constant PEAR_ERROR_TRIGGER was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
425
426
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type integer.
Loading history...
427
    }
428
429
    /**
430
     * Returns the value for next week.
431
     *
432
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
433
     *
434
     * @return int e.g. 6 or timestamp
435
     */
436
    public function nextWeek($format = 'n_in_month')
437
    {
438
        if (method_exists($this->calendar, 'nextWeek')) {
439
            return $this->calendar->nextWeek($format);
440
        }
441
        require_once __DIR__ . '/PEAR.php';
442
        PEAR::raiseError('Cannot call thisWeek on Calendar object of type: ' . get_class($this->calendar), 133, PEAR_ERROR_TRIGGER, E_USER_NOTICE, 'Calendar_Decorator::nextWeek()');
0 ignored issues
show
The constant PEAR_ERROR_TRIGGER was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
443
444
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type integer.
Loading history...
445
    }
446
447
    /**
448
     * Returns the value for the previous day.
449
     *
450
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
451
     *
452
     * @return int e.g. 10 or timestamp
453
     */
454
    public function prevDay($format = 'int')
455
    {
456
        return $this->calendar->prevDay($format);
457
    }
458
459
    /**
460
     * Returns the value for this day.
461
     *
462
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
463
     *
464
     * @return int e.g. 11 or timestamp
465
     */
466
    public function thisDay($format = 'int')
467
    {
468
        return $this->calendar->thisDay($format);
469
    }
470
471
    /**
472
     * Returns the value for the next day.
473
     *
474
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
475
     *
476
     * @return int e.g. 12 or timestamp
477
     */
478
    public function nextDay($format = 'int')
479
    {
480
        return $this->calendar->nextDay($format);
481
    }
482
483
    /**
484
     * Returns the value for the previous hour.
485
     *
486
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
487
     *
488
     * @return int e.g. 13 or timestamp
489
     */
490
    public function prevHour($format = 'int')
491
    {
492
        return $this->calendar->prevHour($format);
493
    }
494
495
    /**
496
     * Returns the value for this hour.
497
     *
498
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
499
     *
500
     * @return int e.g. 14 or timestamp
501
     */
502
    public function thisHour($format = 'int')
503
    {
504
        return $this->calendar->thisHour($format);
505
    }
506
507
    /**
508
     * Returns the value for the next hour.
509
     *
510
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
511
     *
512
     * @return int e.g. 14 or timestamp
513
     */
514
    public function nextHour($format = 'int')
515
    {
516
        return $this->calendar->nextHour($format);
517
    }
518
519
    /**
520
     * Returns the value for the previous minute.
521
     *
522
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
523
     *
524
     * @return int e.g. 23 or timestamp
525
     */
526
    public function prevMinute($format = 'int')
527
    {
528
        return $this->calendar->prevMinute($format);
529
    }
530
531
    /**
532
     * Returns the value for this minute.
533
     *
534
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
535
     *
536
     * @return int e.g. 24 or timestamp
537
     */
538
    public function thisMinute($format = 'int')
539
    {
540
        return $this->calendar->thisMinute($format);
541
    }
542
543
    /**
544
     * Returns the value for the next minute.
545
     *
546
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
547
     *
548
     * @return int e.g. 25 or timestamp
549
     */
550
    public function nextMinute($format = 'int')
551
    {
552
        return $this->calendar->nextMinute($format);
553
    }
554
555
    /**
556
     * Returns the value for the previous second.
557
     *
558
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
559
     *
560
     * @return int e.g. 43 or timestamp
561
     */
562
    public function prevSecond($format = 'int')
563
    {
564
        return $this->calendar->prevSecond($format);
565
    }
566
567
    /**
568
     * Returns the value for this second.
569
     *
570
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
571
     *
572
     * @return int e.g. 44 or timestamp
573
     */
574
    public function thisSecond($format = 'int')
575
    {
576
        return $this->calendar->thisSecond($format);
577
    }
578
579
    /**
580
     * Returns the value for the next second.
581
     *
582
     * @param string $format return value format ['int'|'timestamp'|'object'|'array']
583
     *
584
     * @return int e.g. 45 or timestamp
585
     */
586
    public function nextSecond($format = 'int')
587
    {
588
        return $this->calendar->nextSecond($format);
589
    }
590
}
591