@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | private function addGetter(ClassType $dataProvider, array $element, array $configs): void |
| 106 | 106 | { |
| 107 | 107 | $dataProvider->addMethod('get' . $this->formatElementName($element['name'], $configs)) |
| 108 | - ->addComment('@return ' . $element['type']) |
|
| 109 | - ->setVisibility('public') |
|
| 110 | - ->setBody('return $this->' . $element['name'] . ';') |
|
| 111 | - ->setReturnType($this->getTypeHint($element['type'], $element['allownull'])) |
|
| 108 | + ->addComment('@return ' . $element['type']) |
|
| 109 | + ->setVisibility('public') |
|
| 110 | + ->setBody('return $this->' . $element['name'] . ';') |
|
| 111 | + ->setReturnType($this->getTypeHint($element['type'], $element['allownull'])) |
|
| 112 | 112 | ; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | private function addUnsetter(ClassType $dataProvider, array $element, array $configs): void |
| 121 | 121 | { |
| 122 | 122 | $dataProvider->addMethod('unset' . $this->formatElementName($element['name'], $configs)) |
| 123 | - ->addComment('@return ' . $dataProvider->getName()) |
|
| 124 | - ->setVisibility('public') |
|
| 125 | - ->setBody('$this->' . $element['name'] . ' = null;' . PHP_EOL . PHP_EOL . 'return $this;') |
|
| 123 | + ->addComment('@return ' . $dataProvider->getName()) |
|
| 124 | + ->setVisibility('public') |
|
| 125 | + ->setBody('$this->' . $element['name'] . ' = null;' . PHP_EOL . PHP_EOL . 'return $this;') |
|
| 126 | 126 | ; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | private function addHas(ClassType $dataProvider, array $element, array $configs): void |
| 135 | 135 | { |
| 136 | 136 | $dataProvider->addMethod('has' . $this->formatElementName($element['name'], $configs)) |
| 137 | - ->addComment('@return bool') |
|
| 138 | - ->setVisibility('public') |
|
| 139 | - ->setBody( |
|
| 140 | - 'return ($this->' . $element['name'] . ' !== null && $this->' . $element['name'] . ' !== []);' |
|
| 141 | - ) |
|
| 137 | + ->addComment('@return bool') |
|
| 138 | + ->setVisibility('public') |
|
| 139 | + ->setBody( |
|
| 140 | + 'return ($this->' . $element['name'] . ' !== null && $this->' . $element['name'] . ' !== []);' |
|
| 141 | + ) |
|
| 142 | 142 | ; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -150,16 +150,16 @@ discard block |
||
| 150 | 150 | private function addSetter(ClassType $dataProvider, array $element, array $configs): void |
| 151 | 151 | { |
| 152 | 152 | $setter = $dataProvider->addMethod('set' . $this->formatElementName($element['name'], $configs)) |
| 153 | - ->addComment( |
|
| 154 | - '@param ' . $element['type'] . ' $' |
|
| 155 | - . $element['name'] |
|
| 156 | - ) |
|
| 157 | - ->addComment('@return ' . $dataProvider->getName()) |
|
| 158 | - ->setVisibility('public') |
|
| 159 | - ->setBody( |
|
| 160 | - '$this->' . $element['name'] . ' = $' . $element['name'] . ';' . PHP_EOL . PHP_EOL |
|
| 161 | - . 'return $this;' |
|
| 162 | - ) |
|
| 153 | + ->addComment( |
|
| 154 | + '@param ' . $element['type'] . ' $' |
|
| 155 | + . $element['name'] |
|
| 156 | + ) |
|
| 157 | + ->addComment('@return ' . $dataProvider->getName()) |
|
| 158 | + ->setVisibility('public') |
|
| 159 | + ->setBody( |
|
| 160 | + '$this->' . $element['name'] . ' = $' . $element['name'] . ';' . PHP_EOL . PHP_EOL |
|
| 161 | + . 'return $this;' |
|
| 162 | + ) |
|
| 163 | 163 | ; |
| 164 | 164 | |
| 165 | 165 | $param = $setter->addParameter($element['name']) |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | ; |
| 205 | 205 | |
| 206 | 206 | $singleSetter->addParameter($element['singleton']) |
| 207 | - ->setTypeHint($element['singleton_type']) |
|
| 207 | + ->setTypeHint($element['singleton_type']) |
|
| 208 | 208 | ; |
| 209 | 209 | } |
| 210 | 210 | } |
@@ -216,8 +216,8 @@ discard block |
||
| 216 | 216 | private function addProperty(ClassType $dataProvider, array $element): void |
| 217 | 217 | { |
| 218 | 218 | $property = $dataProvider->addProperty($element['name']) |
| 219 | - ->setVisibility('protected') |
|
| 220 | - ->addComment('@var ' . $element['type']) |
|
| 219 | + ->setVisibility('protected') |
|
| 220 | + ->addComment('@var ' . $element['type']) |
|
| 221 | 221 | ; |
| 222 | 222 | |
| 223 | 223 | if ($element['default']) { |
@@ -255,10 +255,10 @@ discard block |
||
| 255 | 255 | private function addElementsGetter(ClassType $dataProvider, array $elements): void |
| 256 | 256 | { |
| 257 | 257 | $dataProvider->addMethod('getElements') |
| 258 | - ->setReturnType('array') |
|
| 259 | - ->setVisibility('protected') |
|
| 260 | - ->addComment('@return array') |
|
| 261 | - ->setBody('return ' . var_export($elements, true) . ';') |
|
| 258 | + ->setReturnType('array') |
|
| 259 | + ->setVisibility('protected') |
|
| 260 | + ->addComment('@return array') |
|
| 261 | + ->setBody('return ' . var_export($elements, true) . ';') |
|
| 262 | 262 | ; |
| 263 | 263 | } |
| 264 | 264 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | foreach ($this->parser->getDataProvider() as $providerName => $providerData) { |
| 64 | 64 | $namespace = new PhpNamespace($this->namespace); |
| 65 | 65 | $dataProvider = $this->createDataProviderClass($providerName, $providerData, $namespace); |
| 66 | - $classContent = (string)$namespace; |
|
| 66 | + $classContent = (string) $namespace; |
|
| 67 | 67 | $classContent = str_replace('\?', '?', $classContent); |
| 68 | 68 | $classContent = Helpers::tabsToSpaces($classContent, 4); |
| 69 | 69 | $this->fileWriter->writeToFile($dataProvider->getName() . '.php', $classContent); |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | { |
| 352 | 352 | return preg_replace_callback( |
| 353 | 353 | '@\_([a-z]{1,1})@', |
| 354 | - function ($matches) { |
|
| 354 | + function($matches) { |
|
| 355 | 355 | return strtoupper($matches[1] ?? ''); |
| 356 | 356 | }, |
| 357 | 357 | $methodName |
@@ -209,7 +209,7 @@ |
||
| 209 | 209 | { |
| 210 | 210 | return preg_replace_callback( |
| 211 | 211 | '@\_([a-z]{1,1})@', |
| 212 | - function ($matches) { |
|
| 212 | + function($matches) { |
|
| 213 | 213 | return strtoupper($matches[1] ?? ''); |
| 214 | 214 | }, |
| 215 | 215 | $methodName |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $dataProvider = $this->parseDataProvider($xmlDataProvider); |
| 38 | 38 | |
| 39 | 39 | foreach ($xmlDataProvider->DataElement as $element) { |
| 40 | - $fieldName = (string)$element->attributes()['name']; |
|
| 40 | + $fieldName = (string) $element->attributes()['name']; |
|
| 41 | 41 | |
| 42 | 42 | if (isset($this->mergedXml[$dataProvider]['elements'][$fieldName])) { |
| 43 | 43 | $this->mergedXml[$dataProvider]['elements'][$fieldName] = array_merge( |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | private function parseDataProvider(\SimpleXMLElement $xmlDataProvider): string |
| 71 | 71 | { |
| 72 | - $dataProvider = (string)$xmlDataProvider->attributes()['name']; |
|
| 72 | + $dataProvider = (string) $xmlDataProvider->attributes()['name']; |
|
| 73 | 73 | if (!isset($this->mergedXml[$dataProvider])) { |
| 74 | 74 | $this->mergedXml[$dataProvider] = [ |
| 75 | 75 | 'configs' => [ |
| 76 | - 'convertUnderlines' => (bool)$xmlDataProvider->attributes()['ConvertUnderlines'] ?? false, |
|
| 77 | - 'deprecated' => (bool)$xmlDataProvider->attributes()['deprecated'] ?? false |
|
| 76 | + 'convertUnderlines' => (bool) $xmlDataProvider->attributes()['ConvertUnderlines'] ?? false, |
|
| 77 | + 'deprecated' => (bool) $xmlDataProvider->attributes()['deprecated'] ?? false |
|
| 78 | 78 | ], |
| 79 | 79 | 'elements' => [] |
| 80 | 80 | ]; |
@@ -90,12 +90,12 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | private function getElementData(\SimpleXMLElement $element, array $dataProvider): array |
| 92 | 92 | { |
| 93 | - $type = (string)$element->attributes()['type']; |
|
| 93 | + $type = (string) $element->attributes()['type']; |
|
| 94 | 94 | |
| 95 | 95 | $type = ($type !== 'double') ? $type : 'float'; |
| 96 | 96 | |
| 97 | - $allowNull = (bool)$element->attributes()['allownull']; |
|
| 98 | - $default = (string)$element->attributes()['default']; |
|
| 97 | + $allowNull = (bool) $element->attributes()['allownull']; |
|
| 98 | + $default = (string) $element->attributes()['default']; |
|
| 99 | 99 | |
| 100 | 100 | if ($type === 'object') { |
| 101 | 101 | $allowNull = true; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $data = [ |
| 106 | - 'name' => (string)$element->attributes()['name'], |
|
| 106 | + 'name' => (string) $element->attributes()['name'], |
|
| 107 | 107 | 'allownull' => $allowNull, |
| 108 | 108 | 'default' => $default, |
| 109 | 109 | 'type' => $this->getVariableType($type), |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | 'isCamelCase' => $dataProvider['configs']['convertUnderlines'] |
| 113 | 113 | ]; |
| 114 | 114 | |
| 115 | - $singleton = (string)$element->attributes()['singleton']; |
|
| 115 | + $singleton = (string) $element->attributes()['singleton']; |
|
| 116 | 116 | if ($singleton !== '') { |
| 117 | - $data['singleton'] = (string)$element->attributes()['singleton']; |
|
| 117 | + $data['singleton'] = (string) $element->attributes()['singleton']; |
|
| 118 | 118 | $data['singleton_type'] = $this->getSingleVariableType($type); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | { |
| 175 | 175 | if (!$this->isSimpleType($type)) { |
| 176 | 176 | $namespace = ltrim($this->namespace, '\\'); |
| 177 | - $type = '\\' . $namespace .'\\' . $type . 'DataProvider'; |
|
| 177 | + $type = '\\' . $namespace . '\\' . $type . 'DataProvider'; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | if ($type === 'DataProviderInterface') { |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | { |
| 202 | 202 | if (!$this->isSimpleType($type)) { |
| 203 | 203 | $namespace = ltrim($this->namespace, '\\'); |
| 204 | - $type = '\\' . $namespace .'\\' . $type . 'DataProvider'; |
|
| 204 | + $type = '\\' . $namespace . '\\' . $type . 'DataProvider'; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | if ($type === 'DataProviderInterface') { |