Issues (2)

Security Analysis    no request data  

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

  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  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.
  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.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
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.

src/Link.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Spatie\CalendarLinks;
4
5
use DateTimeInterface;
6
use Spatie\CalendarLinks\Exceptions\InvalidLink;
7
use Spatie\CalendarLinks\Generators\Google;
8
use Spatie\CalendarLinks\Generators\Ics;
9
use Spatie\CalendarLinks\Generators\WebOutlook;
10
use Spatie\CalendarLinks\Generators\Yahoo;
11
12
/**
13
 * @property-read string $title
14
 * @property-read DateTimeInterface $from
15
 * @property-read DateTimeInterface $to
16
 * @property-read string $description
17
 * @property-read string $address
18
 * @property-read bool $allDay
19
 */
20
class Link
21
{
22
    /** @var string */
23
    protected $title;
24
25
    /** @var \DateTime */
26
    protected $from;
27
28
    /** @var \DateTime */
29
    protected $to;
30
31
    /** @var string */
32
    protected $description;
33
34
    /** @var bool */
35
    protected $allDay;
36
37
    /** @var string */
38
    protected $address;
39
40
    public function __construct(string $title, DateTimeInterface $from, DateTimeInterface $to, bool $allDay = false)
41
    {
42
        $this->title = $title;
43
        $this->allDay = $allDay;
44
45
        if ($to < $from) {
46
            throw InvalidLink::invalidDateRange($from, $to);
47
        }
48
49
        $this->from = clone $from;
0 ignored issues
show
Documentation Bug introduced by
clone $from is of type object<DateTimeInterface>, but the property $from was declared to be of type object<DateTime>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
50
        $this->to = clone $to;
0 ignored issues
show
Documentation Bug introduced by
clone $to is of type object<DateTimeInterface>, but the property $to was declared to be of type object<DateTime>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
51
    }
52
53
    /**
54
     * @param string $title
55
     * @param \DateTimeInterface $from
56
     * @param \DateTimeInterface $to
57
     * @param bool $allDay
58
     *
59
     * @return static
60
     * @throws InvalidLink
61
     */
62
    public static function create(string $title, DateTimeInterface $from, DateTimeInterface $to, bool $allDay = false)
63
    {
64
        return new static($title, $from, $to, $allDay);
65
    }
66
67
    /**
68
     * @param string $title
69
     * @param DateTimeInterface $fromDate
70
     * @param int $numberOfDays
71
     *
72
     * @return Link
73
     * @throws InvalidLink
74
     */
75
    public static function createAllDay(string $title, DateTimeInterface $fromDate, int $numberOfDays = 1): self
76
    {
77
        $from = (clone $fromDate)->modify('midnight');
78
        $to = (clone $from)->modify("+$numberOfDays days");
79
80
        return new self($title, $from, $to, true);
81
    }
82
83
    /**
84
     * @param string $description
85
     *
86
     * @return $this
87
     */
88
    public function description(string $description)
89
    {
90
        $this->description = $description;
91
92
        return $this;
93
    }
94
95
    /**
96
     * @param string $address
97
     *
98
     * @return $this
99
     */
100
    public function address(string $address)
101
    {
102
        $this->address = $address;
103
104
        return $this;
105
    }
106
107
    public function formatWith(Generator $generator): string
108
    {
109
        return $generator->generate($this);
110
    }
111
112
    public function google(): string
113
    {
114
        return $this->formatWith(new Google());
115
    }
116
117
    public function ics(array $options = []): string
118
    {
119
        return $this->formatWith(new Ics($options));
120
    }
121
122
    public function yahoo(): string
123
    {
124
        return $this->formatWith(new Yahoo());
125
    }
126
127
    public function webOutlook(): string
128
    {
129
        return $this->formatWith(new WebOutlook());
130
    }
131
132
    public function __get($property)
133
    {
134
        return $this->$property;
135
    }
136
}
137