PHP Classes

File: vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.inc

Recommend this page to a friend!
  Classes of Adeleye Ayodeji   Download Installed Plugin   vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.inc   Download  
File: vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.inc
Role: Example script
Content type: text/plain
Description: Example script
Class: Download Installed Plugin
Download a WordPress plugin as a ZIP archive
Author: By
Last change:
Date: Yesterday
Size: 1,598 bytes
 

Contents

Class file image Download
<?php
$var
= TRUE;
$var = ($foo === $bar);
$var = ($foo * $bar);
$var = !$foo;
$var = ($foo || $bar);
$var = ($foo === TRUE);
$var = ($foo === TRUE
       
|| $bar === FALSE);
$var = (!$foo);

$var = is_array($foo);
$var = myFunction($one, $two);
$var = myFunction(
       
'one',
       
'two'
      
);

for (
$i = ($stackPtr + 1); $i < $endStatement; $i++) {
}

// These conditions are allowed by this sniff.
$var = myFunction(!$var);

$depthAdv = array(
            
$this,
             !
$directLinks,
            
FALSE,
            );

$var = myFunction(
   
$var,
    array(
    
$this,
     !
$directLinks,
    
FALSE,
    );
);

for (
$node = $fieldsTag->nextSibling; $node; $node = $node->nextSibling) {
    if (
$node->nodeType !== XML_ELEMENT_NODE) {
        continue;
    }

    for (
$node = $fields->nextSibling; $node; $node = $node->nextSibling) {
        if (
$node->nodeType !== XML_ELEMENT_NODE) {
            continue;
        }
    }
}

$a = $b ? $c : $d;
$a = $b === true ? $c : $d;

$this->_args = $this->_getArgs(($_SERVER['argv'] ?? []));
$args = ($_SERVER['argv'] ?? []);

$a = [
   
'a' => ($foo) ? $foo : $bar,
];

$a = [
   
'a' => ($foo) ? fn() => return 1 : fn() => return 2,
];

$var = $foo->something(!$var);
$var = $foo?->something(!$var);

$callback = function ($value) {
    if (
$value > 10) {
        return
false;
    }
};

function
issue3616() {
   
$food = 'cake';

   
$returnValue = match (true) {
       
$food === 'apple' => 'This food is an apple',
       
$food === 'bar' => 'This food is a bar',
       
$food === 'cake' => 'This food is a cake',
    };
}