Passed
Push — master ( 26274e...3e6eee )
by Arthur
05:26 queued 10s
created

ContentManager::openComment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace SoliDry\Blocks;
4
5
use SoliDry\Controllers\BaseCommand;
6
use SoliDry\Helpers\Console;
7
use SoliDry\Helpers\MethodOptions;
8
use SoliDry\Types\DefaultInterface;
9
use SoliDry\Types\PhpInterface;
10
use SoliDry\Types\ApiInterface;
11
12
/**
13
 * Class ContentManager
14
 *
15
 * @package SoliDry\Blocks
16
 * @property BaseCommand generator
17
 * @property string sourceCode
18
 */
19
trait ContentManager
20
{
21
22
    /**
23
     *  Sets <?php open tag for source code
24
     */
25
    protected function setTag(): void
26
    {
27
        $this->sourceCode = PhpInterface::PHP_OPEN_TAG . PHP_EOL;
28
    }
29
30
    /**
31
     * @param string $postfix
32
     */
33
    protected function setNamespace(string $postfix): void
34
    {
35
        $this->sourceCode .= PhpInterface::PHP_NAMESPACE . PhpInterface::SPACE .
36
            $this->generator->modulesDir . PhpInterface::BACKSLASH .
37
            strtoupper($this->generator->version) .
38
            PhpInterface::BACKSLASH . $postfix . PhpInterface::SEMICOLON . PHP_EOL . PHP_EOL;
39
    }
40
41
    /**
42
     * @param string $path
43
     * @param bool $isTrait
44
     * @param bool $isLast
45
     */
46
    protected function setUse(string $path, bool $isTrait = false, bool $isLast = false): void
47
    {
48
        $this->sourceCode .= (($isTrait === false) ? '' : PhpInterface::TAB_PSR4) .
49
            PhpInterface::PHP_USE . PhpInterface::SPACE . $path . PhpInterface::SEMICOLON .
50
            PHP_EOL . (($isLast === false) ? '' : PHP_EOL);
51
    }
52
53
    /**
54
     * @param string $name
55
     * @param null $extends
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $extends is correct as it would always require null to be passed?
Loading history...
56
     */
57
    protected function startClass(string $name, $extends = NULL): void
58
    {
59
        $this->sourceCode .= PhpInterface::PHP_CLASS . PhpInterface::SPACE . $name
60
            . PhpInterface::SPACE;
61
        if ($extends !== NULL) {
0 ignored issues
show
introduced by
The condition $extends !== NULL is always false.
Loading history...
62
            $this->sourceCode .=
63
                PhpInterface::PHP_EXTENDS
64
                . PhpInterface::SPACE . $extends . PhpInterface::SPACE;
65
        }
66
        $this->sourceCode .= PHP_EOL . PhpInterface::OPEN_BRACE . PHP_EOL;
67
    }
68
69
    /**
70
     *  Ends class declaration
71
     */
72
    protected function endClass(): void
73
    {
74
        $this->sourceCode .= PhpInterface::CLOSE_BRACE . PHP_EOL;
75
    }
76
77
    /**
78
     * @param MethodOptions $methodOptions
79
     */
80
    protected function startMethod(MethodOptions $methodOptions): void
81
    {
82
        // get params
83
        $params = $this->getMethodParams($methodOptions->getParams());
84
        $this->sourceCode .= PhpInterface::TAB_PSR4 . $methodOptions->getModifier() . PhpInterface::SPACE .
85
            (($methodOptions->isStatic() !== false) ? PhpInterface::PHP_STATIC . PhpInterface::SPACE :
86
                '') .
87
            PhpInterface::PHP_FUNCTION . PhpInterface::SPACE .
88
            $methodOptions->getName()
89
            . PhpInterface::OPEN_PARENTHESES . $params . PhpInterface::CLOSE_PARENTHESES .
90
            ((empty($methodOptions->getReturnType())) ? '' :
91
                PhpInterface::COLON . PhpInterface::SPACE . $methodOptions->getReturnType()) .
92
            PhpInterface::SPACE . PHP_EOL . PhpInterface::TAB_PSR4
93
            . PhpInterface::OPEN_BRACE . PHP_EOL;
94
    }
95
96
    /**
97
     * Sets return stmt for any generated method
98
     *
99
     * @param string $value
100
     * @param bool $isString
101
     */
102
    protected function setMethodReturn(string $value, $isString = false): void
103
    {
104
        $this->setTabs(2);
105
        $this->sourceCode .= PhpInterface::PHP_RETURN . PhpInterface::SPACE . (($isString === false) ? $value :
106
                PhpInterface::DOUBLE_QUOTES . $value . PhpInterface::DOUBLE_QUOTES) . PhpInterface::SEMICOLON . PHP_EOL;
107
    }
108
109
    /**
110
     * Ends method declaration
111
     *
112
     * @param int $eolCnt
113
     */
114
    protected function endMethod(int $eolCnt = 2): void
115
    {
116
        $this->sourceCode .= PhpInterface::TAB_PSR4 . PhpInterface::CLOSE_BRACE;
117
        for ($i = $eolCnt; $i > 0; --$i) {
118
            $this->sourceCode .= PHP_EOL;
119
        }
120
    }
121
122
    /**
123
     *  Starts an array declaration in string notation
124
     */
125
    protected function startArray(): void
126
    {
127
        $this->setTabs(2);
128
        $this->sourceCode .= PhpInterface::PHP_RETURN . PhpInterface::SPACE .
129
            PhpInterface::OPEN_BRACKET . PHP_EOL;
130
    }
131
132
    /**
133
     *  Ends an array declaration after values had been set
134
     */
135
    protected function endArray(): void
136
    {
137
        $this->sourceCode .= PHP_EOL . PhpInterface::TAB_PSR4 . PhpInterface::TAB_PSR4
138
            . PhpInterface::CLOSE_BRACKET . PhpInterface::SEMICOLON . PHP_EOL;
139
    }
140
141
    /**
142
     * Creates simple key=value map array property
143
     *
144
     * @param $key
145
     * @param $value
146
     */
147
    private function setArrayProperty($key, array $value): void
148
    {
149
        $val = $this->setArrayToString($value);
150
        $this->sourceCode .= $this->quoteParam($key)
151
            . PhpInterface::SPACE . PhpInterface::DOUBLE_ARROW
152
            . PhpInterface::SPACE . $val . PhpInterface::COMMA . PHP_EOL;
153
    }
154
155
    /**
156
     * @param string $prop
157
     * @param string $modifier
158
     * @param string $value
159
     * @param bool $isString
160
     */
161
    protected function createProperty(
162
        string $prop,
163
        string $modifier,
164
        $value = PhpInterface::PHP_TYPES_NULL,
165
        bool $isString = false
166
    ): void {
167
        if ($value === PhpInterface::PHP_TYPES_NULL) { // drop null assignments as they are already nullable by default
168
            $this->sourceCode .= PhpInterface::TAB_PSR4 . $modifier . PhpInterface::SPACE . PhpInterface::DOLLAR_SIGN .
169
                $prop . PhpInterface::SEMICOLON . PHP_EOL;
170
        } else {
171
            $this->sourceCode .= PhpInterface::TAB_PSR4 . $modifier . PhpInterface::SPACE . PhpInterface::DOLLAR_SIGN .
172
                $prop . PhpInterface::SPACE . PhpInterface::EQUALS . PhpInterface::SPACE
173
                . (($isString === false) ? $value : PhpInterface::QUOTES . $value . PhpInterface::QUOTES) . PhpInterface::SEMICOLON . PHP_EOL;
174
        }
175
    }
176
177
    /**
178
     * @param string $prop
179
     * @param string $modifier
180
     * @param array $value
181
     */
182
    protected function createPropertyArray(string $prop, string $modifier, array $value): void
183
    {
184
        $val = $this->setArrayToString($value);
185
        $this->sourceCode .= PhpInterface::TAB_PSR4 . $modifier . PhpInterface::SPACE . PhpInterface::DOLLAR_SIGN .
186
            $prop . PhpInterface::SPACE . PhpInterface::EQUALS . PhpInterface::SPACE . $val . PhpInterface::SEMICOLON . PHP_EOL;
187
    }
188
189
    /**
190
     * @param array $value
191
     * @return string
192
     */
193
    private function setArrayToString(array $value): string
194
    {
195
        $val = PhpInterface::OPEN_BRACKET;
196
        $val .= PhpInterface::QUOTES . implode(
197
                PhpInterface::QUOTES . PhpInterface::COMMA . PhpInterface::SPACE . PhpInterface::QUOTES, $value
198
            ) . PhpInterface::QUOTES;
199
        $val .= PhpInterface::CLOSE_BRACKET;
200
201
        return $val;
202
    }
203
204
    /**
205
     * @param string $comment
206
     * @param int $tabs
207
     */
208
    protected function setComment(string $comment, int $tabs = 1): void
209
    {
210
        $this->sourceCode .= $this->setTabs($tabs) . PhpInterface::COMMENT
0 ignored issues
show
Bug introduced by
Are you sure $this->setTabs($tabs) of type void can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

210
        $this->sourceCode .= /** @scrutinizer ignore-type */ $this->setTabs($tabs) . PhpInterface::COMMENT
Loading history...
Bug introduced by
Are you sure the usage of $this->setTabs($tabs) targeting SoliDry\Blocks\ContentManager::setTabs() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
211
            . PhpInterface::SPACE . $comment . PHP_EOL;
212
    }
213
214
    /**
215
     * @param int $tabs
216
     */
217
    protected function openComment(int $tabs = 1): void
218
    {
219
        $this->sourceCode .= $this->setTabs($tabs) . PhpInterface::SLASH
0 ignored issues
show
Bug introduced by
Are you sure $this->setTabs($tabs) of type void can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

219
        $this->sourceCode .= /** @scrutinizer ignore-type */ $this->setTabs($tabs) . PhpInterface::SLASH
Loading history...
Bug introduced by
Are you sure the usage of $this->setTabs($tabs) targeting SoliDry\Blocks\ContentManager::setTabs() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
220
            . PhpInterface::ASTERISK . PhpInterface::ASTERISK . PHP_EOL;
221
    }
222
223
    /**
224
     * @param int $tabs
225
     */
226
    protected function closeComment(int $tabs = 1): void
227
    {
228
        $this->sourceCode .= $this->setTabs($tabs) . PhpInterface::ASTERISK
0 ignored issues
show
Bug introduced by
Are you sure $this->setTabs($tabs) of type void can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

228
        $this->sourceCode .= /** @scrutinizer ignore-type */ $this->setTabs($tabs) . PhpInterface::ASTERISK
Loading history...
Bug introduced by
Are you sure the usage of $this->setTabs($tabs) targeting SoliDry\Blocks\ContentManager::setTabs() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
229
            . PhpInterface::SLASH . PHP_EOL;
230
    }
231
232
    /**
233
     * @param string $comment
234
     * @param int $tabs
235
     * @param int $afterTabs
236
     */
237
    protected function setStarredComment(string $comment, int $tabs = 1, int $afterTabs = 0): void
238
    {
239
        $this->setTabs($tabs);
240
        $this->sourceCode .= PhpInterface::ASTERISK
241
            . PhpInterface::SPACE;
242
243
        $this->setTabs($afterTabs);
244
245
        $this->sourceCode .= $comment . PHP_EOL;
246
    }
247
248
    /**
249
     * Sets an amount of tabs to source code
250
     *
251
     * @param int $amount
252
     */
253
    protected function setTabs(int $amount = 1): void
254
    {
255
        for ($i = $amount; $i > 0; --$i) {
256
            $this->sourceCode .= PhpInterface::TAB_PSR4;
257
        }
258
    }
259
260
    /**
261
     * Sets an amount of backslashes to source code
262
     *
263
     * @param int $amount
264
     */
265
    protected function setBackslashes(int $amount = 1): void
266
    {
267
        for ($i = $amount; $i > 0; --$i) {
268
            $this->sourceCode .= PhpInterface::BACKSLASH;
269
        }
270
    }
271
272
    /**
273
     * @param array $attrVal
274
     */
275
    public function setDescription(array $attrVal): void
276
    {
277
        foreach ($attrVal as $k => $v) {
278
            if ($k === ApiInterface::RAML_KEY_DESCRIPTION) {
279
                $this->setTabs(3);
280
                $this->setComment($v);
281
            }
282
        }
283
    }
284
285
    /**
286
     * @param array $params
287
     *
288
     * @return string
289
     */
290
    private function getMethodParams(array $params): string
291
    {
292
        $paramsStr = '';
293
        $cnt = count($params);
294
        foreach ($params as $type => $name) {
295
            --$cnt;
296
            if (is_int($type)) {// not typed
297
                $paramsStr .= PhpInterface::DOLLAR_SIGN . $name;
298
            } else {// typed
299
                $paramsStr .= $type . PhpInterface::SPACE . PhpInterface::DOLLAR_SIGN . $name;
300
            }
301
            if ($cnt > 0) {
302
                $paramsStr .= PhpInterface::COMMA . PhpInterface::SPACE;
303
            }
304
        }
305
306
        return $paramsStr;
307
    }
308
309
    /**
310
     * @param array $params
311
     *
312
     * @param bool $arrayToJson
313
     * @return string
314
     */
315
    private function getMethodParamsToPass(array $params, $arrayToJson = true): string
316
    {
317
        $paramsStr = '';
318
        $cnt = count($params);
319
        foreach ($params as $value) {
320
            --$cnt;
321
            if (is_array($value)) {
322
                $paramsStr .= $arrayToJson ? $this->quoteParam(json_encode($value)) : var_export($value, true);
323
            } else {
324
                $paramsStr .= $this->quoteParam($value);
325
            }
326
            if ($cnt > 0) {
327
                $paramsStr .= PhpInterface::COMMA . PhpInterface::SPACE;
328
            }
329
        }
330
331
        return $paramsStr;
332
    }
333
334
    /**
335
     * @param string $str
336
     */
337
    public function setEchoString(string $str): void
338
    {
339
        $this->sourceCode .= PhpInterface::ECHO . PhpInterface::SPACE . PhpInterface::QUOTES
340
            . $str . PhpInterface::QUOTES . PhpInterface::SEMICOLON . PHP_EOL;
341
    }
342
343
    /**
344
     * @param string $attribute
345
     */
346
    public function openRule(string $attribute): void
347
    {
348
        $this->sourceCode .= PhpInterface::TAB_PSR4 . PhpInterface::TAB_PSR4 .
349
            PhpInterface::TAB_PSR4
350
            . PhpInterface::QUOTES . $attribute . PhpInterface::QUOTES
351
            . PhpInterface::SPACE
352
            . PhpInterface::DOUBLE_ARROW .
353
            PhpInterface::SPACE . PhpInterface::QUOTES;
354
    }
355
356
    /**
357
     *  Close rules in FormRequest
358
     */
359
    public function closeRule(): void
360
    {
361
        $this->sourceCode .= PhpInterface::QUOTES . PhpInterface::COMMA;
362
    }
363
364
    /**
365
     * @uses \SoliDry\Blocks\Controllers::setContent
366
     * @uses \SoliDry\Blocks\Config::setContent
367
     * @uses \SoliDry\Blocks\Migrations::setContent
368
     * @uses \SoliDry\Blocks\Entities::setContent
369
     * @uses \SoliDry\Blocks\FormRequest::setContent
370
     * @uses \SoliDry\Blocks\Tests::setContent
371
     *
372
     * Creates entities like *Controller, *FormRequest, BaseModel entities etc
373
     *
374
     * @param string $basePath
375
     * @param string $postFix
376
     */
377
    public function createEntity(string $basePath, string $postFix = ''): void
378
    {
379
        $this->setContent();
0 ignored issues
show
Bug introduced by
The method setContent() does not exist on SoliDry\Blocks\ContentManager. Did you maybe mean setComment()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

379
        $this->/** @scrutinizer ignore-call */ 
380
               setContent();

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.

Loading history...
380
        $file = $this->getEntityFile($basePath, $postFix);
381
        $isCreated = FileManager::createFile(
382
            $file, $this->sourceCode,
383
            FileManager::isRegenerated($this->generator->options)
384
        );
385
        if ($isCreated) {
386
            Console::out($file . PhpInterface::SPACE . Console::CREATED, Console::COLOR_GREEN);
387
        }
388
    }
389
390
    /**
391
     * Gets Laravel <Entity> file
392
     *
393
     * @param string $basePath
394
     * @param string $postFix
395
     * @return string
396
     */
397
    public function getEntityFile(string $basePath, string $postFix = ''): string
398
    {
399
        $file = $basePath . DIRECTORY_SEPARATOR . $this->className;
400
        if ($postFix !== '') {
401
            $file .= $postFix;
402
        }
403
        $file .= PhpInterface::PHP_EXT;
404
405
        return $file;
406
    }
407
408
    /**
409
     * Creates entities like *Controller, *FormRequest, BaseModel entities etc
410
     *
411
     * @param string $basePath
412
     * @param string $postFix
413
     */
414
    public function recreateEntity(string $basePath, string $postFix = ''): void
415
    {
416
        $this->resetContent();
0 ignored issues
show
Bug introduced by
It seems like resetContent() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

416
        $this->/** @scrutinizer ignore-call */ 
417
               resetContent();
Loading history...
417
        $file = $this->getEntityFile($basePath, $postFix);
418
        $isCreated = FileManager::createFile(
419
            $file, $this->sourceCode,
420
            FileManager::isRegenerated($this->generator->options)
421
        );
422
        if ($isCreated) {
423
            Console::out($file . PhpInterface::SPACE . Console::CREATED, Console::COLOR_GREEN);
424
        }
425
    }
426
427
    /**
428
     * Gets array param as string to place in generated methods
429
     *
430
     * @param array $param
431
     *
432
     * @return string
433
     */
434
    private function getArrayParam(array $param): string
435
    {
436
        return PhpInterface::OPEN_BRACKET . PhpInterface::QUOTES .
437
            implode(PhpInterface::QUOTES . PhpInterface::COMMA . PhpInterface::SPACE . PhpInterface::QUOTES, $param)
438
            . PhpInterface::QUOTES
439
            . PhpInterface::CLOSE_BRACKET;
440
    }
441
442
    /**
443
     * @param string $param
444
     *
445
     * @return string
446
     */
447
    public function quoteParam(string $param): string
448
    {
449
        return PhpInterface::QUOTES . $param . PhpInterface::QUOTES;
450
    }
451
452
    /**
453
     * Sets the source starting code
454
     *
455
     * @param string $entityFile
456
     */
457
    protected function setBeforeProps(string $entityFile): void
458
    {
459
        $this->resourceCode = file_get_contents($entityFile);
0 ignored issues
show
Bug Best Practice introduced by
The property resourceCode does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
460
        $end = mb_strpos($this->resourceCode, DefaultInterface::PROPS_START, NULL, PhpInterface::ENCODING_UTF8) - 3;
461
        $this->sourceCode = mb_substr($this->resourceCode, 0, $end, PhpInterface::ENCODING_UTF8);
462
    }
463
464
    /**
465
     * Sets the source middle code
466
     *
467
     * @param string $till
468
     */
469
    protected function setAfterProps($till = NULL): void
470
    {
471
        $start = $this->setTabs() . mb_strpos($this->resourceCode, DefaultInterface::PROPS_END, NULL,
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->setTabs() targeting SoliDry\Blocks\ContentManager::setTabs() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
Are you sure $this->setTabs() of type void can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

471
        $start = /** @scrutinizer ignore-type */ $this->setTabs() . mb_strpos($this->resourceCode, DefaultInterface::PROPS_END, NULL,
Loading history...
472
                PhpInterface::ENCODING_UTF8) - 3;
473
        if ($till === NULL) {
474
            $this->sourceCode .= mb_substr($this->resourceCode, $start, NULL, PhpInterface::ENCODING_UTF8);
475
        } else {
476
            $end = mb_strpos($this->resourceCode, $till, NULL, PhpInterface::ENCODING_UTF8) - 3;
477
            $this->sourceCode .= mb_substr($this->resourceCode, $start, $end - $start, PhpInterface::ENCODING_UTF8);
478
        }
479
    }
480
481
    /**
482
     *  Sets the source tail
483
     */
484
    private function setAfterMethods(): void
485
    {
486
        $start = mb_strpos($this->resourceCode, DefaultInterface::METHOD_END, NULL, PhpInterface::ENCODING_UTF8) - 3;
487
        $this->sourceCode .= $this->setTabs() . mb_substr($this->resourceCode, $start, NULL,
0 ignored issues
show
Bug introduced by
Are you sure $this->setTabs() of type void can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

487
        $this->sourceCode .= /** @scrutinizer ignore-type */ $this->setTabs() . mb_substr($this->resourceCode, $start, NULL,
Loading history...
Bug introduced by
Are you sure the usage of $this->setTabs() targeting SoliDry\Blocks\ContentManager::setTabs() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
488
                PhpInterface::ENCODING_UTF8);
489
    }
490
491
    /**
492
     *
493
     * @param string $object
494
     * @param string $method
495
     * @param array $params
496
     * @param bool $arrayToJson
497
     */
498
    private function methodCallOnObject(string $object, string $method, array $params = [], $arrayToJson = true): void
499
    {
500
        $this->sourceCode .= $this->setTabs(2) . PhpInterface::DOLLAR_SIGN . $object
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->setTabs(2) targeting SoliDry\Blocks\ContentManager::setTabs() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
Are you sure $this->setTabs(2) of type void can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

500
        $this->sourceCode .= /** @scrutinizer ignore-type */ $this->setTabs(2) . PhpInterface::DOLLAR_SIGN . $object
Loading history...
501
            . PhpInterface::ARROW . $method . PhpInterface::OPEN_PARENTHESES
502
            . $this->getMethodParamsToPass($params, $arrayToJson)
503
            . PhpInterface::CLOSE_PARENTHESES . PhpInterface::SEMICOLON . PHP_EOL;
504
    }
505
506
    /**
507
     * Sets n new lines
508
     *
509
     * @param int $numLines
510
     */
511
    protected function setNewLines(int $numLines = 1): void
512
    {
513
        for ($i = $numLines; $i > 0; --$i) {
514
            $this->sourceCode .= PHP_EOL;
515
        }
516
    }
517
}