Issues (3541)

samples/task/CreateItem.php (13 issues)

Labels
Severity
1
<?php
2
/**
3
 * Composer autoload
4
 */
5
require_once __DIR__ . '/../vendor/autoload.php';
6
/**
7
 * Used classes
8
 */
9
use WsdlToPhp\PackageBase\AbstractSoapClientBase;
10
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...
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\StructType\EwsCreateItemType;
0 ignored issues
show
The type Ews\StructType\EwsCreateItemType 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...
13
use Ews\StructType\EwsTargetFolderIdType;
0 ignored issues
show
The type Ews\StructType\EwsTargetFolderIdType 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\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...
15
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...
16
use Ews\StructType\EwsNonEmptyArrayOfAllItemsType;
0 ignored issues
show
The type Ews\StructType\EwsNonEmptyArrayOfAllItemsType 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\StructType\EwsTaskType;
0 ignored issues
show
The type Ews\StructType\EwsTaskType 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\EwsClassMap;
0 ignored issues
show
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...
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...
19
use Ews\StructType\EwsBodyType;
0 ignored issues
show
The type Ews\StructType\EwsBodyType 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\EnumType\EwsBodyTypeType;
0 ignored issues
show
The type Ews\EnumType\EwsBodyTypeType 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
 * Your Office 365 login
23
 */
24
define('EWS_WS_LOGIN', '***************************');
25
/**
26
 * Your Office 365 passowrd
27
 */
28
define('EWS_WS_PASSWORD', '************');
29
/**
30
 * Minimal options in order to instanciate the ServiceType named Get
31
 */
32
$options = array(
33
    AbstractSoapClientBase::WSDL_URL => __DIR__ . '/../wsdl/services.wsdl',
34
    AbstractSoapClientBase::WSDL_CLASSMAP => EwsClassMap::get(),
35
    AbstractSoapClientBase::WSDL_LOGIN => EWS_WS_LOGIN,
36
    AbstractSoapClientBase::WSDL_PASSWORD => EWS_WS_PASSWORD
37
);
38
/**
39
 * Instanciation of the ServiceType get that gather all the operations beginnig with "get".
40
 */
41
$create = new \Ews\ServiceType\EwsCreate($options);
0 ignored issues
show
The type Ews\ServiceType\EwsCreate 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
$create->setLocation('https://pod51036.outlook.com/ews/Exchange.asmx');
43
/**
44
 * Configure the SoapHeader, each header's method begins with "setSoapHeader".
45
 */
46
$create->setSoapHeaderRequestServerVersion(new EwsRequestServerVersion(EwsExchangeVersionType::VALUE_EXCHANGE_2013_SP_1));
47
/**
48
 * Send the request, you can customize the request by modifiying the new \Ews\StructType\EwsGetServerTimeZonesType() instance
49
 */
50
$items = new EwsNonEmptyArrayOfAllItemsType();
51
$task = new EwsTaskType();
52
$dueDate = new \DateTime('today + 5 day');
53
$task->setDueDate($dueDate->format('Y-m-d\TH:i:s\Z'))
54
    ->setBody(new EwsBodyType(EwsBodyTypeType::VALUE_TEXT, 'This task is very important, please do it as soon as possible'))
55
    ->setSubject('Sample task created with EWS')
56
    ->setReminderDueBy($dueDate->sub(new \DateInterval('PT1H'))
57
    ->format('Y-m-d\TH:i:s\Z'))
58
    ->setReminderIsSet(true);
59
$items->setTask($task);
60
$itemType = new EwsCreateItemType(new EwsTargetFolderIdType(null, new EwsDistinguishedFolderIdType(EwsDistinguishedFolderIdNameType::VALUE_TASKS)), $items);
61
$result = $create->CreateItem($itemType);
62
/**
63
 * Debug informations provided by the utility methods
64
 */
65
if (true) {
66
    echo 'XML Request: ' . $create->getLastRequest() . "\r\n";
67
    echo 'Headers Request: ' . $create->getLastRequestHeaders() . "\r\n";
68
    echo 'XML Response: ' . $create->getLastResponse() . "\r\n";
69
    echo 'Headers Response: ' . $create->getLastResponseHeaders() . "\r\n";
70
}
71
/**
72
 * Sample call for CreateItem operation/method
73
 */
74
if ($result !== false) {
75
    /**
76
     * Display the message
77
     */
78
    foreach ($result->getResponseMessages()->getCreateItemResponseMessage() as $message) {
79
        $responseCode = $message->getResponseCode();
80
        echo PHP_EOL . sprintf('Response code: %s', $responseCode);
81
        $itemsCreated = $message->getItems()->getTask();
82
        if (is_array($itemsCreated)) {
83
            foreach ($itemsCreated as $itemCreated) {
84
                echo PHP_EOL . sprintf('Task created with id %s', $itemCreated->getItemId()->getId());
85
            }
86
        } else {
87
            echo PHP_EOL . 'No message found';
88
        }
89
        echo PHP_EOL;
90
    }
91
} else {
92
    /**
93
     * In this case, we get the \SoapFault object
94
     */
95
    print_r($create->getLastErrorForMethod('\Ews\ServiceType\EwsCreate::CreateItem'));
96
}