This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 Nip\Utility; |
||
4 | |||
5 | use DateTime; |
||
6 | use InvalidArgumentException; |
||
7 | |||
8 | /** |
||
9 | * Class DateTimePlus |
||
10 | * Based on briannesbitt/Carbon |
||
11 | * http://carbon.nesbot.com/ |
||
12 | * @package Nip\Utility |
||
13 | * |
||
14 | * @property $day |
||
15 | * @property $month |
||
16 | * @property $year |
||
17 | * @property $hour |
||
18 | * @property $minute |
||
19 | * @property $offset |
||
20 | * @property $second |
||
21 | */ |
||
22 | class DateTimePlus extends DateTime |
||
23 | { |
||
24 | |||
25 | /////////////////////////////////////////////////////////////////// |
||
26 | ///////////////////////// GETTERS AND SETTERS ///////////////////// |
||
27 | /////////////////////////////////////////////////////////////////// |
||
28 | /** |
||
29 | * Get a part of the Carbon object |
||
30 | * |
||
31 | * @param string $name |
||
32 | * |
||
33 | * @throws InvalidArgumentException |
||
34 | * |
||
35 | * @return string|int|\DateTimeZone |
||
36 | */ |
||
37 | public function __get($name) |
||
38 | { |
||
39 | switch (true) { |
||
40 | case array_key_exists($name, $formats = [ |
||
41 | 'year' => 'Y', |
||
42 | 'yearIso' => 'o', |
||
43 | 'month' => 'n', |
||
44 | 'day' => 'j', |
||
45 | 'hour' => 'G', |
||
46 | 'minute' => 'i', |
||
47 | 'second' => 's', |
||
48 | 'micro' => 'u', |
||
49 | 'dayOfWeek' => 'w', |
||
50 | 'dayOfYear' => 'z', |
||
51 | 'weekOfYear' => 'W', |
||
52 | 'daysInMonth' => 't', |
||
53 | 'timestamp' => 'U', |
||
54 | ]): |
||
55 | return (int)$this->format($formats[$name]); |
||
0 ignored issues
–
show
|
|||
56 | case $name === 'weekOfMonth': |
||
57 | return (int)ceil($this->day / static::DAYS_PER_WEEK); |
||
0 ignored issues
–
show
The property
day does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
58 | case $name === 'age': |
||
59 | return (int)$this->diffInYears(); |
||
0 ignored issues
–
show
The method
diffInYears() does not seem to exist on object<Nip\Utility\DateTimePlus> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
60 | case $name === 'quarter': |
||
61 | return (int)ceil($this->month / 3); |
||
0 ignored issues
–
show
The property
month does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
62 | case $name === 'offset': |
||
63 | return $this->getOffset(); |
||
64 | case $name === 'offsetHours': |
||
65 | return $this->getOffset() / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR; |
||
0 ignored issues
–
show
|
|||
66 | case $name === 'dst': |
||
67 | return $this->format('I') === '1'; |
||
0 ignored issues
–
show
The return type of
return $this->format('I') === '1'; (boolean ) is incompatible with the return type documented by Nip\Utility\DateTimePlus::__get of type string|integer|DateTimeZone .
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function ![]() |
|||
68 | case $name === 'local': |
||
69 | return $this->offset === $this->copy()->setTimezone(date_default_timezone_get())->offset; |
||
0 ignored issues
–
show
The property
offset does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The method
copy() does not seem to exist on object<Nip\Utility\DateTimePlus> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() The return type of
return $this->offset ===...imezone_get())->offset; (boolean ) is incompatible with the return type documented by Nip\Utility\DateTimePlus::__get of type string|integer|DateTimeZone .
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function ![]() |
|||
70 | case $name === 'utc': |
||
71 | return $this->offset === 0; |
||
0 ignored issues
–
show
The property
offset does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The return type of
return $this->offset === 0; (boolean ) is incompatible with the return type documented by Nip\Utility\DateTimePlus::__get of type string|integer|DateTimeZone .
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function ![]() |
|||
72 | case $name === 'timezone' || $name === 'tz': |
||
73 | return $this->getTimezone(); |
||
74 | case $name === 'timezoneName' || $name === 'tzName': |
||
75 | return $this->getTimezone()->getName(); |
||
76 | default: |
||
77 | throw new InvalidArgumentException(sprintf("Unknown getter '%s'", $name)); |
||
78 | } |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * Check if an attribute exists on the object |
||
83 | * |
||
84 | * @param string $name |
||
85 | * |
||
86 | * @return bool |
||
87 | */ |
||
88 | public function __isset($name) |
||
89 | { |
||
90 | try { |
||
91 | $this->__get($name); |
||
92 | } catch (InvalidArgumentException $e) { |
||
93 | return false; |
||
94 | } |
||
95 | return true; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * Set a part of the Date object |
||
100 | * |
||
101 | * @param string $name |
||
102 | * @param string|int|\DateTimeZone $value |
||
103 | * |
||
104 | * @throws InvalidArgumentException |
||
105 | */ |
||
106 | public function __set($name, $value) |
||
107 | { |
||
108 | switch ($name) { |
||
109 | case 'year': |
||
110 | $this->setDate($value, $this->month, $this->day); |
||
0 ignored issues
–
show
The property
month does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The property
day does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
111 | break; |
||
112 | case 'month': |
||
113 | $this->setDate($this->year, $value, $this->day); |
||
0 ignored issues
–
show
The property
year does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The property
day does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
114 | break; |
||
115 | case 'day': |
||
116 | $this->setDate($this->year, $this->month, $value); |
||
0 ignored issues
–
show
The property
year does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The property
month does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
117 | break; |
||
118 | case 'hour': |
||
119 | $this->setTime($value, $this->minute, $this->second); |
||
0 ignored issues
–
show
The property
minute does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The property
second does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
120 | break; |
||
121 | case 'minute': |
||
122 | $this->setTime($this->hour, $value, $this->second); |
||
0 ignored issues
–
show
The property
hour does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The property
second does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
123 | break; |
||
124 | case 'second': |
||
125 | $this->setTime($this->hour, $this->minute, $value); |
||
0 ignored issues
–
show
The property
hour does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The property
minute does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
126 | break; |
||
127 | case 'timestamp': |
||
128 | parent::setTimestamp($value); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
setTimestamp() instead of __set() ). Are you sure this is correct? If so, you might want to change this to $this->setTimestamp() .
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The ![]() |
|||
129 | break; |
||
130 | case 'timezone': |
||
131 | case 'tz': |
||
132 | $this->setTimezone($value); |
||
133 | break; |
||
134 | default: |
||
135 | throw new InvalidArgumentException(sprintf("Unknown setter '%s'", $name)); |
||
136 | } |
||
137 | } |
||
138 | |||
139 | |||
140 | /** |
||
141 | * Set the instance's year |
||
142 | * @param int $value |
||
143 | * @return static |
||
144 | */ |
||
145 | public function year($value) |
||
146 | { |
||
147 | $this->year = $value; |
||
0 ignored issues
–
show
The property
year does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
148 | return $this; |
||
149 | } |
||
150 | |||
151 | /** |
||
152 | * Set the instance's month |
||
153 | * @param int $value |
||
154 | * @return static |
||
155 | */ |
||
156 | public function month($value) |
||
157 | { |
||
158 | $this->month = $value; |
||
0 ignored issues
–
show
The property
month does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
159 | return $this; |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * Set the instance's day |
||
164 | * |
||
165 | * @param int $value |
||
166 | * @return static |
||
167 | */ |
||
168 | public function day($value) |
||
169 | { |
||
170 | $this->day = $value; |
||
0 ignored issues
–
show
The property
day does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
171 | return $this; |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * Set the instance's hour |
||
176 | * |
||
177 | * @param int $value |
||
178 | * @return static |
||
179 | */ |
||
180 | public function hour($value) |
||
181 | { |
||
182 | $this->hour = $value; |
||
0 ignored issues
–
show
The property
hour does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
183 | return $this; |
||
184 | } |
||
185 | |||
186 | /** |
||
187 | * Set the instance's minute |
||
188 | * |
||
189 | * @param int $value |
||
190 | * @return static |
||
191 | */ |
||
192 | public function minute($value) |
||
193 | { |
||
194 | $this->minute = $value; |
||
0 ignored issues
–
show
The property
minute does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
195 | return $this; |
||
196 | } |
||
197 | |||
198 | /** |
||
199 | * Set the instance's second |
||
200 | * |
||
201 | * @param int $value |
||
202 | * @return static |
||
203 | */ |
||
204 | public function second($value) |
||
205 | { |
||
206 | $this->second = $value; |
||
0 ignored issues
–
show
The property
second does not exist on object<Nip\Utility\DateTimePlus> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
207 | return $this; |
||
208 | } |
||
209 | |||
210 | |||
211 | /** |
||
212 | * @inheritdoc |
||
213 | */ |
||
214 | public static function createFromFormat($format, $time, $timezone = null) |
||
215 | { |
||
216 | if ($timezone !== null) { |
||
217 | $dt = parent::createFromFormat($format, $time, static::safeCreateDateTimeZone($timezone)); |
||
0 ignored issues
–
show
The method
safeCreateDateTimeZone() does not seem to exist on object<Nip\Utility\DateTimePlus> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||
218 | } else { |
||
219 | $dt = parent::createFromFormat($format, $time); |
||
220 | } |
||
221 | |||
222 | if ($dt instanceof DateTime) { |
||
223 | return static::instance($dt); |
||
224 | } |
||
225 | $errors = static::getLastErrors(); |
||
226 | throw new InvalidArgumentException(implode(PHP_EOL, $errors['errors'])); |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * Modify date to this year |
||
231 | * |
||
232 | * @return static |
||
233 | */ |
||
234 | public function currentYear() |
||
235 | { |
||
236 | return $this->year(date('Y')); |
||
237 | } |
||
238 | |||
239 | /** |
||
240 | * Create a DatePlus instance from a DateTime one. |
||
241 | * @param \DateTime $dt |
||
242 | * @return static |
||
243 | */ |
||
244 | public static function instance(\DateTime $dt) |
||
245 | { |
||
246 | if ($dt instanceof static) { |
||
247 | return clone $dt; |
||
248 | } |
||
249 | return new static($dt->format('Y-m-d H:i:s.u'), $dt->getTimeZone()); |
||
250 | } |
||
251 | } |
||
252 |
This error can happen if you refactor code and forget to move the variable initialization.
Let’s take a look at a simple example:
The above code is perfectly fine. Now imagine that we re-order the statements:
In that case,
$x
would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.