Issues (491)

docs/examples/1.php (7 issues)

1
<?php
2
/**
3
* Description: Passes through all main calendar classes, beginning with year
4
* and down to seconds, skipping weeks. Useful to test Calendar is (basically)
5
* working correctly
6
*
7
*/
8
function getmicrotime(){
9
    list($usec, $sec) = explode(" ",microtime());
10
    return ((float)$usec + (float)$sec);
11
}
12
13
if ( !@include 'Calendar/Calendar.php' ) {
14
    define('CALENDAR_ROOT','../../');
15
}
16
17
if (!isset($_GET['y'])) $_GET['y'] = 2003;
18
if (!isset($_GET['m'])) $_GET['m'] = 8;
19
if (!isset($_GET['d'])) $_GET['d'] = 9;
20
if (!isset($_GET['h'])) $_GET['h'] = 12;
21
if (!isset($_GET['i'])) $_GET['i'] = 34;
22
if (!isset($_GET['s'])) $_GET['s'] = 46;
23
24
switch ( @$_GET['view'] ) {
25
    default:
26
        $_GET['view'] = 'calendar_year';
27
    case 'calendar_year':
28
        require_once CALENDAR_ROOT.'Year.php';
29
        $c = new Calendar_Year($_GET['y']);
0 ignored issues
show
The type Calendar_Year 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...
30
    break;
31
    case 'calendar_month':
32
        require_once CALENDAR_ROOT.'Month.php';
33
        $c = new Calendar_Month($_GET['y'],$_GET['m']);
0 ignored issues
show
The type Calendar_Month 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...
34
    break;
35
    case 'calendar_day':
36
        require_once CALENDAR_ROOT.'Day.php';
37
        $c = new Calendar_Day($_GET['y'],$_GET['m'],$_GET['d']);
0 ignored issues
show
The type Calendar_Day 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...
38
    break;
39
    case 'calendar_hour':
40
        require_once CALENDAR_ROOT.'Hour.php';
41
        $c = new Calendar_Hour($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h']);
0 ignored issues
show
The type Calendar_Hour 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...
42
    break;
43
    case 'calendar_minute':
44
        require_once CALENDAR_ROOT.'Minute.php';
45
        $c = new Calendar_Minute($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i']);
0 ignored issues
show
The type Calendar_Minute 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...
46
    break;
47
    case 'calendar_second':
48
        require_once CALENDAR_ROOT.'Second.php';
49
        $c = new Calendar_Second($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i'],$_GET['s']);
0 ignored issues
show
The type Calendar_Second 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...
50
    break;
51
}
52
53
echo ( 'Viewing: '.@$_GET['view'].'<br />' );
54
echo ( 'The time is now: '.date('Y M d H:i:s',$c->getTimestamp()).'<br >' );
55
56
$i = 1;
57
echo ( '<h1>First Iteration</h1>' );
58
echo ( '<p>The first iteration is more "expensive", the calendar data
59
        structures having to be built.</p>' );
60
$start = getmicrotime();
61
$c->build();
62
while ( $e = $c->fetch() ) {
63
    $class = strtolower(get_class($e));
64
    $link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay().
65
        "&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond();
66
    $method = 'this'.str_replace('calendar_','',$class);
67
    echo ( "<a href=\"".$_SERVER['PHP_SELF']."?view=".$class.$link."\">".$e->{$method}()."</a> : " );
68
    if ( ($i % 10) == 0 ) {
69
        echo ( '<br>' );
70
    }
71
    $i++;
72
}
73
echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' );
74
75
$i = 1;
76
echo ( '<h1>Second Iteration</h1>' );
77
echo ( '<p>This second iteration is faster, the data structures
78
        being re-used</p>' );
79
$start = getmicrotime();
80
while ( $e = $c->fetch() ) {
81
    $class = strtolower(get_class($e));
82
    $link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay().
83
        "&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond();
84
    $method = 'this'.str_replace('calendar_','',$class);
85
    echo ( "<a href=\"".$_SERVER['PHP_SELF']."?view=".$class.$link."\">".$e->{$method}()."</a> : " );
86
    if ( ($i % 10) == 0 ) {
87
        echo ( '<br>' );
88
    }
89
    $i++;
90
}
91
echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' );
92
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...