Issues (180)

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.

tests/RelationsTest.php (36 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 Fwk\Db;
4
5
use Fwk\Db\Relations\Many2Many;
6
use Fwk\Db\Relations\One2Many;
7
use Fwk\Db\Relations\One2One;
8
9
class Commit
10
{
11
    protected $id;
12
    protected $hash;
13
    protected $repositoryId;
14
    protected $pushId;
15
16
    protected $authorName;
17
    protected $authorDate;
18
    protected $authorEmail;
19
20
    protected $authorId;
21
22
    protected $committerName;
23
    protected $committerDate;
24
    protected $committerEmail;
25
26
    protected $committerId;
27
28
    protected $message;
29
30
    protected $indexDate;
31
32
    protected $repository;
33
    protected $author;
34
    protected $committer;
35
    protected $references;
36
    protected $push;
37
38
    public function __construct()
39
    {
40
        $this->push = new One2One(
41
            'pushId',
42
            'id',
43
            'pushes',
44
            'Fwk\Db\Push'
45
        );
46
47
        $this->references = new Many2Many(
48
            'id',
49
            'commitId',
50
            'refs',
51
            'commits_refs',
52
            'id',
53
            'refId',
54
            'Fwk\Db\Reference'
55
        );
56
    }
57
58
    public function getId() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
59
        return $this->id;
60
    }
61
62
    public function setId($id) {
63
        $this->id = $id;
64
    }
65
66
    public function getHash() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
67
        return $this->hash;
68
    }
69
70
    public function setHash($hash) {
71
        $this->hash = $hash;
72
    }
73
74
    public function getRepositoryId() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
75
        return $this->repositoryId;
76
    }
77
78
    public function setRepositoryId($repositoryId) {
79
        $this->repositoryId = $repositoryId;
80
    }
81
82
    public function getPushId() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
83
        return $this->pushId;
84
    }
85
86
    public function setPushId($pushId) {
87
        $this->pushId = $pushId;
88
    }
89
90
    public function getAuthorName() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
91
        return $this->authorName;
92
    }
93
94
    public function setAuthorName($authorName) {
95
        $this->authorName = $authorName;
96
    }
97
98
    public function getAuthorDate() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
99
        return $this->authorDate;
100
    }
101
102
    public function setAuthorDate($authorDate) {
103
        $this->authorDate = $authorDate;
104
    }
105
106
    public function getAuthorEmail() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
107
        return $this->authorEmail;
108
    }
109
110
    public function setAuthorEmail($authorEmail) {
111
        $this->authorEmail = $authorEmail;
112
    }
113
114
    public function getAuthorId() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
115
        return $this->authorId;
116
    }
117
118
    public function setAuthorId($authorId) {
119
        $this->authorId = $authorId;
120
    }
121
122
    public function getCommitterName() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
123
        return $this->committerName;
124
    }
125
126
    public function setCommitterName($committerName) {
127
        $this->committerName = $committerName;
128
    }
129
130
    public function getCommitterDate() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
131
        return $this->committerDate;
132
    }
133
134
    public function setCommitterDate($committerDate) {
135
        $this->committerDate = $committerDate;
136
    }
137
138
    public function getCommitterEmail() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
139
        return $this->committerEmail;
140
    }
141
142
    public function setCommitterEmail($committerEmail) {
143
        $this->committerEmail = $committerEmail;
144
    }
145
146
    public function getCommitterId() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
147
        return $this->committerId;
148
    }
149
150
    public function setCommitterId($committerId) {
151
        $this->committerId = $committerId;
152
    }
153
154
    public function getMessage() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
155
        return $this->message;
156
    }
157
158
    public function setMessage($message) {
159
        $this->message = $message;
160
    }
161
162
    public function getIndexDate() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
163
        return $this->indexDate;
164
    }
165
166
    public function setIndexDate($indexDate) {
167
        $this->indexDate = $indexDate;
168
    }
169
170
    /**
171
     *
172
     * @return One2One
173
     */
174
    public function getRepository()
175
    {
176
        return $this->repository;
177
    }
178
179
    /**
180
     *
181
     * @return One2One
182
     */
183
    public function getAuthor()
184
    {
185
        return $this->author;
186
    }
187
188
    /**
189
     *
190
     * @return One2One
191
     */
192
    public function getCommitter()
193
    {
194
        return $this->committer;
195
    }
196
197
    /**
198
     *
199
     * @return One2One
200
     */
201
    public function getPush()
202
    {
203
        return $this->push;
204
    }
205
206
    /**
207
     *
208
     * @return Many2Many
209
     */
210
    public function getReferences()
211
    {
212
        return $this->references;
213
    }
214
215
    public function getCommitterDateObj()
216
    {
217
        return new \DateTime($this->committerDate);
218
    }
219
220
    public function getAuthorDateObj()
221
    {
222
        return new \DateTime($this->authorDate);
223
    }
224
225
    public function getComputedCommitterName()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
226
    {
227
        if (empty($this->committerId)) {
228
            return (empty($this->committerName) ? $this->committerEmail : $this->committerName);
229
        }
230
231
        return $this->getCommitter()->get()->getFullname();
232
    }
233
}
234
235
236
class Reference
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
237
{
238
    protected $id;
239
    protected $name;
240
    protected $fullname;
241
    protected $repositoryId;
242
    protected $pushId;
243
    protected $createdOn;
244
    protected $commitHash;
245
    protected $type;
246
247
    protected $repository;
248
    protected $commits;
249
    protected $push;
250
251
    public function __construct()
252
    {
253
        $this->commits = new Many2Many(
254
            'id',
255
            'refId',
256
            'commits',
257
            'commits_refs',
258
            'id',
259
            'commitId',
260
            'Fwk\Db\Commit'
261
        );
262
263
        $this->push = new One2One(
264
            'pushId',
265
            'id',
266
            'pushes',
267
            'Fwk\Db\Push'
268
        );
269
    }
270
271
    public function getId() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
272
        return $this->id;
273
    }
274
275
    public function setId($id) {
276
        $this->id = $id;
277
    }
278
279
    public function getName() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
280
        return $this->name;
281
    }
282
283
    public function setName($name) {
284
        $this->name = $name;
285
    }
286
287
    public function getFullname()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
288
    {
289
        return $this->fullname;
290
    }
291
292
    public function setFullname($fullname)
293
    {
294
        $this->fullname = $fullname;
295
    }
296
297
    public function getRepositoryId() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
298
        return $this->repositoryId;
299
    }
300
301
    public function setRepositoryId($repositoryId) {
302
        $this->repositoryId = $repositoryId;
303
    }
304
305
    public function getCreatedOn() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
306
        return $this->createdOn;
307
    }
308
309
    public function setCreatedOn($createdOn) {
310
        $this->createdOn = $createdOn;
311
    }
312
313
    public function getCommitHash() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
314
        return $this->commitHash;
315
    }
316
317
    public function setCommitHash($commitHash)
318
    {
319
        $this->commitHash = $commitHash;
320
    }
321
322
    public function getType()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
323
    {
324
        return $this->type;
325
    }
326
327
    public function setType($type)
328
    {
329
        $this->type = $type;
330
    }
331
332
    public function getPushId() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
333
        return $this->pushId;
334
    }
335
336
    public function setPushId($pushId) {
337
        $this->pushId = $pushId;
338
    }
339
340
    public function getRepository()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
341
    {
342
        return $this->repository;
343
    }
344
345
    public function getCommits()
346
    {
347
        return $this->commits;
348
    }
349
350
    public function isBranch()
351
    {
352
        return $this->type === "branch";
353
    }
354
355
    /**
356
     * @return \Fwk\Db\Relations\One2One
357
     */
358
    public function getPush()
359
    {
360
        return $this->push;
361
    }
362
}
363
364
365
class Push
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
366
{
367
    protected $id;
368
    protected $userId;
369
    protected $username;
370
    protected $repositoryId;
371
    protected $createdOn;
372
373
    protected $repository;
374
    protected $author;
375
    protected $commits;
376
    protected $references;
377
378
    public function __construct()
379
    {
380
        $this->commits = new One2Many(
381
            'id',
382
            'pushId',
383
            'commits',
384
            'Fwk\Db\Commit'
385
        );
386
387
        $this->references = new One2Many(
388
            'id',
389
            'pushId',
390
            'refs',
391
            'Fwk\Db\Reference'
392
        );
393
    }
394
395
    public function getId() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
396
        return $this->id;
397
    }
398
399
    public function setId($id) {
400
        $this->id = $id;
401
    }
402
403
    public function getUserId() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
404
        return $this->userId;
405
    }
406
407
    public function setUserId($userId) {
408
        $this->userId = $userId;
409
    }
410
411
    public function getUsername() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
412
        return $this->username;
413
    }
414
415
    public function setUsername($username) {
416
        $this->username = $username;
417
    }
418
419
    public function getRepositoryId() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
420
        return $this->repositoryId;
421
    }
422
423
    public function setRepositoryId($repositoryId) {
424
        $this->repositoryId = $repositoryId;
425
    }
426
427
    public function getCreatedOn() {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
428
        return $this->createdOn;
429
    }
430
431
    public function setCreatedOn($createdOn) {
432
        $this->createdOn = $createdOn;
433
    }
434
435
    /**
436
     *
437
     * @return One2One
438
     */
439
    public function getRepository()
440
    {
441
        return $this->repository;
442
    }
443
444
    /**
445
     *
446
     * @return One2One
447
     */
448
    public function getAuthor()
449
    {
450
        return $this->author;
451
    }
452
453
    /**
454
     *
455
     * @return One2Many
456
     */
457
    public function getCommits()
458
    {
459
        return $this->commits;
460
    }
461
462
    public function getReferences()
463
    {
464
        return $this->references;
465
    }
466
}
467
468
/**
469
 * Test class for Accessor.
470
 * Generated by PHPUnit on 2012-05-27 at 17:46:42.
471
 */
472
class RelationsTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
473
{
474
    /**
475
     *
476
     * @var \Fwk\Db\Connection
477
     */
478
    protected $connection;
479
480
    /**
481
     * Sets up the fixture, for example, opens a network connection.
482
     * This method is called before a test is executed.
483
     */
484
    protected function setUp()
485
    {
486
        $this->connection = new Connection(array(
487
            'memory'    => true,
488
            'driver'    => 'pdo_sqlite'
489
        ));
490
491
        $this->createGitDatabase($this->connection);
492
    }
493
494
    protected function tearDown()
495
    {
496
        \FwkDbTestUtil::dropTestDb($this->connection);
497
    }
498
499
500
    protected function createGitDatabase(Connection $connection)
501
    {
502
        $schema = $connection->getSchema();
503
        $tbl = $schema->createTable('pushes');
504
        $tbl->addColumn("id", "integer", array("unsigned" => true, "autoincrement" => true));
505
        $tbl->addColumn("userId", "integer", array("unsigned" => true, "notnull" => false));
506
        $tbl->addColumn("username", "string", array("length" => 255, "notnull" => false));
507
        $tbl->addColumn("repositoryId", "integer", array("unsigned" => true));
508
        $tbl->addColumn('createdOn', 'datetime', array('notnull' => false));
509
        $tbl->setPrimaryKey(array("id"));
510
        $tbl->addIndex(array("username"));
511
        $tbl->addIndex(array("repositoryId"));
512
513
        $tbl = $schema->createTable('refs');
514
        $tbl->addColumn("id", "integer", array("unsigned" => true, "autoincrement" => true));
515
        $tbl->addColumn("name", "string", array("length" => 255));
516
        $tbl->addColumn("type", "string", array("length" => 10));
517
        $tbl->addColumn("fullname", "string", array("length" => 255));
518
        $tbl->addColumn("repositoryId", "integer", array("unsigned" => true));
519
        $tbl->addColumn("pushId", "integer", array("unsigned" => true));
520
        $tbl->addColumn('createdOn', 'datetime', array('notnull' => false));
521
        $tbl->addColumn("commitHash", "string", array("length" => 40));
522
        $tbl->setPrimaryKey(array("id"));
523
        $tbl->addIndex(array("pushId"));
524
        $tbl->addIndex(array("repositoryId"));
525
        $tbl->addForeignKeyConstraint('pushes', array("pushId"), array("id"));
0 ignored issues
show
'pushes' is of type string, but the function expects a object<Doctrine\DBAL\Schema\Table>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
526
527
        $tbl = $schema->createTable('commits');
528
        $tbl->addColumn("id", "integer", array("unsigned" => true, "autoincrement" => true));
529
        $tbl->addColumn("hash", "string", array("length" => 40));
530
        $tbl->addColumn("repositoryId", "integer", array("unsigned" => true));
531
        $tbl->addColumn("pushId", "integer", array("unsigned" => true));
532
        $tbl->addColumn("authorName", "string", array("length" => 255, "notnull" => false));
533
        $tbl->addColumn("authorEmail", "string", array("length" => 255));
534
        $tbl->addColumn("authorDate", "datetime", array("length" => 255));
535
        $tbl->addColumn("authorId", "integer", array("unsigned" => true, "notnull" => false));
536
        $tbl->addColumn("committerName", "string", array("length" => 255, "notnull" => false));
537
        $tbl->addColumn("committerEmail", "string", array("length" => 255));
538
        $tbl->addColumn("committerDate", "datetime", array());
539
        $tbl->addColumn("committerId", "integer", array("unsigned" => true, "notnull" => false));
540
        $tbl->addColumn("message", "string", array());
541
        $tbl->addColumn("indexDate", "datetime");
542
        $tbl->setPrimaryKey(array("id"));
543
        $tbl->addUniqueIndex(array("hash", "repositoryId"));
544
        $tbl->addIndex(array("pushId"));
545
        $tbl->addIndex(array("repositoryId"));
546
        $tbl->addIndex(array("authorId"));
547
        $tbl->addIndex(array("committerId"));
548
        $tbl->addForeignKeyConstraint('pushes', array("pushId"), array("id"));
0 ignored issues
show
'pushes' is of type string, but the function expects a object<Doctrine\DBAL\Schema\Table>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
549
550
        $tbl = $schema->createTable('commits_refs');
551
        $tbl->addColumn("commitId", "integer", array("unsigned" => true));
552
        $tbl->addColumn("refId", "integer", array("unsigned" => true));
553
        $tbl->setPrimaryKey(array("commitId", "refId"));
554
        $tbl->addIndex(array("commitId"));
555
        $tbl->addIndex(array("refId"));
556
        $tbl->addForeignKeyConstraint('commits', array("commitId"), array("id"));
0 ignored issues
show
'commits' is of type string, but the function expects a object<Doctrine\DBAL\Schema\Table>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
557
        $tbl->addForeignKeyConstraint('refs', array("refId"), array("id"));
0 ignored issues
show
'refs' is of type string, but the function expects a object<Doctrine\DBAL\Schema\Table>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
558
559
        $connection->connect();
560
        $queries = $schema->toSql($connection->getDriver()->getDatabasePlatform());
561
        foreach ($queries as $query) {
562
            $connection->getDriver()->exec($query);
563
        }
564
    }
565
566
    public function testCreatePushWithCommits()
567
    {
568
        $this->assertEquals(0, count($this->connection->table('pushes')->finder()->all()));
569
        $this->assertEquals(0, count($this->connection->table('commits')->finder()->all()));
570
        $this->assertEquals(0, count($this->connection->table('refs')->finder()->all()));
571
572
        $push = new Push();
573
        $push->setCreatedOn(date('Y-m-d H:i:s'));
574
        $push->setRepositoryId(1);
575
        $push->setUserId(25);
576
        $push->setUsername("Luimeme");
577
578
        $ref = new Reference();
579
        $ref->setRepositoryId(1);
580
        $ref->setCreatedOn(date('Y-m-d H:i:s'));
581
        $ref->setName('master');
582
        $ref->setFullname('refs/origin/master');
583
        $ref->setType("branch");
584
        $ref->setCommitHash(sha1("testCommit1"));
585
586
        $push->getReferences()->add($ref);
587
588
        $commit = new Commit();
589
        $commit->setRepositoryId(1);
590
        $commit->setAuthorName("ducon");
591
        $commit->setAuthorDate(date('Y-m-d H:i:s'));
592
        $commit->setAuthorEmail("[email protected]");
593
        $commit->setAuthorId(null);
594
        $commit->setCommitterDate(date('Y-m-d H:i:s'));
595
        $commit->setCommitterName("Dutrou");
596
        $commit->setCommitterEmail("[email protected]");
597
        $commit->setCommitterId(null);
598
        $commit->setMessage("test commit");
599
        $commit->setIndexDate(date('Y-m-d H:i:s'));
600
        $commit->getPush()->add($push);
601
        $commit->setHash(sha1("testCommit1"));
602
603
        $commit2 = new Commit();
604
        $commit2->setRepositoryId(1);
605
        $commit2->setAuthorName("ducon");
606
        $commit2->setAuthorDate(date('Y-m-d H:i:s'));
607
        $commit2->setAuthorEmail("[email protected]");
608
        $commit2->setAuthorId(null);
609
        $commit2->setCommitterDate(date('Y-m-d H:i:s'));
610
        $commit2->setCommitterName("Dutrou");
611
        $commit2->setCommitterEmail("[email protected]");
612
        $commit2->setCommitterId(null);
613
        $commit2->setMessage("test commit 2");
614
        $commit2->setIndexDate(date('Y-m-d H:i:s'));
615
        $commit2->getPush()->add($push);
616
        $commit2->setHash(sha1("tes2"));
617
618
        $ref->getCommits()->add($commit);
619
        $ref->getCommits()->add($commit2);
620
621
        $this->connection->table('pushes')->save($push);
622
623
        $this->assertEquals(1, count($this->connection->table('pushes')->finder()->all()));
624
        $this->assertEquals(1, count($this->connection->table('refs')->finder()->all()));
625
        $this->assertEquals(2, count($this->connection->table('commits')->finder()->all()));
626
    }
627
}