Skip to content

Commit

Permalink
Enable "native_constant_invocation" CS rule
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Sep 2, 2020
1 parent 702ee65 commit 82fe363
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions AbstractUriElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getUri()
$uri = trim($this->getRawUri());

// absolute URL?
if (null !== parse_url($uri, PHP_URL_SCHEME)) {
if (null !== parse_url($uri, \PHP_URL_SCHEME)) {
return $uri;
}

Expand Down Expand Up @@ -114,7 +114,7 @@ public function getUri()
}

// relative path
$path = parse_url(substr($this->currentUri, \strlen($baseUri)), PHP_URL_PATH);
$path = parse_url(substr($this->currentUri, \strlen($baseUri)), \PHP_URL_PATH);
$path = $this->canonicalizePath(substr($path, 0, strrpos($path, '/')).'/'.$uri);

return $baseUri.('' === $path || '/' !== $path[0] ? '/' : '').$path;
Expand Down
12 changes: 6 additions & 6 deletions Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function addContent($content, $type = null)
public function addHtmlContent($content, $charset = 'UTF-8')
{
$internalErrors = libxml_use_internal_errors(true);
if (LIBXML_VERSION < 20900) {
if (\LIBXML_VERSION < 20900) {
$disableEntities = libxml_disable_entity_loader(true);
}

Expand All @@ -205,7 +205,7 @@ public function addHtmlContent($content, $charset = 'UTF-8')
}

libxml_use_internal_errors($internalErrors);
if (LIBXML_VERSION < 20900) {
if (\LIBXML_VERSION < 20900) {
libxml_disable_entity_loader($disableEntities);
}

Expand Down Expand Up @@ -242,15 +242,15 @@ public function addHtmlContent($content, $charset = 'UTF-8')
* LIBXML_PARSEHUGE is dangerous, see
* http://symfony.com/blog/security-release-symfony-2-0-17-released
*/
public function addXmlContent($content, $charset = 'UTF-8', $options = LIBXML_NONET)
public function addXmlContent($content, $charset = 'UTF-8', $options = \LIBXML_NONET)
{
// remove the default namespace if it's the only namespace to make XPath expressions simpler
if (!preg_match('/xmlns:/', $content)) {
$content = str_replace('xmlns', 'ns', $content);
}

$internalErrors = libxml_use_internal_errors(true);
if (LIBXML_VERSION < 20900) {
if (\LIBXML_VERSION < 20900) {
$disableEntities = libxml_disable_entity_loader(true);
}

Expand All @@ -262,7 +262,7 @@ public function addXmlContent($content, $charset = 'UTF-8', $options = LIBXML_NO
}

libxml_use_internal_errors($internalErrors);
if (LIBXML_VERSION < 20900) {
if (\LIBXML_VERSION < 20900) {
libxml_disable_entity_loader($disableEntities);
}

Expand Down Expand Up @@ -497,7 +497,7 @@ public function parents()
$nodes = [];

while ($node = $node->parentNode) {
if (XML_ELEMENT_NODE === $node->nodeType) {
if (\XML_ELEMENT_NODE === $node->nodeType) {
$nodes[] = $node;
}
}
Expand Down
6 changes: 3 additions & 3 deletions Field/FileFormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FileFormField extends FormField
*/
public function setErrorCode($error)
{
$codes = [UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_EXTENSION];
$codes = [\UPLOAD_ERR_INI_SIZE, \UPLOAD_ERR_FORM_SIZE, \UPLOAD_ERR_PARTIAL, \UPLOAD_ERR_NO_FILE, \UPLOAD_ERR_NO_TMP_DIR, \UPLOAD_ERR_CANT_WRITE, \UPLOAD_ERR_EXTENSION];
if (!\in_array($error, $codes)) {
throw new \InvalidArgumentException(sprintf('The error code "%s" is not valid.', $error));
}
Expand All @@ -53,7 +53,7 @@ public function upload($value)
public function setValue($value)
{
if (null !== $value && is_readable($value)) {
$error = UPLOAD_ERR_OK;
$error = \UPLOAD_ERR_OK;
$size = filesize($value);
$info = pathinfo($value);
$name = $info['basename'];
Expand All @@ -69,7 +69,7 @@ public function setValue($value)
copy($value, $tmp);
$value = $tmp;
} else {
$error = UPLOAD_ERR_NO_FILE;
$error = \UPLOAD_ERR_NO_FILE;
$size = 0;
$name = '';
$value = '';
Expand Down
2 changes: 1 addition & 1 deletion Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function getUri()
$uri = parent::getUri();

if (!\in_array($this->getMethod(), ['POST', 'PUT', 'DELETE', 'PATCH'])) {
$query = parse_url($uri, PHP_URL_QUERY);
$query = parse_url($uri, \PHP_URL_QUERY);
$currentParameters = [];
if ($query) {
parse_str($query, $currentParameters);
Expand Down
8 changes: 4 additions & 4 deletions Tests/Field/FileFormFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testInitialize()
$node = $this->createNode('input', '', ['type' => 'file']);
$field = new FileFormField($node);

$this->assertEquals(['name' => '', 'type' => '', 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, 'size' => 0], $field->getValue(), '->initialize() sets the value of the field to no file uploaded');
$this->assertEquals(['name' => '', 'type' => '', 'tmp_name' => '', 'error' => \UPLOAD_ERR_NO_FILE, 'size' => 0], $field->getValue(), '->initialize() sets the value of the field to no file uploaded');

$node = $this->createNode('textarea', '');
try {
Expand Down Expand Up @@ -48,7 +48,7 @@ public function testSetValue($method)
$field = new FileFormField($node);

$field->$method(null);
$this->assertEquals(['name' => '', 'type' => '', 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, 'size' => 0], $field->getValue(), "->$method() clears the uploaded file if the value is null");
$this->assertEquals(['name' => '', 'type' => '', 'tmp_name' => '', 'error' => \UPLOAD_ERR_NO_FILE, 'size' => 0], $field->getValue(), "->$method() clears the uploaded file if the value is null");

$field->$method(__FILE__);
$value = $field->getValue();
Expand Down Expand Up @@ -91,9 +91,9 @@ public function testSetErrorCode()
$node = $this->createNode('input', '', ['type' => 'file']);
$field = new FileFormField($node);

$field->setErrorCode(UPLOAD_ERR_FORM_SIZE);
$field->setErrorCode(\UPLOAD_ERR_FORM_SIZE);
$value = $field->getValue();
$this->assertEquals(UPLOAD_ERR_FORM_SIZE, $value['error'], '->setErrorCode() sets the file input field error code');
$this->assertEquals(\UPLOAD_ERR_FORM_SIZE, $value['error'], '->setErrorCode() sets the file input field error code');

try {
$field->setErrorCode('foobar');
Expand Down

0 comments on commit 82fe363

Please sign in to comment.