Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7e657b8

Browse filesBrowse files
committed
feature #20867 [Console] Include application name/version in JSON descriptions (ro0NL)
This PR was merged into the 3.3-dev branch. Discussion ---------- [Console] Include application name/version in JSON descriptions | Q | A | ------------- | --- | Branch? | "master" | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | comma-separated list of tickets fixed by the PR, if any | License | MIT | Doc PR | reference to the documentation PR, if any To be consistent with other formats. Commits ------- a43e040 [Console] Include application name/version in JSON descriptions
2 parents 462a02b + a43e040 commit 7e657b8
Copy full SHA for 7e657b8

File tree

2 files changed

+19
-3
lines changed
Filter options

2 files changed

+19
-3
lines changed

‎src/Symfony/Component/Console/Descriptor/JsonDescriptor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Descriptor/JsonDescriptor.php
+15-3Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,21 @@ protected function describeApplication(Application $application, array $options
7171
$commands[] = $this->getCommandData($command);
7272
}
7373

74-
$data = $describedNamespace
75-
? array('commands' => $commands, 'namespace' => $describedNamespace)
76-
: array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces()));
74+
$data = array();
75+
if ('UNKNOWN' !== $application->getName()) {
76+
$data['application']['name'] = $application->getName();
77+
if ('UNKNOWN' !== $application->getVersion()) {
78+
$data['application']['version'] = $application->getVersion();
79+
}
80+
}
81+
82+
$data['commands'] = $commands;
83+
84+
if ($describedNamespace) {
85+
$data['namespace'] = $describedNamespace;
86+
} else {
87+
$data['namespaces'] = array_values($description->getNamespaces());
88+
}
7789

7890
$this->writeData($data, $options);
7991
}

‎src/Symfony/Component/Console/Tests/Fixtures/application_2.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Fixtures/application_2.json
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
2+
"application": {
3+
"name": "My Symfony application",
4+
"version": "v1.0"
5+
},
26
"commands": [
37
{
48
"name": "help",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.