PHP Classes

File: vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/GotoLabelTest.inc

Recommend this page to a friend!
  Classes of Adeleye Ayodeji   Download Installed Plugin   vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/GotoLabelTest.inc   Download  
File: vendor/squizlabs/php_codesniffer/tests/Core/Tokenizer/PHP/GotoLabelTest.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: 2 days ago
Size: 1,060 bytes
 

Contents

Class file image Download
<?php

/* testGotoStatement */
goto marker;
echo
'Foo';

/* testGotoDeclaration */
marker:
echo
'Bar';

/* testGotoStatementInLoop */
for($i=0,$j=50; $i<100; $i++) {
  while(
$j--) {
    if(
$j==17) GOTO end;
  }
}
echo
"i = $i";
?>
<div><?php $cond ? TEST_A : TEST_B ?></div>

<?php
/* testGotoDeclarationOutsideLoop */
end:
echo
'j hit 17';

switch (
$x) {
   
/* testNotGotoDeclarationGlobalConstant */
   
case CONSTANT:
       
// Do something.
       
break;

   
/* testNotGotoDeclarationNamespacedConstant */
   
case MyNS\CONSTANT:
       
// Do something.
       
break;

   
/* testNotGotoDeclarationClassConstant */
   
case MyClass::CONSTANT:
       
// Do something.
       
break;

   
/* testNotGotoDeclarationClassProperty */
   
case $obj->property:
       
// Do something.
       
break;
}

switch (
true) {
   
/* testNotGotoDeclarationGlobalConstantInTernary */
   
case $x === ($cond) ? CONST_A : CONST_B:
       
// Do something.
       
break;
}

/* testNotGotoDeclarationEnumWithType */
enum Suit: string implements Colorful, CardGame {}