Completed
Push — master ( 7eae42...8f150d )
by Thiago
10:26
created

src/Common/src/Entity.php (2 issues)

Labels
Severity

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
declare(strict_types = 1);
3
4
namespace Common;
5
6
use DateTime;
7
use Doctrine\ORM\Mapping as ORM;
8
9
/**
10
 * @author Thiago Paes <[email protected]>
11
 * @ORM\MappedSuperclass(repositoryClass="Doctrine\ORM\EntityRepository")
12
 */
13
trait Entity
14
{
15
    /**
16
     * @ORM\PrePersist
17
     */
18
    public function onPrePersist()
19
    {
20
        $this->created = new DateTime();
0 ignored issues
show
The property created does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
21
        $this->updated = new DateTime();
0 ignored issues
show
The property updated does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
22
    }
23
24
    /**
25
     * @ORM\PreUpdate
26
     */
27
    public function onPreUpdate()
28
    {
29
        $this->updated = new DateTime();
30
    }
31
}
32