Completed
Push — v0.7 ( 7c9b41...5c4e91 )
by Nate
02:30
created

DefaultWriterContext::serializeNull()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/*
3
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
declare(strict_types=1);
7
8
namespace Tebru\Gson\Internal;
9
10
use Tebru\Gson\Context;
11
use Tebru\Gson\WriterContext;
12
13
/**
14
 * Class JsonReaderContext
15
 *
16
 * Runtime context that can be used during reading
17
 *
18
 * @author Nate Brunette <[email protected]>
19
 */
20
final class DefaultWriterContext extends DefaultContext implements WriterContext
21
{
22
    private $serializeNull;
0 ignored issues
show
introduced by
The private property $serializeNull is not used, and could be removed.
Loading history...
23
24
    /**
25
     * If we should serialize null
26
     *
27
     * @return bool
28
     */
29
    public function serializeNull(): bool
30
    {
31
        return false;
32
    }
33
34
    public function setSerializeNull(): Context
35
    {
36
        // TODO: Implement setSerializeNull() method.
37
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Tebru\Gson\Context. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
38
}
39