From a0c6f2e5e071a287717e58f32c5b3cf6e219f321 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 7 Jul 2015 15:37:56 +0200 Subject: Use the decorator pattern --- lib/private/app/codechecker/codechecker.php | 10 +- lib/private/app/codechecker/deprecationcheck.php | 163 +++++++++++++++++++++ lib/private/app/codechecker/deprecationlist.php | 152 ------------------- lib/private/app/codechecker/emptycheck.php | 65 ++++++++ lib/private/app/codechecker/icheck.php | 53 +++++++ lib/private/app/codechecker/ichecklist.php | 53 ------- lib/private/app/codechecker/nodevisitor.php | 4 +- lib/private/app/codechecker/privatecheck.php | 104 +++++++++++++ lib/private/app/codechecker/privatelist.php | 105 ------------- .../app/codechecker/strongcomparisoncheck.php | 78 ++++++++++ 10 files changed, 470 insertions(+), 317 deletions(-) create mode 100644 lib/private/app/codechecker/deprecationcheck.php delete mode 100644 lib/private/app/codechecker/deprecationlist.php create mode 100644 lib/private/app/codechecker/emptycheck.php create mode 100644 lib/private/app/codechecker/icheck.php delete mode 100644 lib/private/app/codechecker/ichecklist.php create mode 100644 lib/private/app/codechecker/privatecheck.php delete mode 100644 lib/private/app/codechecker/privatelist.php create mode 100644 lib/private/app/codechecker/strongcomparisoncheck.php (limited to 'lib') diff --git a/lib/private/app/codechecker/codechecker.php b/lib/private/app/codechecker/codechecker.php index b2ee9d6d71d..ae16b156178 100644 --- a/lib/private/app/codechecker/codechecker.php +++ b/lib/private/app/codechecker/codechecker.php @@ -49,11 +49,11 @@ class CodeChecker extends BasicEmitter { /** @var Parser */ private $parser; - /** @var ICheckList */ - protected $list; + /** @var ICheck */ + protected $checkList; - public function __construct(ICheckList $list) { - $this->list = $list; + public function __construct(ICheck $checkList) { + $this->checkList = $checkList; $this->parser = new Parser(new Lexer); } @@ -114,7 +114,7 @@ class CodeChecker extends BasicEmitter { $code = file_get_contents($file); $statements = $this->parser->parse($code); - $visitor = new NodeVisitor($this->list); + $visitor = new NodeVisitor($this->checkList); $traverser = new NodeTraverser; $traverser->addVisitor($visitor); diff --git a/lib/private/app/codechecker/deprecationcheck.php b/lib/private/app/codechecker/deprecationcheck.php new file mode 100644 index 00000000000..bac59e4dd7c --- /dev/null +++ b/lib/private/app/codechecker/deprecationcheck.php @@ -0,0 +1,163 @@ + + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OC\App\CodeChecker; + +class DeprecationCheck implements ICheck { + /** @var ICheck */ + protected $check; + + /** + * @param ICheck $check + */ + public function __construct(ICheck $check) { + $this->check = $check; + } + + /** + * @return string + */ + public function getDescription() { + $innerDescription = $this->check->getDescription(); + return 'deprecated' . (($innerDescription === '') ? '' : ' ' . $innerDescription); + } + + /** + * @return array E.g.: `'ClassName' => 'oc version',` + */ + public function getClasses() { + return array_merge([ + 'OCP\Config' => '8.0.0', + 'OCP\Contacts' => '8.1.0', + 'OCP\DB' => '8.1.0', + 'OCP\IHelper' => '8.1.0', + 'OCP\JSON' => '8.1.0', + 'OCP\Response' => '8.1.0', + 'OCP\AppFramework\IApi' => '8.0.0', + ], $this->check->getClasses()); + } + + /** + * @return array E.g.: `'ClassName::CONSTANT_NAME' => 'oc version',` + */ + public function getConstants() { + return array_merge([ + 'OCP::PERMISSION_CREATE' => '8.0.0', + 'OCP::PERMISSION_READ' => '8.0.0', + 'OCP::PERMISSION_UPDATE' => '8.0.0', + 'OCP::PERMISSION_DELETE' => '8.0.0', + 'OCP::PERMISSION_SHARE' => '8.0.0', + 'OCP::PERMISSION_ALL' => '8.0.0', + 'OCP::FILENAME_INVALID_CHARS' => '8.0.0', + ], $this->check->getConstants()); + } + + /** + * @return array E.g.: `'functionName' => 'oc version',` + */ + public function getFunctions() { + return array_merge([ + 'OCP::image_path' => '8.0.0', + 'OCP::mimetype_icon' => '8.0.0', + 'OCP::preview_icon' => '8.0.0', + 'OCP::publicPreview_icon' => '8.0.0', + 'OCP::human_file_size' => '8.0.0', + 'OCP::relative_modified_date' => '8.0.0', + 'OCP::simple_file_size' => '8.0.0', + 'OCP::html_select_options' => '8.0.0', + ], $this->check->getFunctions()); + } + + /** + * @return array E.g.: `'ClassName::methodName' => 'oc version',` + */ + public function getMethods() { + return array_merge([ + 'OCP\App::register' => '8.1.0', + 'OCP\App::addNavigationEntry' => '8.1.0', + 'OCP\App::setActiveNavigationEntry' => '8.1.0', + + 'OCP\AppFramework\Controller::params' => '7.0.0', + 'OCP\AppFramework\Controller::getParams' => '7.0.0', + 'OCP\AppFramework\Controller::method' => '7.0.0', + 'OCP\AppFramework\Controller::getUploadedFile' => '7.0.0', + 'OCP\AppFramework\Controller::env' => '7.0.0', + 'OCP\AppFramework\Controller::cookie' => '7.0.0', + 'OCP\AppFramework\Controller::render' => '7.0.0', + + 'OCP\AppFramework\IAppContainer::getCoreApi' => '8.0.0', + 'OCP\AppFramework\IAppContainer::isLoggedIn' => '8.0.0', + 'OCP\AppFramework\IAppContainer::isAdminUser' => '8.0.0', + 'OCP\AppFramework\IAppContainer::log' => '8.0.0', + + 'OCP\BackgroundJob::addQueuedTask' => '6.0.0', + 'OCP\BackgroundJob::addRegularTask' => '6.0.0', + 'OCP\BackgroundJob::allQueuedTasks' => '6.0.0', + 'OCP\BackgroundJob::allRegularTasks' => '6.0.0', + 'OCP\BackgroundJob::deleteQueuedTask' => '6.0.0', + 'OCP\BackgroundJob::findQueuedTask' => '6.0.0', + 'OCP\BackgroundJob::queuedTaskWhereAppIs' => '6.0.0', + 'OCP\BackgroundJob::registerJob' => '8.1.0', + + 'OCP\Files::tmpFile' => '8.1.0', + 'OCP\Files::tmpFolder' => '8.1.0', + + 'OCP\IAppConfig::getValue' => '8.0.0', + 'OCP\IAppConfig::deleteKey' => '8.0.0', + 'OCP\IAppConfig::getKeys' => '8.0.0', + 'OCP\IAppConfig::setValue' => '8.0.0', + 'OCP\IAppConfig::deleteApp' => '8.0.0', + + 'OCP\ISearch::search' => '8.0.0', + + 'OCP\IServerContainer::getDb' => '8.1.0', + 'OCP\IServerContainer::getHTTPHelper' => '8.1.0', + + 'OCP\User::getUser' => '8.0.0', + 'OCP\User::getUsers' => '8.1.0', + 'OCP\User::getDisplayName' => '8.1.0', + 'OCP\User::getDisplayNames' => '8.1.0', + 'OCP\User::userExists' => '8.1.0', + 'OCP\User::logout' => '8.1.0', + 'OCP\User::checkPassword' => '8.1.0', + + 'OCP\Util::sendMail' => '8.1.0', + 'OCP\Util::formatDate' => '8.0.0', + 'OCP\Util::encryptedFiles' => '8.1.0', + 'OCP\Util::linkToRoute' => '8.1.0', + 'OCP\Util::linkTo' => '8.1.0', + 'OCP\Util::getServerHost' => '8.1.0', + 'OCP\Util::getServerProtocol' => '8.1.0', + 'OCP\Util::getRequestUri' => '8.1.0', + 'OCP\Util::getScriptName' => '8.1.0', + 'OCP\Util::imagePath' => '8.1.0', + 'OCP\Util::isValidFileName' => '8.1.0', + 'OCP\Util::generateRandomBytes' => '8.1.0', + ], $this->check->getMethods()); + } + + /** + * @return bool + */ + public function checkStrongComparisons() { + return $this->check->checkStrongComparisons(); + } +} diff --git a/lib/private/app/codechecker/deprecationlist.php b/lib/private/app/codechecker/deprecationlist.php deleted file mode 100644 index d0abc75a30f..00000000000 --- a/lib/private/app/codechecker/deprecationlist.php +++ /dev/null @@ -1,152 +0,0 @@ - - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -namespace OC\App\CodeChecker; - -class DeprecationList implements ICheckList { - /** - * @return string - */ - public function getDescription() { - return 'deprecated'; - } - - /** - * @return array E.g.: `'ClassName' => 'oc version',` - */ - public function getClasses() { - return [ - 'OCP\Config' => '8.0.0', - 'OCP\Contacts' => '8.1.0', - 'OCP\DB' => '8.1.0', - 'OCP\IHelper' => '8.1.0', - 'OCP\JSON' => '8.1.0', - 'OCP\Response' => '8.1.0', - 'OCP\AppFramework\IApi' => '8.0.0', - ]; - } - - /** - * @return array E.g.: `'ClassName::CONSTANT_NAME' => 'oc version',` - */ - public function getConstants() { - return [ - 'OCP::PERMISSION_CREATE' => '8.0.0', - 'OCP::PERMISSION_READ' => '8.0.0', - 'OCP::PERMISSION_UPDATE' => '8.0.0', - 'OCP::PERMISSION_DELETE' => '8.0.0', - 'OCP::PERMISSION_SHARE' => '8.0.0', - 'OCP::PERMISSION_ALL' => '8.0.0', - 'OCP::FILENAME_INVALID_CHARS' => '8.0.0', - ]; - } - - /** - * @return array E.g.: `'functionName' => 'oc version',` - */ - public function getFunctions() { - return [ - 'OCP::image_path' => '8.0.0', - 'OCP::mimetype_icon' => '8.0.0', - 'OCP::preview_icon' => '8.0.0', - 'OCP::publicPreview_icon' => '8.0.0', - 'OCP::human_file_size' => '8.0.0', - 'OCP::relative_modified_date' => '8.0.0', - 'OCP::simple_file_size' => '8.0.0', - 'OCP::html_select_options' => '8.0.0', - ]; - } - - /** - * @return array E.g.: `'ClassName::methodName' => 'oc version',` - */ - public function getMethods() { - return [ - 'OCP\App::register' => '8.1.0', - 'OCP\App::addNavigationEntry' => '8.1.0', - 'OCP\App::setActiveNavigationEntry' => '8.1.0', - - 'OCP\AppFramework\Controller::params' => '7.0.0', - 'OCP\AppFramework\Controller::getParams' => '7.0.0', - 'OCP\AppFramework\Controller::method' => '7.0.0', - 'OCP\AppFramework\Controller::getUploadedFile' => '7.0.0', - 'OCP\AppFramework\Controller::env' => '7.0.0', - 'OCP\AppFramework\Controller::cookie' => '7.0.0', - 'OCP\AppFramework\Controller::render' => '7.0.0', - - 'OCP\AppFramework\IAppContainer::getCoreApi' => '8.0.0', - 'OCP\AppFramework\IAppContainer::isLoggedIn' => '8.0.0', - 'OCP\AppFramework\IAppContainer::isAdminUser' => '8.0.0', - 'OCP\AppFramework\IAppContainer::log' => '8.0.0', - - 'OCP\BackgroundJob::addQueuedTask' => '6.0.0', - 'OCP\BackgroundJob::addRegularTask' => '6.0.0', - 'OCP\BackgroundJob::allQueuedTasks' => '6.0.0', - 'OCP\BackgroundJob::allRegularTasks' => '6.0.0', - 'OCP\BackgroundJob::deleteQueuedTask' => '6.0.0', - 'OCP\BackgroundJob::findQueuedTask' => '6.0.0', - 'OCP\BackgroundJob::queuedTaskWhereAppIs' => '6.0.0', - 'OCP\BackgroundJob::registerJob' => '8.1.0', - - 'OCP\Files::tmpFile' => '8.1.0', - 'OCP\Files::tmpFolder' => '8.1.0', - - 'OCP\IAppConfig::getValue' => '8.0.0', - 'OCP\IAppConfig::deleteKey' => '8.0.0', - 'OCP\IAppConfig::getKeys' => '8.0.0', - 'OCP\IAppConfig::setValue' => '8.0.0', - 'OCP\IAppConfig::deleteApp' => '8.0.0', - - 'OCP\ISearch::search' => '8.0.0', - - 'OCP\IServerContainer::getDb' => '8.1.0', - 'OCP\IServerContainer::getHTTPHelper' => '8.1.0', - - 'OCP\User::getUser' => '8.0.0', - 'OCP\User::getUsers' => '8.1.0', - 'OCP\User::getDisplayName' => '8.1.0', - 'OCP\User::getDisplayNames' => '8.1.0', - 'OCP\User::userExists' => '8.1.0', - 'OCP\User::logout' => '8.1.0', - 'OCP\User::checkPassword' => '8.1.0', - - 'OCP\Util::sendMail' => '8.1.0', - 'OCP\Util::formatDate' => '8.0.0', - 'OCP\Util::encryptedFiles' => '8.1.0', - 'OCP\Util::linkToRoute' => '8.1.0', - 'OCP\Util::linkTo' => '8.1.0', - 'OCP\Util::getServerHost' => '8.1.0', - 'OCP\Util::getServerProtocol' => '8.1.0', - 'OCP\Util::getRequestUri' => '8.1.0', - 'OCP\Util::getScriptName' => '8.1.0', - 'OCP\Util::imagePath' => '8.1.0', - 'OCP\Util::isValidFileName' => '8.1.0', - 'OCP\Util::generateRandomBytes' => '8.1.0', - ]; - } - - /** - * @return bool - */ - public function checkStrongComparisons() { - return true; - } -} diff --git a/lib/private/app/codechecker/emptycheck.php b/lib/private/app/codechecker/emptycheck.php new file mode 100644 index 00000000000..78a0d303790 --- /dev/null +++ b/lib/private/app/codechecker/emptycheck.php @@ -0,0 +1,65 @@ + + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ +namespace OC\App\CodeChecker; + +class EmptyCheck implements ICheck { + /** + * @return string + */ + public function getDescription() { + return ''; + } + + /** + * @return array E.g.: `'ClassName' => 'oc version',` + */ + public function getClasses() { + return []; + } + + /** + * @return array E.g.: `'ClassName::CONSTANT_NAME' => 'oc version',` + */ + public function getConstants() { + return []; + } + + /** + * @return array E.g.: `'functionName' => 'oc version',` + */ + public function getFunctions() { + return []; + } + + /** + * @return array E.g.: `'ClassName::methodName' => 'oc version',` + */ + public function getMethods() { + return []; + } + + /** + * @return bool + */ + public function checkStrongComparisons() { + return false; + } +} diff --git a/lib/private/app/codechecker/icheck.php b/lib/private/app/codechecker/icheck.php new file mode 100644 index 00000000000..7625a105b0a --- /dev/null +++ b/lib/private/app/codechecker/icheck.php @@ -0,0 +1,53 @@ + + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ +namespace OC\App\CodeChecker; + +interface ICheck { + /** + * @return string + */ + public function getDescription(); + + /** + * @return array E.g.: `'ClassName' => 'oc version',` + */ + public function getClasses(); + + /** + * @return array E.g.: `'ClassName::CONSTANT_NAME' => 'oc version',` + */ + public function getConstants(); + + /** + * @return array E.g.: `'functionName' => 'oc version',` + */ + public function getFunctions(); + + /** + * @return array E.g.: `'ClassName::methodName' => 'oc version',` + */ + public function getMethods(); + + /** + * @return bool + */ + public function checkStrongComparisons(); +} diff --git a/lib/private/app/codechecker/ichecklist.php b/lib/private/app/codechecker/ichecklist.php deleted file mode 100644 index c5cc82e6bb5..00000000000 --- a/lib/private/app/codechecker/ichecklist.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ -namespace OC\App\CodeChecker; - -interface ICheckList { - /** - * @return string - */ - public function getDescription(); - - /** - * @return array E.g.: `'ClassName' => 'oc version',` - */ - public function getClasses(); - - /** - * @return array E.g.: `'ClassName::CONSTANT_NAME' => 'oc version',` - */ - public function getConstants(); - - /** - * @return array E.g.: `'functionName' => 'oc version',` - */ - public function getFunctions(); - - /** - * @return array E.g.: `'ClassName::methodName' => 'oc version',` - */ - public function getMethods(); - - /** - * @return bool - */ - public function checkStrongComparisons(); -} diff --git a/lib/private/app/codechecker/nodevisitor.php b/lib/private/app/codechecker/nodevisitor.php index 8ec4a0320f4..80acb9f2414 100644 --- a/lib/private/app/codechecker/nodevisitor.php +++ b/lib/private/app/codechecker/nodevisitor.php @@ -43,9 +43,9 @@ class NodeVisitor extends NodeVisitorAbstract { protected $errorMessages; /** - * @param ICheckList $list + * @param ICheck $list */ - public function __construct(ICheckList $list) { + public function __construct(ICheck $list) { $this->blackListDescription = $list->getDescription(); $this->blackListedClassNames = []; diff --git a/lib/private/app/codechecker/privatecheck.php b/lib/private/app/codechecker/privatecheck.php new file mode 100644 index 00000000000..e7497f3dbfc --- /dev/null +++ b/lib/private/app/codechecker/privatecheck.php @@ -0,0 +1,104 @@ + + * @author Morris Jobke + * @author Thomas Müller + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OC\App\CodeChecker; + +class PrivateCheck implements ICheck { + /** @var ICheck */ + protected $check; + + /** + * @param ICheck $check + */ + public function __construct(ICheck $check) { + $this->check = $check; + } + + /** + * @return string + */ + public function getDescription() { + $innerDescription = $this->check->getDescription(); + return 'private' . (($innerDescription === '') ? '' : ' ' . $innerDescription); + } + + /** + * @return array + */ + public function getClasses() { + return array_merge([ + // classes replaced by the public api + 'OC_API' => '6.0.0', + 'OC_App' => '6.0.0', + 'OC_AppConfig' => '6.0.0', + 'OC_Avatar' => '6.0.0', + 'OC_BackgroundJob' => '6.0.0', + 'OC_Config' => '6.0.0', + 'OC_DB' => '6.0.0', + 'OC_Files' => '6.0.0', + 'OC_Helper' => '6.0.0', + 'OC_Hook' => '6.0.0', + 'OC_Image' => '6.0.0', + 'OC_JSON' => '6.0.0', + 'OC_L10N' => '6.0.0', + 'OC_Log' => '6.0.0', + 'OC_Mail' => '6.0.0', + 'OC_Preferences' => '6.0.0', + 'OC_Search_Provider' => '6.0.0', + 'OC_Search_Result' => '6.0.0', + 'OC_Request' => '6.0.0', + 'OC_Response' => '6.0.0', + 'OC_Template' => '6.0.0', + 'OC_User' => '6.0.0', + 'OC_Util' => '6.0.0', + ], $this->check->getClasses()); + } + + /** + * @return array + */ + public function getConstants() { + return $this->check->getConstants(); + } + + /** + * @return array + */ + public function getFunctions() { + return $this->check->getFunctions(); + } + + /** + * @return array + */ + public function getMethods() { + return $this->check->getMethods(); + } + + /** + * @return bool + */ + public function checkStrongComparisons() { + return $this->check->checkStrongComparisons(); + } +} diff --git a/lib/private/app/codechecker/privatelist.php b/lib/private/app/codechecker/privatelist.php deleted file mode 100644 index e44926ada77..00000000000 --- a/lib/private/app/codechecker/privatelist.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @author Morris Jobke - * @author Thomas Müller - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -namespace OC\App\CodeChecker; - -use OC\Hooks\BasicEmitter; -use PhpParser\Lexer; -use PhpParser\Node; -use PhpParser\Node\Name; -use PhpParser\NodeTraverser; -use PhpParser\Parser; -use RecursiveCallbackFilterIterator; -use RecursiveDirectoryIterator; -use RecursiveIteratorIterator; -use RegexIterator; -use SplFileInfo; - -class PrivateList implements ICheckList { - /** - * @return string - */ - public function getDescription() { - return 'private'; - } - - /** - * @return array - */ - public function getClasses() { - return [ - // classes replaced by the public api - 'OC_API', - 'OC_App', - 'OC_AppConfig', - 'OC_Avatar', - 'OC_BackgroundJob', - 'OC_Config', - 'OC_DB', - 'OC_Files', - 'OC_Helper', - 'OC_Hook', - 'OC_Image', - 'OC_JSON', - 'OC_L10N', - 'OC_Log', - 'OC_Mail', - 'OC_Preferences', - 'OC_Search_Provider', - 'OC_Search_Result', - 'OC_Request', - 'OC_Response', - 'OC_Template', - 'OC_User', - 'OC_Util', - ]; - } - - /** - * @return array - */ - public function getConstants() { - return []; - } - - /** - * @return array - */ - public function getFunctions() { - return []; - } - - /** - * @return array - */ - public function getMethods() { - return []; - } - - /** - * @return bool - */ - public function checkStrongComparisons() { - return false; - } -} diff --git a/lib/private/app/codechecker/strongcomparisoncheck.php b/lib/private/app/codechecker/strongcomparisoncheck.php new file mode 100644 index 00000000000..bfbde1acbef --- /dev/null +++ b/lib/private/app/codechecker/strongcomparisoncheck.php @@ -0,0 +1,78 @@ + + * @author Morris Jobke + * @author Thomas Müller + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OC\App\CodeChecker; + +class StrongComparisonCheck implements ICheck { + /** @var ICheck */ + protected $check; + + /** + * @param ICheck $check + */ + public function __construct(ICheck $check) { + $this->check = $check; + } + + /** + * @return string + */ + public function getDescription() { + return $this->check->getDescription(); + } + + /** + * @return array + */ + public function getClasses() { + return $this->check->getClasses(); + } + + /** + * @return array + */ + public function getConstants() { + return $this->check->getConstants(); + } + + /** + * @return array + */ + public function getFunctions() { + return $this->check->getFunctions(); + } + + /** + * @return array + */ + public function getMethods() { + return $this->check->getMethods(); + } + + /** + * @return bool + */ + public function checkStrongComparisons() { + return true; + } +} -- cgit v1.2.3