From 0b9433216b9d00e59f686c90d34ec50b6f2adcf5 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Mon, 23 Jul 2012 09:31:22 +0200 Subject: [PATCH] Added staticCalls test file. Tests for static calls (using pattern matching). Uses a whitelist; correct calls must be added manually. At the moment all calls have been marked correct except CHTTPRequest and CController. When finding an incorrect call you can use sed / awk to recursively fix the errors. --- application/tests/staticCalls.php | 152 ++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 application/tests/staticCalls.php diff --git a/application/tests/staticCalls.php b/application/tests/staticCalls.php new file mode 100644 index 00000000000..c3dd1a9b302 --- /dev/null +++ b/application/tests/staticCalls.php @@ -0,0 +1,152 @@ +hasChildren() && !ignore($entry)) + { + iterateList($i->getChildren()); + } + else + { + if (substr($entry, -4, 4) == '.php') + { + checkFile($entry); + } + } + } +} + +// Get all static calls in file. +function checkFile($filename) +{ + if ($filename == __FILE__) + { + return; + } + $file = file($filename, FILE_IGNORE_NEW_LINES); + $file = array_filter($file, "checkStatic"); + + if (!empty($file)) + { + pr($filename); + print_r($file); + } +} + +function checkStatic($line) +{ + $validStatics = array( + 'Yii::', + 'parent::', + 'LimeExpressionManager::', +'Answers::', +'Questions::', +'Survey::', +'Groups::', +'self::', +'PDO::', +'Participants::', +'Survey_links::', +'Participant_attribute::', +'Tokens::', +'User_groups::', +'Tokens_dynamic::', +'Conditions::', +'Survey_Common_Action::', +'Quota::', +'Survey_url_parameters::', +'Survey_languagesettings::', +'Survey_permissions::', +'Saved_control::', +'Quota_members::', +'Quota_languagesettings::', +'ParticipantAttributeNames::', +'User::', +'Surveys_languagesettings::', +'Question_attributes::', +'Assessment::', +'CDbConnection::', +'ParticipantShares::', +'\'{INSERTANS::', +'Defaultvalues::', +'CHtml::', +'ExpressionManager::', +'\'::\'', +'Labelsets::', +'Survey_dynamic::', +'PEAR::', +'Settings_global::', +'Zend_Http_Client::', +'Zend_XmlRpc_Value::', +'Templates_rights_model::', +'Zend_XmlRpc_Server_Fault::', +'Zend_XmlRpc_Value::', +'Zend_Server_Cache::', +'Zend_XmlRpc_Server_Cache::', +'Label::', +'Assessments::', +'XMLReader::', +'LEM::', +'Question::', +'DateTime::', +'Installer::', +'Sessions::', +'dataentry::', +'Assessments::', +'Zend_Server_Reflection::', +'Participants::', +'jsonRPCServer::', +'Failed_login_attempts::', +'survey::', +'tokens::', +'questiongroup::', +'printanswers::', +'imagick::', +':: ', +'Assessments::', +'InstallerConfigForm::', +'Database::', +'User_in_groups::', +'Usergroups::', +'Survey_timings::', +'::regClass', +'surveypermission::', +'Template::', +'templates::', +'Templates_rights::', +'register::', +'::first', +'::before', +'::after', +'::reg', +'text::', +'httpCache::' + ); + $replacements = array_pad(array(), count($validStatics), ''); + $line = str_replace($validStatics, $replacements, $line); + + return strpos($line, '::') !== false; + +} +function pr($msg) +{ + echo $msg . "\n"; +} +?>