Consistently throw exceptions on a single line
MODIFY
Data/Bundle/Compiler/GenrbCompiler.php
Data/Bundle/Compiler/GenrbCompiler.php
@@ -37,10 +37,7 @@ class GenrbCompiler implements BundleCompilerInterface
exec('which '.$genrb, $output, $status);
if (0 !== $status) {
- throw new RuntimeException(sprintf(
- 'The command "%s" is not installed',
- $genrb
- ));
+ throw new RuntimeException(sprintf('The command "%s" is not installed', $genrb));
}
$this->genrb = ($envVars ? $envVars.' ' : '').$genrb;
@@ -58,12 +55,7 @@ class GenrbCompiler implements BundleCompilerInterface
exec($this->genrb.' --quiet -e UTF-8 -d '.$targetDir.' '.$sourcePath, $output, $status);
if (0 !== $status) {
- throw new RuntimeException(sprintf(
- 'genrb failed with status %d while compiling %s to %s.',
- $status,
- $sourcePath,
- $targetDir
- ));
+ throw new RuntimeException(sprintf('genrb failed with status %d while compiling %s to %s.', $status, $sourcePath, $targetDir));
}
}
}

MODIFY
Data/Bundle/Reader/IntlBundleReader.php
Data/Bundle/Reader/IntlBundleReader.php
@@ -41,11 +41,7 @@ class IntlBundleReader implements BundleReaderInterface
// The bundle is NULL if the path does not look like a resource bundle
// (i.e. contain a bunch of *.res files)
if (null === $bundle) {
- throw new ResourceBundleNotFoundException(sprintf(
- 'The resource bundle "%s/%s.res" could not be found.',
- $path,
- $locale
- ));
+ throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s/%s.res" could not be found.', $path, $locale));
}
// Other possible errors are U_USING_FALLBACK_WARNING and U_ZERO_ERROR,

MODIFY
Data/Bundle/Reader/JsonBundleReader.php
Data/Bundle/Reader/JsonBundleReader.php
@@ -36,27 +36,17 @@ class JsonBundleReader implements BundleReaderInterface
}
if (!file_exists($fileName)) {
- throw new ResourceBundleNotFoundException(sprintf(
- 'The resource bundle "%s" does not exist.',
- $fileName
- ));
+ throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
}
if (!is_file($fileName)) {
- throw new RuntimeException(sprintf(
- 'The resource bundle "%s" is not a file.',
- $fileName
- ));
+ throw new RuntimeException(sprintf('The resource bundle "%s" is not a file.', $fileName));
}
$data = json_decode(file_get_contents($fileName), true);
if (null === $data) {
- throw new RuntimeException(sprintf(
- 'The resource bundle "%s" contains invalid JSON: %s',
- $fileName,
- json_last_error_msg()
- ));
+ throw new RuntimeException(sprintf('The resource bundle "%s" contains invalid JSON: %s', $fileName, json_last_error_msg()));
}
return $data;

MODIFY
Data/Bundle/Reader/PhpBundleReader.php
Data/Bundle/Reader/PhpBundleReader.php
@@ -36,19 +36,11 @@ class PhpBundleReader implements BundleReaderInterface
}
if (!file_exists($fileName)) {
- throw new ResourceBundleNotFoundException(sprintf(
- 'The resource bundle "%s/%s.php" does not exist.',
- $path,
- $locale
- ));
+ throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s/%s.php" does not exist.', $path, $locale));
}
if (!is_file($fileName)) {
- throw new RuntimeException(sprintf(
- 'The resource bundle "%s/%s.php" is not a file.',
- $path,
- $locale
- ));
+ throw new RuntimeException(sprintf('The resource bundle "%s/%s.php" is not a file.', $path, $locale));
}
return include $fileName;

MODIFY
Data/Generator/LanguageDataGenerator.php
Data/Generator/LanguageDataGenerator.php
@@ -175,32 +175,19 @@ class LanguageDataGenerator extends AbstractDataGenerator
if (isset(self::$preferredAlpha2ToAlpha3Mapping[$language])) {
// Validate to prevent typos
if (!isset($aliases[self::$preferredAlpha2ToAlpha3Mapping[$language]])) {
- throw new RuntimeException(
- 'The statically set three-letter mapping '.
- self::$preferredAlpha2ToAlpha3Mapping[$language].' '.
- 'for the language code '.$language.' seems to be '.
- 'invalid. Typo?'
- );
+ throw new RuntimeException('The statically set three-letter mapping '.self::$preferredAlpha2ToAlpha3Mapping[$language].' for the language code '.$language.' seems to be invalid. Typo?');
}
$alpha3 = self::$preferredAlpha2ToAlpha3Mapping[$language];
$alpha2 = $aliases[$alpha3]['replacement'];
if ($language !== $alpha2) {
- throw new RuntimeException(
- 'The statically set three-letter mapping '.$alpha3.' '.
- 'for the language code '.$language.' seems to be '.
- 'an alias for '.$alpha2.'. Wrong mapping?'
- );
+ throw new RuntimeException('The statically set three-letter mapping '.$alpha3.' for the language code '.$language.' seems to be an alias for '.$alpha2.'. Wrong mapping?');
}
$alpha2ToAlpha3[$language] = $alpha3;
} elseif (isset($alpha2ToAlpha3[$language])) {
- throw new RuntimeException(
- 'Multiple three-letter mappings exist for the language '.
- 'code '.$language.'. Please add one of them to the '.
- 'property $preferredAlpha2ToAlpha3Mapping.'
- );
+ throw new RuntimeException('Multiple three-letter mappings exist for the language code '.$language.'. Please add one of them to the property $preferredAlpha2ToAlpha3Mapping.');
} else {
$alpha2ToAlpha3[$language] = $alias;
}

MODIFY
Data/Util/RecursiveArrayAccess.php
Data/Util/RecursiveArrayAccess.php
@@ -36,10 +36,7 @@ class RecursiveArrayAccess
}
}
- throw new OutOfBoundsException(sprintf(
- 'The index %s does not exist.',
- $index
- ));
+ throw new OutOfBoundsException(sprintf('The index %s does not exist.', $index));
}
return $array;

MODIFY
Data/Util/RingBuffer.php
Data/Util/RingBuffer.php
@@ -53,10 +53,7 @@ class RingBuffer implements \ArrayAccess
public function offsetGet($key)
{
if (!isset($this->indices[$key])) {
- throw new OutOfBoundsException(sprintf(
- 'The index "%s" does not exist.',
- $key
- ));
+ throw new OutOfBoundsException(sprintf('The index "%s" does not exist.', $key));
}
return $this->values[$this->indices[$key]];

MODIFY
DateFormatter/DateFormat/TimeZoneTransformer.php
DateFormatter/DateFormat/TimeZoneTransformer.php
@@ -106,10 +106,7 @@ class TimeZoneTransformer extends Transformer
$signal = '-' == $matches['signal'] ? '+' : '-';
if (0 < $minutes) {
- throw new NotImplementedException(sprintf(
- 'It is not possible to use a GMT time zone with minutes offset different than zero (0). GMT time zone tried: %s.',
- $formattedTimeZone
- ));
+ throw new NotImplementedException(sprintf('It is not possible to use a GMT time zone with minutes offset different than zero (0). GMT time zone tried: %s.', $formattedTimeZone));
}
return 'Etc/GMT'.(0 !== $hours ? $signal.$hours : '');

MODIFY
NumberFormatter/NumberFormatter.php
NumberFormatter/NumberFormatter.php
@@ -360,10 +360,7 @@ class NumberFormatter
}
if (self::CURRENCY == $this->style) {
- throw new NotImplementedException(sprintf(
- '%s() method does not support the formatting of currencies (instance with CURRENCY style). %s',
- __METHOD__, NotImplementedException::INTL_INSTALL_MESSAGE
- ));
+ throw new NotImplementedException(sprintf('%s() method does not support the formatting of currencies (instance with CURRENCY style). %s', __METHOD__, NotImplementedException::INTL_INSTALL_MESSAGE));
}
// Only the default type is supported.

Consistently throw exceptions on a single line