Issues (3541)

samples/calendar/FindItems.php (12 issues)

Labels
Severity
1
<?php
2
/**
3
 * Composer autoload
4
 */
5
require_once __DIR__ . '/../../vendor/autoload.php';
6
7
/**
8
 * Used classes
9
 */
10
use WsdlToPhp\PackageBase\AbstractSoapClientBase;
11
use Ews\EnumType\EwsExchangeVersionType;
0 ignored issues
show
The type Ews\EnumType\EwsExchangeVersionType 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...
12
use Ews\EwsClassMap;
0 ignored issues
show
The type Ews\EwsClassMap 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...
This use statement conflicts with another class in this namespace, EwsClassMap. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
13
use Ews\StructType\EwsFindItemType;
0 ignored issues
show
The type Ews\StructType\EwsFindItemType 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...
14
use Ews\StructType\EwsItemResponseShapeType;
0 ignored issues
show
The type Ews\StructType\EwsItemResponseShapeType 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...
15
use Ews\EnumType\EwsDefaultShapeNamesType;
0 ignored issues
show
The type Ews\EnumType\EwsDefaultShapeNamesType 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...
16
use Ews\StructType\EwsNonEmptyArrayOfBaseFolderIdsType;
0 ignored issues
show
The type Ews\StructType\EwsNonEmptyArrayOfBaseFolderIdsType 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...
17
use Ews\EnumType\EwsDistinguishedFolderIdNameType;
0 ignored issues
show
The type Ews\EnumType\EwsDistinguishedFolderIdNameType 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...
18
use Ews\EnumType\EwsItemQueryTraversalType;
0 ignored issues
show
The type Ews\EnumType\EwsItemQueryTraversalType 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...
19
use Ews\StructType\EwsDistinguishedFolderIdType;
0 ignored issues
show
The type Ews\StructType\EwsDistinguishedFolderIdType 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...
20
use Ews\StructType\EwsRequestServerVersion;
0 ignored issues
show
The type Ews\StructType\EwsRequestServerVersion 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...
21
22
/**
23
 * Your Office 365 login
24
 */
25
define('EWS_WS_LOGIN', '***************************');
26
/**
27
 * Your Office 365 passowrd
28
 */
29
define('EWS_WS_PASSWORD', '************');
30
31
/**
32
 * Minimal options in order to instanciate the ServiceType named Get
33
 */
34
$options = array(
35
    AbstractSoapClientBase::WSDL_URL => __DIR__ . '/../../wsdl/services.updated.wsdl',
36
    AbstractSoapClientBase::WSDL_CLASSMAP => EwsClassMap::get(),
37
    AbstractSoapClientBase::WSDL_LOGIN => EWS_WS_LOGIN,
38
    AbstractSoapClientBase::WSDL_PASSWORD => EWS_WS_PASSWORD,
39
);
40
41
/**
42
 * Instanciation of the ServiceType get that gather all the operations beginnig with "get".
43
 */
44
$find = new \Ews\ServiceType\EwsFind($options);
0 ignored issues
show
The type Ews\ServiceType\EwsFind 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...
45
$find->setLocation('https://pod51036.outlook.com/ews/Exchange.asmx');
46
/**
47
 * Configure the SoapHeader, each header's method begins with "setSoapHeader".
48
 */
49
$find->setSoapHeaderRequestServerVersion(new EwsRequestServerVersion(EwsExchangeVersionType::VALUE_EXCHANGE_2013_SP_1));
50
/**
51
 * Send the request
52
 */
53
$itemType = new EwsFindItemType();
54
$itemShape = new EwsItemResponseShapeType(EwsDefaultShapeNamesType::VALUE_ALL_PROPERTIES);
55
$itemType
56
    ->setItemShape($itemShape)
57
    ->setParentFolderIds(new EwsNonEmptyArrayOfBaseFolderIdsType(null, new EwsDistinguishedFolderIdType(EwsDistinguishedFolderIdNameType::VALUE_CALENDAR)))
58
    ->setTraversal(EwsItemQueryTraversalType::VALUE_SHALLOW);
59
$result = $find->FindItem($itemType);
60
61
/**
62
 * Debug informations provided by the utility methods
63
 */
64
if (false) {
65
    echo 'XML Request: ' . $find->getLastRequest() . "\r\n";
66
    echo 'Headers Request: ' . $find->getLastRequestHeaders() . "\r\n";
67
    echo 'XML Response: ' . $find->getLastResponse() . "\r\n";
68
    echo 'Headers Response: ' . $find->getLastResponseHeaders() . "\r\n";
69
}
70
71
if ($result !== false) {
72
    /**
73
     * Display the Calendar items if there is at least one:
74
     *
75
     * Event with subject "***" starts at "2017-03-15T08:00:00-06:00" and ends at "2017-03-15T08:30:00-06:00" with timezone "(UTC-07:00) Mountain Time (US & Canada)"
76
     * Event with subject "***" starts at "2017-03-15T08:00:00-06:00" and ends at "2017-03-15T08:30:00-06:00" with timezone "(UTC-07:00) Mountain Time (US & Canada)"
77
     * ... etc
78
     */
79
    foreach($result->getResponseMessages()->getFindItemResponseMessage() as $message) {
80
        $events = $message->getRootFolder()->getItems()->getCalendarItem();
81
        if(is_array($events)) {
82
            foreach($events as $item) {
83
               echo PHP_EOL . sprintf('Event with subject "%s" starts at "%s" and ends at "%s" with timezone "%s"',
84
                    $item->getSubject(),
85
                    $item->getStartWallClock(),
86
                    $item->getEndWallClock(),
87
                    $item->getTimeZone());
88
            }
89
        } else {
90
            echo PHP_EOL . 'No event found';
91
        }
92
        echo  PHP_EOL;
93
    }
94
} else {
95
    /**
96
     * In this case, we get the \SoapFault object
97
     */
98
    print_r($find->getLastErrorForMethod('\Ews\ServiceType\EwsFind::FindItem'));
99
}