Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Validator] Fix init of YamlFileLoader::$classes for empty files#20828

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,13 +46,7 @@ public function loadClassMetadata(ClassMetadata $metadata)
$this->yamlParser = new YamlParser();
}

// This method may throw an exception. Do not modify the class'
// state before it completes
if (false === ($classes = $this->parseFile($this->file))) {
return false;
}

$this->classes = $classes;
$this->classes = $this->parseFile($this->file);

if (isset($this->classes['namespaces'])) {
foreach ($this->classes['namespaces'] as $alias => $namespace) {
Expand DownExpand Up@@ -111,7 +105,7 @@ protected function parseNodes(array $nodes)
*
* @param string $path The path of the YAML file
*
* @return array|null The class descriptions or null, if the file was empty
* @return array The class descriptions
*
* @throws \InvalidArgumentException If the file could not be loaded or did
* not contain a YAML array
Expand All@@ -126,7 +120,7 @@ private function parseFile($path)

// empty file
if (null === $classes) {
return;
return array();
}

// not an array
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,6 +31,10 @@ public function testLoadClassMetadataReturnsFalseIfEmpty()
$metadata = new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity');

$this->assertFalse($loader->loadClassMetadata($metadata));

$r = new \ReflectionProperty($loader, 'classes');
$r->setAccessible(true);
$this->assertSame(array(), $r->getValue($loader));
}

/**
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp