1 | <?php |
||
25 | { |
||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $evtName = 'evtInfoContribuinte'; |
||
30 | protected $evtTag = 'evtInfoContri'; |
||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $evtAlias = 'R-1000'; |
||
35 | |||
36 | /** |
||
37 | * Constructor |
||
38 | * @param string $config |
||
39 | * @param stdClass $std |
||
40 | * @param Certificate $certificate |
||
41 | * @param string date |
||
42 | */ |
||
43 | public function __construct( |
||
51 | |||
52 | /** |
||
53 | * Node constructor |
||
54 | */ |
||
55 | protected function toNode() |
||
56 | { |
||
57 | $ideContri = $this->node->getElementsByTagName('ideContri')->item(0); |
||
58 | //o idEvento pode variar de evento para evento |
||
59 | //então cada factory individualmente terá de construir o seu |
||
60 | $ideEvento = $this->dom->createElement("ideEvento"); |
||
61 | $this->dom->addChild( |
||
62 | $ideEvento, |
||
63 | "tpAmb", |
||
64 | $this->tpAmb, |
||
65 | true |
||
66 | ); |
||
67 | $this->dom->addChild( |
||
68 | $ideEvento, |
||
69 | "procEmi", |
||
70 | $this->procEmi, |
||
71 | true |
||
72 | ); |
||
73 | $this->dom->addChild( |
||
74 | $ideEvento, |
||
75 | "verProc", |
||
76 | $this->verProc, |
||
77 | true |
||
78 | ); |
||
79 | $this->node->insertBefore($ideEvento, $ideContri); |
||
80 | //tag deste evento em particular |
||
81 | $infoContri = $this->dom->createElement("infoContri"); |
||
82 | //se aplica a todos os modos |
||
83 | $idePeriodo = $this->dom->createElement("idePeriodo"); |
||
84 | $this->dom->addChild( |
||
85 | $idePeriodo, |
||
86 | "iniValid", |
||
87 | $this->std->inivalid, |
||
88 | true |
||
89 | ); |
||
90 | $this->dom->addChild( |
||
91 | $idePeriodo, |
||
92 | "fimValid", |
||
93 | !empty($this->std->fimvalid) ? $this->std->fimvalid : null, |
||
94 | false |
||
95 | ); |
||
96 | if (!empty($this->std->infocadastro)) { |
||
97 | $cad = $this->std->infocadastro; |
||
98 | $infocadastro = $this->dom->createElement("infoCadastro"); |
||
99 | $this->dom->addChild( |
||
100 | $infocadastro, |
||
101 | "classTrib", |
||
102 | $cad->classtrib, |
||
103 | true |
||
104 | ); |
||
105 | $this->dom->addChild( |
||
106 | $infocadastro, |
||
107 | "indEscrituracao", |
||
108 | $cad->indescrituracao, |
||
109 | true |
||
244 |
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: