8000 Tweak the code to avoid fabbot false positives · symfony/symfony@ad6f75e · GitHub
[go: up one dir, main page]

Skip to content

Commit ad6f75e

Browse files
committed
Tweak the code to avoid fabbot false positives
1 parent a21c112 commit ad6f75e

File tree

24 files changed

+42
-42
lines changed

24 files changed

+42
-42
lines changed

src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function destroy($sessionId)
9696
$stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
9797
$stmt->execute();
9898
} catch (\Exception $e) {
99-
throw new \RuntimeException(sprintf('Exception was thrown when trying to delete a session: %s.', $e->getMessage()), 0, $e);
99+
throw new \RuntimeException('Exception was thrown when trying to delete a session: '.$e->getMessage(), 0, $e);
100100
}
101101

102102
return true;
@@ -115,7 +115,7 @@ public function gc($maxlifetime)
115115
$stmt->bindValue(':time', time() - $maxlifetime, \PDO::PARAM_INT);
116116
$stmt->execute();
117117
} catch (\Exception $e) {
118-
throw new \RuntimeException(sprintf('Exception was thrown when trying to delete expired sessions: %s.', $e->getMessage()), 0, $e);
118+
throw new \RuntimeException('Exception was thrown when trying to delete expired sessions: '.$e->getMessage(), 0, $e);
119119
}
120120

121121
return true;
@@ -142,7 +142,7 @@ public function read($sessionId)
142142

143143
return '';
144144
} catch (\Exception $e) {
145-
throw new \RuntimeException(sprintf('Exception was thrown when trying to read the session data: %s.', $e->getMessage()), 0, $e);
145+
throw new \RuntimeException('Exception was thrown when trying to read the session data: '.$e->getMessage(), 0, $e);
146146
}
147147
}
148148

@@ -212,7 +212,7 @@ public function write($sessionId, $data)
212212
}
213213
}
214214
} catch (\Exception $e) {
215-
throw new \RuntimeException(sprintf('Exception was thrown when trying to write the session data: %s.', $e->getMessage()), 0, $e);
215+
throw new \RuntimeException('Exception was thrown when trying to write the session data: '.$e->getMessage(), 0, $e);
216216
}
217217

218218
return true;

src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function refreshUser(UserInterface $user)
9292

9393
$refreshedUser = $repository->find($id);
9494
if (null === $refreshedUser) {
95-
throw new UsernameNotFoundException(sprintf('User with id %s not found.', json_encode($id)));
95+
throw new UsernameNotFoundException('User with id '.json_encode($id).' not found.'));
9696
}
9797
}
9898

src/Symfony/Bundle/WebServerBundle/Command/ServerLogCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9999
}
100100

101101
if (!$socket = stream_socket_server($host, $errno, $errstr)) {
102-
throw new RuntimeException(sprintf('Server start failed on "%s": %s %s.', $host, $errstr, $errno));
102+
throw new RuntimeException(sprintf('Server start failed on "%s": '.$errstr.' '.$errno, $host));
103103
}
104104

105105
foreach ($this->getLogs($socket) as $clientId => $message) {

src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private function getManifestPath($path)
5959

6060
$this->manifestData = json_decode(file_get_contents($this->manifestPath), true);
6161
if (0 < json_last_error()) {
62-
throw new \RuntimeException(sprintf('Error parsing JSON from asset manifest file "%s" - %s.', $this->manifestPath, json_last_error_msg()));
62+
throw new \RuntimeException(sprintf('Error parsing JSON from asset manifest file "%s": '.json_last_error_msg(), $this->manifestPath));
6363
}
6464
}
6565

src/Symfony/Component/Cache/Traits/MemcachedTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ private function checkResultCode($result)
272272
return $result;
273273
}
274274

275-
throw new CacheException(sprintf('MemcachedAdapter client error: %s.', strtolower($this->client->getResultMessage())));
275+
throw new CacheException('MemcachedAdapter client error: '.strtolower($this->client->getResultMessage()));
276276
}
277277

278278
/**

src/Symfony/Component/Config/Definition/BaseNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ final public function finalize($value)
335335
} catch (Exception $e) {
336336
throw $e;
337337
} catch (\Exception $e) {
338-
throw new InvalidConfigurationException(sprintf('Invalid configuration for path "%s": %s.', $this->getPath(), $e->getMessage()), $e->getCode(), $e);
338+
throw new InvalidConfigurationException(sprintf('Invalid configuration for path "%s": '.$e->getMessage(), $this->getPath()), $e->getCode(), $e);
339339
}
340340
}
341341

src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected function getConstructor(Definition $definition, $required)
126126
throw new RuntimeException(sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
127127
}
128128
} catch (\ReflectionException $e) {
129-
throw new RuntimeException(sprintf('Invalid service "%s": %s.', $this->currentId, lcfirst(rtrim($e->getMessage(), '.'))));
129+
throw new RuntimeException(sprintf('Invalid service "%s": '.lcfirst($e->getMessage()), $this->currentId));
130130
}
131131
if (!$r = $r->getConstructor()) {
132132
if ($required) {

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ protected function loadFile($file)
660660
try {
661661
$configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
662662
} catch (ParseException $e) {
663-
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: %s.', $file, $e->getMessage()), 0, $e);
663+
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: '.$e->getMessage(), $file), 0, $e);
664664
} finally {
665665
restore_error_handler();
666666
}

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function mkdir($dirs, $mode = 0777)
101101
if (!is_dir($dir)) {
102102
// The directory was not created by a concurrent process. Let's throw an exception with a developer friendly error message if we have one
103103
if (self::$lastError) {
104-
throw new IOException(sprintf('Failed to create "%s": %s.', $dir, self::$lastError), 0, null, $dir);
104+
throw new IOException(sprintf('Failed to create "%s": '.self::$lastError, $dir), 0, null, $dir);
105105
}
106106
throw new IOException(sprintf('Failed to create "%s".', $dir), 0, null, $dir);
107107
}
@@ -171,16 +171,16 @@ public function remove($files)
171171
if (is_link($file)) {
172172
// See https://bugs.php.net/52176
173173
if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && file_exists($file)) {
174-
throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, self::$lastError));
174+
throw new IOException(sprintf('Failed to remove symlink "%s": '.self::$lastError, $file));
175175
}
176176
} elseif (is_dir($file)) {
177177
$this->remove(new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS));
178178

179179
if (!self::box('rmdir', $file) && file_exists($file)) {
180-
throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, self::$lastError));
180+
throw new IOException(sprintf('Failed to remove directory "%s": '.self::$lastError, $file));
181181
}
182182
} elseif (!self::box('unlink', $file) && file_exists($file)) {
183-
throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, self::$lastError));
183+
throw new IOException(sprintf('Failed to remove file "%s": '.self::$lastError, $file));
184184
}
185185
}
186186
}

src/Symfony/Component/Form/Form.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ private function modelToNorm($value)
10311031
$value = $transformer->transform($value);
10321032
}
10331033
} catch (TransformationFailedException $exception) {
1034-
throw new TransformationFailedException(sprintf('Unable to transform data for property path "%s": %s', $this->getPropertyPath(), $exception->getMessage()), $exception->getCode(), $exception);
1034+
throw new TransformationFailedException(sprintf('Unable to transform data for property path "%s": '.$exception->getMessage(), $this->getPropertyPath()), $exception->getCode(), $exception);
10351035
}
10361036

10371037
return $value;
@@ -1055,7 +1055,7 @@ private function normToModel($value)
10551055
$value = $transformers[$i]->reverseTransform($value);
10561056
}
10571057
} catch (TransformationFailedException $exception) {
1058-
throw new TransformationFailedException(sprintf('Unable to reverse value for property path "%s": %s', $this->getPropertyPath(), $exception->getMessage()), $exception->getCode(), $exception);
1058+
throw new TransformationFailedException(sprintf('Unable to reverse value for property path "%s": '.$exception->getMessage(), $this->getPropertyPath()), $exception->getCode(), $exception);
10591059
}
10601060

10611061
return $value;
@@ -1086,7 +1086,7 @@ private function normToView($value)
10861086
$value = $transformer->transform($value);
10871087
}
10881088
} catch (TransformationFailedException $exception) {
1089-
throw new TransformationFailedException(sprintf('Unable to transform value for property path "%s": %s', $this->getPropertyPath(), $exception->getMessage()), $exception->getCode(), $exception);
1089+
throw new TransformationFailedException(sprintf('Unable to transform value for property path "%s": '.$exception->getMessage(), $this->getPropertyPath()), $exception->getCode(), $exception);
10901090
}
10911091

10921092
return $value;
@@ -1112,7 +1112,7 @@ private function viewToNorm($value)
11121112
$value = $transformers[$i]->reverseTransform($value);
11131113
}
11141114
} catch (TransformationFailedException $exception) {
1115-
throw new TransformationFailedException(sprintf('Unable to reverse value for property path "%s": %s', $this->getPropertyPath(), $ 10000 exception->getMessage()), $exception->getCode(), $exception);
1115+
throw new TransformationFailedException(sprintf('Unable to reverse value for property path "%s": '.$exception->getMessage(), $this->getPropertyPath()), $exception->getCode(), $exception);
11161116
}
11171117

11181118
return $value;

src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function getController(Request $request)
8888
try {
8989
$callable = $this->createController($controller);
9090
} catch (\InvalidArgumentException $e) {
91-
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s.', $request->getPathInfo(), $e->getMessage()), 0, $e);
91+
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: '.$e->getMessage(), $request->getPathInfo()), 0, $e);
9292
}
9393

9494
return $callable;

src/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function read($path, $locale)
4646
$data = json_decode(file_get_contents($fileName), true);
4747

4848
if (null === $data) {
49-
throw new RuntimeException(sprintf('The resource bundle "%s" contains invalid JSON: %s.', $fileName, json_last_error_msg()));
49+
throw new RuntimeException(sprintf('The resource bundle "%s" contains invalid JSON: '.json_last_error_msg(), $fileName));
5050
}
5151

5252
return $data;

src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function count()
4848
return $count;
4949
}
5050

51-
throw new LdapException(sprintf('Error while retrieving entry count: %s.', ldap_error($this->connection->getResource())));
51+
throw new LdapException('Error while retrieving entry count: '.ldap_error($this->connection->getResource()));
5252
}
5353

5454
public function getIterator()
@@ -62,7 +62,7 @@ public function getIterator()
6262
}
6363

6464
if (false === $current) {
65-
throw new LdapException(sprintf('Could not rewind entries array: %s.', ldap_error($con)));
65+
throw new LdapException('Could not rewind entries array: '.ldap_error($con));
6666
}
6767

6868
yield $this->getSingleEntry($con, $current);
@@ -105,15 +105,15 @@ private function getSingleEntry($con, $current)
105105
$attributes = ldap_get_attributes($con, $current);
106106

107107
if (false === $attributes) {
108-
throw new LdapException(sprintf('Could not fetch attributes: %s.', ldap_error($con)));
108+
throw new LdapException('Could not fetch attributes: '.ldap_error($con));
109109
}
110110

111111
$attributes = $this->cleanupAttributes($attributes);
112112

113113
$dn = ldap_get_dn($con, $current);
114114

115115
if (false === $dn) {
116-
throw new LdapException(sprintf('Could not fetch DN: %s.', ldap_error($con)));
116+
throw new LdapException('Could not fetch DN: '.ldap_error($con));
117117
}
118118

119119
return new Entry($dn, $attributes);

src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ private function connect()
138138
}
139139

140140
if (false === $this->connection) {
141-
throw new LdapException(sprintf('Could not connect to Ldap server: %s.', ldap_error($this->connection)));
141+
throw new LdapException('Could not connect to Ldap server: '.ldap_error($this->connection));
142142
}
143143

144144
if ('tls' === $this->config['encryption'] && false === @ldap_start_tls($this->connection)) {
145-
throw new LdapException(sprintf('Could not initiate TLS connection: %s.', ldap_error($this->connection)));
145+
throw new LdapException('Could not initiate TLS connection: '.ldap_error($this->connection));
146146
}
147147
}
148148

src/Symfony/Component/Ldap/Adapter/ExtLdap/EntryManager.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function add(Entry $entry)
3838
$con = $this->getConnectionResource();
3939

4040
if (!@ldap_add($con, $entry->getDn(), $entry->getAttributes())) {
41-
throw new LdapException(sprintf('Could not add entry "%s": %s.', $entry->getDn(), ldap_error($con)));
41+
throw new LdapException(sprintf('Could not add entry "%s": '.ldap_error($con), $entry->getDn()));
4242
}
4343

4444
return $this;
@@ -52,7 +52,7 @@ public function update(Entry $entry)
5252
$con = $this->getConnectionResource();
5353

5454
if (!@ldap_modify($con, $entry->getDn(), $entry->getAttributes())) {
55-
throw new LdapException(sprintf('Could not update entry "%s": %s.', $entry->getDn(), ldap_error($con)));
55+
throw new LdapException(sprintf('Could not update entry "%s": '.ldap_error($con), $entry->getDn()));
5656
}
5757
}
5858

@@ -64,7 +64,7 @@ public function remove(Entry $entry)
6464
$con = $this->getConnectionResource();
6565

6666
if (!@ldap_delete($con, $entry->getDn())) {
67-
throw new LdapException(sprintf('Could not remove entry "%s": %s.', $entry->getDn(), ldap_error($con)));
67+
throw new LdapException(sprintf('Could not remove entry "%s": '.ldap_error($con), $entry->getDn()));
6868
}
6969
}
7070

@@ -76,7 +76,7 @@ public function rename(Entry $entry, $newRdn, $removeOldRdn = true)
7676
$con = $this->getConnectionResource();
7777

7878
if (!@ldap_rename($con, $entry->getDn(), $newRdn, null, $removeOldRdn)) {
79-
throw new LdapException(sprintf('Could not rename entry "%s" to "%s": %s.', $entry->getDn(), $newRdn, ldap_error($con)));
79+
throw new LdapException(sprintf('Could not rename entry "%s" to "%s": '.ldap_error($con), $entry->getDn(), $newRdn));
8080
}
8181
}
8282

src/Symfony/Component/Ldap/Adapter/ExtLdap/Qu F41A ery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __destruct()
4545
$this->search = null;
4646

4747
if (!$success) {
48-
throw new LdapException(sprintf('Could not free results: %s.', ldap_error($con)));
48+
throw new LdapException('Could not free results: '.ldap_error($con));
4949
}
5050
}
5151

src/Symfony/Component/Process/Pipes/WindowsPipes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function __construct($input, $haveReadSupport)
5757

5858
if (!$h = fopen($file.'.lock', 'w')) {
5959
restore_error_handler();
60-
throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s.', $lastError));
60+
throw new RuntimeException('A temporary file could not be opened to write the process output: '.$lastError);
6161
}
6262
if (!flock($h, LOCK_EX | LOCK_NB)) {
6363
continue 2;

src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ private function createEncoder(array $config)
7171
$config = $this->getEncoderConfigFromAlgorithm($config);
7272
}
7373
if (!isset($config['class'])) {
74-
throw new \InvalidArgumentException(sprintf('"class" must be set in %s.', json_encode($config)));
74+
throw new \InvalidArgumentException('"class" must be set in '.json_encode($config));
7575
}
7676
if (!isset($config['arguments'])) {
77-
throw new \InvalidArgumentException(sprintf('"arguments" must be set in %s.', json_encode($config)));
77+
throw new \InvalidArgumentException('"arguments" must be set in '.json_encode($config));
7878
}
7979

8080
$reflection = new \ReflectionClass($config['class']);

src/Symfony/Component/Serializer/Encoder/XmlEncoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ private function buildXml(\DOMNode $parentNode, $data, $xmlRootNodeName = null)
431431
return $this->appendNode($parentNode, $data, 'data');
432432
}
433433

434-
throw new NotEncodableValueException(sprintf('An unexpected value could not be serialized: %s.', !\is_resource($data) ? var_export($data, true) : sprintf('%s resource', get_resource_type($data))));
434+
throw new NotEncodableValueException('An unexpected value could not be serialized: '.(!\is_resource($data) ? var_export($data, true) : sprintf('%s resource', get_resource_type($data))));
435435
}
436436

437437
/**

src/Symfony/Component/Serializer/Serializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function normalize($data, $format = null, array $context = [])
164164
throw new NotNormalizableValueException(sprintf('Could not normalize object of type "%s", no supporting normalizer found.', \get_class($data)));
165165
}
166166

167-
throw new NotNormalizableValueException(sprintf('An unexpected value could not be normalized: %s.', !\is_resource($data) ? var_export($data, true) : sprintf('%s resource', get_resource_type($data))));
167+
throw new NotNormalizableValueException('An unexpected value could not be normalized: '.(!\is_resource($data) ? var_export($data, true) : sprintf('%s resource', get_resource_type($data))));
168168
}
169169

170170
/**

src/Symfony/Component/Translation/Loader/JsonFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function loadResource($resource)
3030
$messages = json_decode($data, true);
3131

3232
if (0 < $errorCode = json_last_error()) {
33-
throw new InvalidResourceException(sprintf('Error parsing JSON - %s.', $this->getJSONErrorMessage($errorCode)));
33+
throw new InvalidResourceException('Error parsing JSON: '.$this->getJSONErrorMessage($errorCode));
3434
}
3535
}
3636

src/Symfony/Component/Translation/Loader/XliffFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private function extract($resource, MessageCatalogue $catalogue, $domain)
5353
try {
5454
$dom = XmlUtils::loadFile($resource);
5555
} catch (\InvalidArgumentException $e) {
56-
throw new InvalidResourceException(sprintf('Unable to load "%s": %s.', $resource, $e->getMessage()), $e->getCode(), $e);
56+
throw new InvalidResourceException(sprintf('Unable to load "%s": '.$e->getMessage(), $resource), $e->getCode(), $e);
5757
}
5858

5959
$xliffVersion = $this->getVersionNumber($dom);
@@ -194,7 +194,7 @@ private function validateSchema($file, \DOMDocument $dom, $schema)
194194
if (!@$dom->schemaValidateSource($schema)) {
195195
libxml_disable_entity_loader($disableEntities);
196196

197-
throw new InvalidResourceException(sprintf('Invalid resource provided: "%s"; Errors: %s.', $file, implode("\n", $this->getXmlErrors($internalErrors))));
197+
throw new InvalidResourceException(sprintf('Invalid resource provided: "%s"; Errors: '.implode("\n", $this->getXmlErrors($internalErrors)), $file));
198198
}
199199

200200
libxml_disable_entity_loader($disableEntities);

src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function validate($value, Constraint $constraint)
5555
try {
5656
$comparedValue = $this->getPropertyAccessor()->getValue($object, $path);
5757
} catch (NoSuchPropertyException $e) {
58-
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: %s.', $path, \get_class($constraint), $e->getMessage()), 0, $e);
58+
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: '.$e->getMessage(), $path, \get_class($constraint)), 0, $e);
5959
}
6060
} else {
6161
$comparedValue = $constraint->value;

0 commit comments

Comments
 (0)
0