Skip to content

Commit 2fd6513

Browse files
committed
Enable the fixer enforcing fully-qualified calls for compiler-optimized functions
1 parent 7475ced commit 2fd6513

File tree

7 files changed

+40
-40
lines changed

7 files changed

+40
-40
lines changed

Crawler.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ public function add($node)
8787
$this->addNodeList($node);
8888
} elseif ($node instanceof \DOMNode) {
8989
$this->addNode($node);
90-
} elseif (is_array($node)) {
90+
} elseif (\is_array($node)) {
9191
$this->addNodes($node);
92-
} elseif (is_string($node)) {
92+
} elseif (\is_string($node)) {
9393
$this->addContent($node);
9494
} elseif (null !== $node) {
95-
throw new \InvalidArgumentException(sprintf('Expecting a DOMNodeList or DOMNode instance, an array, a string, or null, but got "%s".', is_object($node) ? get_class($node) : gettype($node)));
95+
throw new \InvalidArgumentException(sprintf('Expecting a DOMNodeList or DOMNode instance, an array, a string, or null, but got "%s".', \is_object($node) ? \get_class($node) : \gettype($node)));
9696
}
9797
}
9898

@@ -186,7 +186,7 @@ public function addHtmlContent($content, $charset = 'UTF-8')
186186
$base = $this->filterRelativeXPath('descendant-or-self::base')->extract(array('href'));
187187

188188
$baseHref = current($base);
189-
if (count($base) && !empty($baseHref)) {
189+
if (\count($base) && !empty($baseHref)) {
190190
if ($this->baseHref) {
191191
$linkNode = $dom->createElement('a');
192192
$linkNode->setAttribute('href', $baseHref);
@@ -405,7 +405,7 @@ public function first()
405405
*/
406406
public function last()
407407
{
408-
return $this->eq(count($this) - 1);
408+
return $this->eq(\count($this) - 1);
409409
}
410410

411411
/**
@@ -417,7 +417,7 @@ public function last()
417417
*/
418418
public function siblings()
419419
{
420-
if (!count($this)) {
420+
if (!\count($this)) {
421421
throw new \InvalidArgumentException('The current node list is empty.');
422422
}
423423

@@ -433,7 +433,7 @@ public function siblings()
433433
*/
434434
public function nextAll()
435435
{
436-
if (!count($this)) {
436+
if (!\count($this)) {
437437
throw new \InvalidArgumentException('The current node list is empty.');
438438
}
439439

@@ -449,7 +449,7 @@ public function nextAll()
449449
*/
450450
public function previousAll()
451451
{
452-
if (!count($this)) {
452+
if (!\count($this)) {
453453
throw new \InvalidArgumentException('The current node list is empty.');
454454
}
455455

@@ -465,7 +465,7 @@ public function previousAll()
465465
*/
466466
public function parents()
467467
{
468-
if (!count($this)) {
468+
if (!\count($this)) {
469469
throw new \InvalidArgumentException('The current node list is empty.');
470470
}
471471

@@ -490,7 +490,7 @@ public function parents()
490490
*/
491491
public function children()
492492
{
493-
if (!count($this)) {
493+
if (!\count($this)) {
494494
throw new \InvalidArgumentException('The current node list is empty.');
495495
}
496496

@@ -510,7 +510,7 @@ public function children()
510510
*/
511511
public function attr($attribute)
512512
{
513-
if (!count($this)) {
513+
if (!\count($this)) {
514514
throw new \InvalidArgumentException('The current node list is empty.');
515515
}
516516

@@ -528,7 +528,7 @@ public function attr($attribute)
528528
*/
529529
public function nodeName()
530530
{
531-
if (!count($this)) {
531+
if (!\count($this)) {
532532
throw new \InvalidArgumentException('The current node list is empty.');
533533
}
534534

@@ -544,7 +544,7 @@ public function nodeName()
544544
*/
545545
public function text()
546546
{
547-
if (!count($this)) {
547+
if (!\count($this)) {
548548
throw new \InvalidArgumentException('The current node list is empty.');
549549
}
550550

@@ -560,7 +560,7 @@ public function text()
560560
*/
561561
public function html()
562562
{
563-
if (!count($this)) {
563+
if (!\count($this)) {
564564
throw new \InvalidArgumentException('The current node list is empty.');
565565
}
566566

@@ -588,7 +588,7 @@ public function html()
588588
public function extract($attributes)
589589
{
590590
$attributes = (array) $attributes;
591-
$count = count($attributes);
591+
$count = \count($attributes);
592592

593593
$data = array();
594594
foreach ($this as $node) {
@@ -697,14 +697,14 @@ public function selectButton($value)
697697
*/
698698
public function link($method = 'get')
699699
{
700-
if (!count($this)) {
700+
if (!\count($this)) {
701701
throw new \InvalidArgumentException('The current node list is empty.');
702702
}
703703

704704
$node = $this->getNode(0);
705705

706706
if (!$node instanceof \DOMElement) {
707-
throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', get_class($node)));
707+
throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', \get_class($node)));
708708
}
709709

710710
return new Link($node, $this->baseHref, $method);
@@ -722,7 +722,7 @@ public function links()
722722
$links = array();
723723
foreach ($this as $node) {
724724
if (!$node instanceof \DOMElement) {
725-
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', get_class($node)));
725+
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', \get_class($node)));
726726
}
727727

728728
$links[] = new Link($node, $this->baseHref, 'get');
@@ -743,14 +743,14 @@ public function links()
743743
*/
744744
public function form(array $values = null, $method = null)
745745
{
746-
if (!count($this)) {
746+
if (!\count($this)) {
747747
throw new \InvalidArgumentException('The current node list is empty.');
748748
}
749749

750750
$node = $this->getNode(0);
751751

752752
if (!$node instanceof \DOMElement) {
753-
throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', get_class($node)));
753+
throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', \get_class($node)));
754754
}
755755

756756
$form = new Form($node, $this->uri, $method, $this->baseHref);
@@ -989,7 +989,7 @@ private function relativize($xpath)
989989
// We cannot simply drop
990990
$nonMatchingExpression = 'a[name() = "b"]';
991991

992-
$xpathLen = strlen($xpath);
992+
$xpathLen = \strlen($xpath);
993993
$openedBrackets = 0;
994994
$startPosition = strspn($xpath, " \t\n\r\0\x0B");
995995

@@ -1185,7 +1185,7 @@ private function createSubCrawler($nodes)
11851185

11861186
private function triggerDeprecation($methodName, $useTrace = false)
11871187
{
1188-
if ($useTrace || defined('HHVM_VERSION')) {
1188+
if ($useTrace || \defined('HHVM_VERSION')) {
11891189
if (\PHP_VERSION_ID >= 50400) {
11901190
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
11911191
} else {

Field/ChoiceFormField.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ChoiceFormField extends FormField
4545
public function hasValue()
4646
{
4747
// don't send a value for unchecked checkboxes
48-
if (in_array($this->type, array('checkbox', 'radio')) && null === $this->value) {
48+
if (\in_array($this->type, array('checkbox', 'radio')) && null === $this->value) {
4949
return false;
5050
}
5151

@@ -126,7 +126,7 @@ public function setValue($value)
126126
// check
127127
$this->value = $this->options[0]['value'];
128128
} else {
129-
if (is_array($value)) {
129+
if (\is_array($value)) {
130130
if (!$this->multiple) {
131131
throw new \InvalidArgumentException(sprintf('The value for "%s" cannot be an array.', $this->name));
132132
}
@@ -144,7 +144,7 @@ public function setValue($value)
144144
$value = (array) $value;
145145
}
146146

147-
if (is_array($value)) {
147+
if (\is_array($value)) {
148148
$this->value = $value;
149149
} else {
150150
parent::setValue($value);

Field/FileFormField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class FileFormField extends FormField
2828
public function setErrorCode($error)
2929
{
3030
$codes = array(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);
31-
if (!in_array($error, $codes)) {
31+
if (!\in_array($error, $codes)) {
3232
throw new \InvalidArgumentException(sprintf('The error code %s is not valid.', $error));
3333
}
3434

Form.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function getValues()
108108
*/
109109
public function getFiles()
110110
{
111-
if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) {
111+
if (!\in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) {
112112
return array();
113113
}
114114

@@ -142,7 +142,7 @@ public function getPhpValues()
142142
$qs = http_build_query(array($name => $value), '', '&');
143143
if (!empty($qs)) {
144144
parse_str($qs, $expandedValue);
145-
$varName = substr($name, 0, strlen(key($expandedValue)));
145+
$varName = substr($name, 0, \strlen(key($expandedValue)));
146146
$values = array_replace_recursive($values, array($varName => current($expandedValue)));
147147
}
148148
}
@@ -169,7 +169,7 @@ public function getPhpFiles()
169169
$qs = http_build_query(array($name => $value), '', '&');
170170
if (!empty($qs)) {
171171
parse_str($qs, $expandedValue);
172-
$varName = substr($name, 0, strlen(key($expandedValue)));
172+
$varName = substr($name, 0, \strlen(key($expandedValue)));
173173

174174
array_walk_recursive(
175175
$expandedValue,
@@ -202,7 +202,7 @@ public function getUri()
202202
{
203203
$uri = parent::getUri();
204204

205-
if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) {
205+
if (!\in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) {
206206
$query = parse_url($uri, PHP_URL_QUERY);
207207
$currentParameters = array();
208208
if ($query) {
@@ -369,7 +369,7 @@ public function disableValidation()
369369
protected function setNode(\DOMElement $node)
370370
{
371371
$this->button = $node;
372-
if ('button' === $node->nodeName || ('input' === $node->nodeName && in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image')))) {
372+
if ('button' === $node->nodeName || ('input' === $node->nodeName && \in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image')))) {
373373
if ($node->hasAttribute('form')) {
374374
// if the node has the HTML5-compliant 'form' attribute, use it
375375
$formId = $node->getAttribute('form');
@@ -470,7 +470,7 @@ private function addField(\DOMElement $node)
470470
}
471471
} elseif ('input' == $nodeName && 'file' == strtolower($node->getAttribute('type'))) {
472472
$this->set(new Field\FileFormField($node));
473-
} elseif ('input' == $nodeName && !in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image'))) {
473+
} elseif ('input' == $nodeName && !\in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image'))) {
474474
$this->set(new Field\InputFormField($node));
475475
} elseif ('textarea' == $nodeName) {
476476
$this->set(new Field\TextareaFormField($node));

FormFieldRegistry.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function add(FormField $field)
3333

3434
$target = &$this->fields;
3535
while ($segments) {
36-
if (!is_array($target)) {
36+
if (!\is_array($target)) {
3737
$target = array();
3838
}
3939
$path = array_shift($segments);
@@ -55,7 +55,7 @@ public function remove($name)
5555
{
5656
$segments = $this->getSegments($name);
5757
$target = &$this->fields;
58-
while (count($segments) > 1) {
58+
while (\count($segments) > 1) {
5959
$path = array_shift($segments);
6060
if (!array_key_exists($path, $target)) {
6161
return;
@@ -118,9 +118,9 @@ public function has($name)
118118
public function set($name, $value)
119119
{
120120
$target = &$this->get($name);
121-
if ((!is_array($value) && $target instanceof Field\FormField) || $target instanceof Field\ChoiceFormField) {
121+
if ((!\is_array($value) && $target instanceof Field\FormField) || $target instanceof Field\ChoiceFormField) {
122122
$target->setValue($value);
123-
} elseif (is_array($value)) {
123+
} elseif (\is_array($value)) {
124124
$fields = self::create($name, $value);
125125
foreach ($fields->all() as $k => $v) {
126126
$this->set($k, $v);
@@ -173,7 +173,7 @@ private function walk(array $array, $base = '', array &$output = array())
173173
{
174174
foreach ($array as $k => $v) {
175175
$path = empty($base) ? $k : sprintf('%s[%s]', $base, $k);
176-
if (is_array($v)) {
176+
if (\is_array($v)) {
177177
$this->walk($v, $path, $output);
178178
} else {
179179
$output[$path] = $v;

Link.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Link
4242
*/
4343
public function __construct(\DOMElement $node, $currentUri, $method = 'GET')
4444
{
45-
if (!in_array(strtolower(substr($currentUri, 0, 4)), array('http', 'file'))) {
45+
if (!\in_array(strtolower(substr($currentUri, 0, 4)), array('http', 'file'))) {
4646
throw new \InvalidArgumentException(sprintf('Current URI must be an absolute URL ("%s").', $currentUri));
4747
}
4848

@@ -114,7 +114,7 @@ public function getUri()
114114
}
115115

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

120120
return $baseUri.('' === $path || '/' !== $path[0] ? '/' : '').$path;

Tests/FormTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public function testConstructor($message, $form, $values)
191191
$values,
192192
array_map(
193193
function ($field) {
194-
$class = get_class($field);
194+
$class = \get_class($field);
195195

196196
return array(substr($class, strrpos($class, '\\') + 1), $field->getValue());
197197
},

0 commit comments

Comments
 (0)