-
Notifications
You must be signed in to change notification settings - Fork 3
Fix tests for the Translation component #27
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
use Symfony\Component\HttpKernel\DataCollector\DataCollector; | ||
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; | ||
use Symfony\Component\Translation\DataCollectorTranslator; | ||
use Symfony\Component\VarDumper\Cloner\Data; | ||
|
||
/** | ||
* @author Abdellatif Ait boudad <[email protected]> | ||
|
@@ -60,11 +61,11 @@ public function reset() | |
} | ||
|
||
/** | ||
* @return array | ||
* @return Data | ||
*/ | ||
public function getMessages() | ||
{ | ||
return isset($this->data['messages']) ? $this->data['messages'] : []; | ||
return isset($this->data['messages']) ? $this->data['messages'] : new Data([]); | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,13 +21,13 @@ | |
abstract class AbstractFileExtractor | ||
{ | ||
/** | ||
* @param string|array $resource Files, a file or a directory | ||
* @param string|iterable $resource Files, a file or a directory | ||
* | ||
* @return array | ||
* @return iterable | ||
*/ | ||
protected function extractFiles($resource) | ||
{ | ||
if (\is_array($resource) || $resource instanceof \Traversable) { | ||
if (\is_iterable($resource)) { | ||
$files = []; | ||
foreach ($resource as $file) { | ||
if ($this->canBeExtracted($file)) { | ||
|
@@ -74,7 +74,7 @@ abstract protected function canBeExtracted($file); | |
/** | ||
* @param string|array $resource Files, a file or a directory | ||
* | ||
* @return array files to be extracted | ||
* @return iterable files to be extracted | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both implementations return a |
||
*/ | ||
abstract protected function extractFromDirectory($resource); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,11 +40,15 @@ protected function loadResource($resource) | |
} | ||
|
||
try { | ||
$messages = $this->yamlParser->parseFile($resource, Yaml::PARSE_CONSTANT); | ||
$messages = $this->yamlParser->parseFile($resource, Yaml::PARSE_CONSTANT) ?? []; | ||
} catch (ParseException $e) { | ||
throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s"', $resource), 0, $e); | ||
} | ||
|
||
if (!\is_array($messages)) { | ||
throw new InvalidResourceException(sprintf('Unable to load file "%s".', $resource)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
return $messages; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might change an
if (message)
in the twig template, can you please confirm this doesn't break anything?otherwise I'm good with array|Data - other collector do it I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.