Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop php notice when name key is undefined #21

Merged
merged 1 commit into from
Dec 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/yaml-lint.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
$componentsManifest = __DIR__ . $pathToTry . 'composer/installed.json';
$components = json_decode(file_get_contents($componentsManifest), true);
foreach ($components as $component) {
if ($component['name'] == 'symfony/yaml') {
if (isset($component['name']) && $component['name'] == 'symfony/yaml') {
$appStr .= ', symfony/yaml ' . $component['version'];
break;
}
Expand Down Expand Up @@ -82,7 +82,7 @@
if (count($argPaths) < 1) {
throw new UsageException('no input specified', EXIT_ERROR);
}

$lintPath = function($path) use ($argQuiet, $appStr) {
$content = file_get_contents($path);
if (strlen($content) < 1) {
Expand Down Expand Up @@ -112,11 +112,11 @@
fwrite(STDOUT, trim($appStr . ': parsing ' . $path));
fwrite(STDOUT, sprintf(" [ %s ]\n", _ansify('OK', ANSI_GRN)));
}
};
};

if ($argPaths[0] === '-') {
$path = 'php://stdin';

$lintPath($path);
} else {
// Check input file(s)
Expand All @@ -127,7 +127,7 @@
if (!is_readable($argPath)) {
throw new ParseException(sprintf('File %s is not readable', $argPath));
}

$lintPath($argPath);
}
}
Expand Down