opt
/
cpanel
/
ea-wappspector
/
vendor
/
squizlabs
/
php_codesniffer
/
src
/
Standards
/
Squiz
/
Tests
/
PHP
➕ New
📤 Upload
✎ Editing:
InnerFunctionsUnitTest.inc
← Back
<?php function outer() { if (!function_exists('inner')) { function inner() { } } } // Closures are allowed. function myFunc($foo) { $callback = function ($bar) use ($foo) { $bar += $foo; }; } // Anon class methods are allowed. function test() { return new class { public function foo() { // do something } }; } new class { public function valueObject(): object { return new class { public function string(): string { return 'string'; } }; } }; new class { public function outer() { if (!function_exists('inner')) { function inner() { } } } }; $outerClosure = function () { // Functions inside closures are not allowed. function innerFunction() { } }; // Allow methods in classes/traits/interfaces defined inside functions function foo() { if (class_exists('MyClass') === false) { class MyClass { function foo() {} } } if (trait_exists('MyTrait') === false) { trait MyTrait { function foo() {} } } if (interface_exists('MyInterface') === false) { interface MyInterface { function foo(); } } // But disallow functions nested inside those methods if (class_exists('NestedFunctionInMethod') === false) { class NestedFunctionInMethod { function foo() { function innerFunction() {} } } } }
💾 Save Changes
Cancel
📤 Upload File
×
Select File
Upload
Cancel
➕ Create New
×
Type
📄 File
📁 Folder
Name
Create
Cancel
✎ Rename Item
×
Current Name
New Name
Rename
Cancel
🔐 Change Permissions
×
Target File
Permission (e.g., 0755, 0644)
0755
0644
0777
Apply
Cancel