1 | <?php |
||
52 | class ObjectFactory extends AbstractObjectFactory |
||
53 | { |
||
54 | /** |
||
55 | * Create a repository object |
||
56 | * |
||
57 | * @param \DateTimeInterface $creationDate Creation date |
||
58 | * @param int $objectId Object ID |
||
59 | * @param array $config Object configuration |
||
60 | */ |
||
61 | 1 | public function create(\DateTimeInterface $creationDate, $objectId, array $config) |
|
62 | { |
||
63 | 1 | $objectTypeMethod = ucfirst($config[Repository::TYPE]); |
|
64 | 1 | $objectMutator = null; |
|
65 | |||
66 | /** @var ObjectInterface $object */ |
||
67 | 1 | $object = $this->{'create'.$objectTypeMethod}($creationDate, $objectMutator); |
|
68 | |||
69 | // Create the object revisions |
||
70 | 1 | $this->createObjectRevisions($object, $config, $objectMutator); |
|
|
|||
71 | |||
72 | // Eventually hide the object if necessary |
||
73 | 1 | if (($config[Repository::HIDDEN] > 0) ? (rand(0, 100) < ($config[Repository::HIDDEN] * 100)) : false) { |
|
74 | 1 | $object->delete()->persist(); |
|
75 | } |
||
76 | 1 | } |
|
77 | |||
78 | /** |
||
79 | * Create the object revisions |
||
80 | * |
||
81 | * @param ObjectInterface $object Object |
||
82 | * @param array $config Object configuration |
||
83 | * @param ObjectMutatorInterface $objectMutator Object mutator |
||
84 | */ |
||
85 | 1 | protected function createObjectRevisions( |
|
86 | ObjectInterface $object, |
||
87 | array $config, |
||
88 | ObjectMutatorInterface $objectMutator |
||
89 | ) { |
||
90 | // Determine the amount of archive revisions to create |
||
91 | 1 | $revisions = ($config[Repository::REVISIONS] < 0) ? |
|
92 | 1 | rand(1, abs($config[Repository::REVISIONS]) + 1) : (1 + $config[Repository::REVISIONS]); |
|
93 | |||
94 | // Determine the draft status |
||
95 | 1 | $draft = (($config[Repository::DRAFTS] > 0) ? (rand(0, 100) < $config[Repository::DRAFTS] * 100) : 0); |
|
96 | |||
97 | // Build the revision path list |
||
98 | 1 | for ($revision = 1; $revision < $revisions - $draft; ++$revision) { |
|
99 | 1 | $objectMutator->mutate($object)->publish()->persist(); |
|
100 | } |
||
101 | 1 | if ($revision <= $revisions - $draft) { |
|
102 | 1 | $objectMutator->mutate($object)->publish()->persist(); |
|
103 | } |
||
104 | 1 | if ($draft) { |
|
105 | 1 | $objectMutator->mutate($object)->persist(); |
|
106 | } |
||
107 | 1 | } |
|
108 | |||
109 | /** |
||
110 | * Create an article object |
||
111 | * |
||
112 | * @param \DateTimeInterface $creationDate Creation date |
||
113 | * @return ObjectInterface Article |
||
114 | */ |
||
115 | 1 | protected function createArticle(\DateTimeInterface $creationDate, ObjectMutatorInterface &$objectMutator = null) |
|
121 | } |
||
122 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: