Skip to content
This repository was archived by the owner on Apr 30, 2022. It is now read-only.

Commit 176cf60

Browse files
committed
Pass options to doc generation.
1 parent 85c3bda commit 176cf60

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/LinusShops/MagicDoc/Generate.php

+17-7
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
6060
$mapping['source']['path'],
6161
$mapping['destination'],
6262
isset($mapping['types']) ? $mapping['types'] : array(),
63-
isset($mapping['parameters']) ? $mapping['parameters'] : array()
63+
isset($mapping['parameters']) ? $mapping['parameters'] : array(),
64+
isset($mapping['options']) ? $mapping['options']: array()
6465
);
6566
break;
6667
case 'url':
@@ -78,7 +79,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
7879
$mapping['source'],
7980
$mapping['destination'],
8081
isset($mapping['types']) ? $mapping['types'] : array(),
81-
isset($mapping['parameters']) ? $mapping['parameters'] : array()
82+
isset($mapping['parameters']) ? $mapping['parameters'] : array(),
83+
isset($mapping['options']) ? $mapping['options']: array()
8284
);
8385
}
8486
}
@@ -105,23 +107,23 @@ private function processUrlMapping($source, $destination, $types = array(), $par
105107

106108
$this->writeDoc(
107109
$destination,
108-
$this->generateDoc($decoded, $types, $parameters)
110+
$this->generateDoc($decoded, $types, $parameters, $options)
109111
);
110112
}
111113

112-
private function processFileMapping($source, $destination, $types = array(), $parameters = array())
114+
private function processFileMapping($source, $destination, $types = array(), $parameters = array(), $options = array())
113115
{
114116
$json = file_get_contents($source);
115117

116118
$decoded = json_decode($json, true);
117119

118120
$this->writeDoc(
119121
$destination,
120-
$this->generateDoc($decoded, $types, $parameters)
122+
$this->generateDoc($decoded, $types, $parameters, $options)
121123
);
122124
}
123125

124-
private function generateDoc($decodedJsonData, $types, $parameters)
126+
private function generateDoc($decodedJsonData, $types, $parameters, $options = array())
125127
{
126128
$docblock = "";
127129
foreach ($decodedJsonData as $key=>$value) {
@@ -135,7 +137,15 @@ private function generateDoc($decodedJsonData, $types, $parameters)
135137
}
136138

137139
if (!isset($parameters[$key])) {
138-
$params = "...\$parameters";
140+
//Arrays are always descendable
141+
if($type == 'array') {
142+
$params = "...\$parameters";
143+
}
144+
else if (isset($options['parameter_default'])) {
145+
$params = $options['parameter_default'];
146+
} else {
147+
$params = "...\$parameters";
148+
}
139149
} else {
140150
$params = $parameters[$key];
141151
}

0 commit comments

Comments
 (0)