_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q253000
Comment.deleteReply
validation
public function deleteReply($msgId, $index, $commentId) { $params = [ 'msg_data_id' => $msgId, 'index' => $index, 'user_comment_id' => $commentId,
php
{ "resource": "" }
q253001
Collection.getArray
validation
public static function getArray() { $object = new \ReflectionClass( Collection::class ); $properties = $object->getProperties(\ReflectionProperty::IS_PUBLIC); $array = array(); foreach ($properties as $property) {
php
{ "resource": "" }
q253002
Collection.set
validation
public static function set($property, $value = NULL) { $object = new \ReflectionClass( Collection::class );
php
{ "resource": "" }
q253003
Collection.get
validation
public static function get($property, $default = NULL) { $object = new \ReflectionClass( Collection::class ); $value = $object->getStaticPropertyValue($property);
php
{ "resource": "" }
q253004
IsPipeline.replace
validation
public function replace($needle, $replacement): Pipeline { $stages = []; $found = false; foreach ($this->stages as $stage) { if ($this->matches($stage, $needle)) { $stages[] = $replacement; $found = true; continue; } $stages[] = $stage;
php
{ "resource": "" }
q253005
IsPipeline.handleStage
validation
protected function handleStage(&$stages, $stage) { if ($stage instanceof Pipeline) { $stages = array_merge($stages, $stage->stages()); } elseif ($stage instanceof MiddlewareInterface) { $stages[] = $stage; } elseif ($stage instanceof RequestHandlerInterface) { $stages[] = new
php
{ "resource": "" }
q253006
Filter.remove
validation
public function remove(ExpressionContract $e) { unset($this->expressions[$this->indexOf($e)]); $this->expressions
php
{ "resource": "" }
q253007
Filter.indexOf
validation
public function indexOf($expressionOrColumn) { if ($expressionOrColumn instanceof ExpressionContract) {
php
{ "resource": "" }
q253008
SentinelReplication.wipeServerList
validation
protected function wipeServerList() { $this->reset(); $this->master = null;
php
{ "resource": "" }
q253009
SentinelReplication.updateSentinels
validation
public function updateSentinels() { SENTINEL_QUERY: { $sentinel = $this->getSentinelConnection(); try { $payload = $sentinel->executeCommand( RawCommand::create('SENTINEL', 'sentinels', $this->service) ); $this->se...
php
{ "resource": "" }
q253010
SentinelReplication.getConnectionByRole
validation
public function getConnectionByRole($role) { if ($role === 'master') { return $this->getMaster();
php
{ "resource": "" }
q253011
SentinelReplication.switchTo
validation
public function switchTo(NodeConnectionInterface $connection) { if ($connection && $connection === $this->current) { return; } if ($connection !== $this->master && !in_array($connection, $this->slaves, true)) { throw new \InvalidArgumentException('Invalid connection ...
php
{ "resource": "" }
q253012
SentinelReplication.retryCommandOnFailure
validation
private function retryCommandOnFailure(CommandInterface $command, $method) { $retries = 0; SENTINEL_RETRY: { try { $response = $this->getConnectionByCommand($command)->$method($command); } catch (CommunicationException $exception) { $this->wip...
php
{ "resource": "" }
q253013
ModuleDependencyResolver.resolve
validation
public function resolve() : array { try{ $app_required_modules = array_unique($this->required_modules); // get component dependency map $component_dependency_map = $this->getComponentDependencyMap($app_required_modules); // resolve component dependency ...
php
{ "resource": "" }
q253014
ModuleDependencyResolver.findComponentModuleByType
validation
private function findComponentModuleByType(array $module_list, string $find_component_type) { foreach($module_list as $m) { $component_type = call_user_func([$m, 'declareComponentType']);
php
{ "resource": "" }
q253015
CalcDef.getMaxPercentForPersonalBonus
validation
private function getMaxPercentForPersonalBonus($levels) { $result = 0; foreach ($levels as $percent)
php
{ "resource": "" }
q253016
Site.getIsEnabled
validation
protected function getIsEnabled(): \Illuminate\Database\Eloquent\Model {
php
{ "resource": "" }
q253017
CliQuestion.getHelper
validation
public function getHelper() { if ($this->helper === null) {
php
{ "resource": "" }
q253018
LinkedCustomFieldsType.appendChoice
validation
public function appendChoice(FormEvent $event) { $rootForm = $this->getRootForm($event->getForm()); $group = $rootForm->getData(); if ($group === NULL) { return; } $choices = array(); foreach($group->getCustomFields() as $customFields) { ...
php
{ "resource": "" }
q253019
StartFromThemeController.startAction
validation
public function startAction(Request $request, Application $app) { $options = array( "request" =>
php
{ "resource": "" }
q253020
HelperMakeCommand.buildClass
validation
protected function buildClass($name) { $stub = $this->files->get($this->getStub());
php
{ "resource": "" }
q253021
EntityDbMapper.fromDbToEntity
validation
public function fromDbToEntity(array $data) { $hydratorFactory = $this->documentManager->getHydratorFactory(); $documentClass = $this->documentClass;
php
{ "resource": "" }
q253022
EntityDbMapper.fromEntityToDb
validation
public function fromEntityToDb($document) { $unitOfWork = $this->documentManager->getUnitOfWork(); $persistenceBuilder = new PersistenceBuilder($this->documentManager, $unitOfWork); $mapping = array (
php
{ "resource": "" }
q253023
ExtendableCollectionBlock.generateSourceFromChildren
validation
protected function generateSourceFromChildren() { $i = 1; $children = array(); foreach ($this->children as $child) { $childValue = Yaml::parse($child->getSource()); if (is_array($childValue) && array_key_exists("type", $childValue)) { $childValue["type...
php
{ "resource": "" }
q253024
Page.add
validation
public function add($title, $description, $pageUrl, $iconUrl, $comment = '') { $params = [ 'title' => $title, 'description' => $description, 'page_url' => $pageUrl, 'icon_url' => $iconUrl,
php
{ "resource": "" }
q253025
Page.update
validation
public function update($pageId, $title, $description, $pageUrl, $iconUrl, $comment = '') { $params = [ 'page_id' => intval($pageId), 'title' => $title, 'description' => $description, 'page_url' => $pageUrl,
php
{ "resource": "" }
q253026
Page.pagination
validation
public function pagination($begin, $count) { $params = [ 'type' => 2, 'begin' => intval($begin), 'count'
php
{ "resource": "" }
q253027
Page.delete
validation
public function delete($pageId) { $params = [ 'page_id' => intval($pageId), ];
php
{ "resource": "" }
q253028
Date.getAgeByDate
validation
public static function getAgeByDate(string $sBirthday) : int { list($iYear, $iMonth, $iDay) = preg_split('/[-.]/', $sBirthday); $aToday = array(); $aToday['mois'] = date('n'); $aToday['jour'] = date('j'); $aToday['annee'] = date('Y'); $iYears = $aToday['annee'] - $i...
php
{ "resource": "" }
q253029
Tv.updateTv
validation
private function updateTv($dwnl) { $entity = new EBonDwnl(); /** @var EBonDwnl $one */ foreach ($dwnl as $one) { $tv = $one->getTv(); $calcId = $one->getCalculationRef(); $custId = $one->getCustomerRef(); $entity->setTv($tv);
php
{ "resource": "" }
q253030
ElFinderFilesController.filesAction
validation
public function filesAction(Request $request, Application $app) { $options = array(
php
{ "resource": "" }
q253031
MimeMessage.clear
validation
public function clear($name = null) { if (!is_null($name)) { $name = strtolower($name); if (array_key_exists($name, self::$clearings)) { $this->{$name} = self::$clearings[$self::$clearings]; }
php
{ "resource": "" }
q253032
MimeMessage.setFrom
validation
public function setFrom($mail = '', $name = null, $reply = true) { $mail = trim($mail); if (strlen($mail) && Helper::isEmail($mail)) { $this->from = !empty($name) ? array($name=>$mail) : array($mail); $this->getMailer()->setRegistry('Return-Path', '<'.$mail.'>', 'headers');
php
{ "resource": "" }
q253033
MimeMessage.setTo
validation
public function setTo($mail = '', $name = null) { $this->to = Helper::deduplicate(
php
{ "resource": "" }
q253034
MimeMessage.setCc
validation
public function setCc($mail = '', $name = null) { $this->cc = Helper::deduplicate(
php
{ "resource": "" }
q253035
MimeMessage.setBcc
validation
public function setBcc($mail = '', $name = null) { $this->bcc = Helper::deduplicate(
php
{ "resource": "" }
q253036
MimeMessage.setAttachment
validation
public function setAttachment($file = '', $clear = false) { if (true===$clear) { $this->clear('text'); } if (is_array($file)) { foreach ($file as $_f) { if (file_exists($_f)) { $this->attachment[] = $_f; }
php
{ "resource": "" }
q253037
MimeMessage.setSubject
validation
public function setSubject($subject = '', $clear = false) { if (true===$clear) { $this->clear('subject');
php
{ "resource": "" }
q253038
MimeMessage.setText
validation
public function setText($text = '', $clear = false) { if (true===$clear) { $this->clear('text'); } if ('auto'==$text) { if (!empty($this->html)) { $html_content = preg_replace("/.*<body[^>]*>|<\/body>.*/si", "", $this->html); $this->tex...
php
{ "resource": "" }
q253039
MimeMessage.setHtml
validation
public function setHtml($html = '', $clear = false) { if (true===$clear) {
php
{ "resource": "" }
q253040
MimeMessage.setReplyTo
validation
public function setReplyTo($mail = '', $name = null) { if (strlen($mail) && Helper::isEmail($mail)) { if (!empty($name)) { $_m = Helper::mailTagger($mail, $name); } else {
php
{ "resource": "" }
q253041
MimeMessage.substitution
validation
public function substitution($search, $replace) { $this->body = str_replace($search, $replace,
php
{ "resource": "" }
q253042
Main.hookTemplateRender
validation
public function hookTemplateRender($templates, $data, $rendered, $controller) { $template = reset($templates); if (strpos($template, '/modules/ga_report/templates/panels/') !== false && isset($data['content']['data']['report']['data']) && isset($data['content']['data']['hand...
php
{ "resource": "" }
q253043
Setup.import
validation
public static function import($name) { $importPath = FOREVERPHP_ROOT . DS . $name . '.php'; if (file_exists($importPath)) { include_once $importPath; } else {
php
{ "resource": "" }
q253044
Setup.importFromApp
validation
public static function importFromApp($path) { $importPath = APPS_ROOT . DS . $path . '.php'; if (file_exists($importPath)) {
php
{ "resource": "" }
q253045
Builder.isRelation
validation
public function isRelation($key) { if(!method_exists($this->model, $key)) {
php
{ "resource": "" }
q253046
Builder.get
validation
public function get($columns = array('*')) { $columnsPassed = (func_num_args() > 1); $columns = $columnsPassed ? $columns : $this->getQueryColumns(); $query = $this->buildQuery($columns); if (!$columnsPassed) { // addJoinOnce adds queryColumns again...
php
{ "resource": "" }
q253047
Builder.chunk
validation
public function chunk($count, callable $callback){
php
{ "resource": "" }
q253048
Builder.lists
validation
public function lists($column, $key = null){
php
{ "resource": "" }
q253049
Builder.paginate
validation
public function paginate($perPage = null, $columns = array('*')) { $columnsPassed = (func_num_args() > 1) && ($columns !== null); $columns = $columnsPassed ? $columns : $this->getQueryColumns(); $query = $this->buildQuery($columns); if ($columnsPassed) {
php
{ "resource": "" }
q253050
DataItem.fillRelationConfig
validation
protected function fillRelationConfig(&$config, $otherObject) { if (isset($config['parent_object_id'])) { $config['child_object_id'] = $otherObject;
php
{ "resource": "" }
q253051
DataItem.loadForeignObject
validation
protected function loadForeignObject() { if ($this->_isLoadingForeignObject) { throw new RecursionException('Ran into recursion while loading foreign object'); } $this->_isLoadingForeignObject = true; if (isset($this->deferredModel) && ($attributes = $this->deferredModel-...
php
{ "resource": "" }
q253052
DataItem.loadLocalObject
validation
protected function loadLocalObject() { if ($this->_isLoadingLocalObject) { throw new RecursionException('Ran into recursion while loading local object'); } $this->_isLoadingLocalObject = true; if (isset($this->foreignObject) && !isset($this->_localObject))
php
{ "resource": "" }
q253053
Benchmark.setPointInLog
validation
public static function setPointInLog(string $sName = 'default') { $oLogger = Debug::getInstance(); $oLogger->info('BENCHMARK:
php
{ "resource": "" }
q253054
Material.lists
validation
public function lists($type, $offset = 0, $count = 20) { $params = [ 'type' => $type,
php
{ "resource": "" }
q253055
Install.step1
validation
protected function step1(){ //this is step 1; $this->view->addToBlock("form", "import://admin/setup/license"); $this->view->setData("step", "1");
php
{ "resource": "" }
q253056
Install.step2
validation
protected function step2(){ $this->view->addToBlock("form", "import://admin/setup/requirements"); $this->view->setData("step", "2"); $this->view->setData("title", t("Installation | Requirements")); $systemcheck = new Helpers\Requirements(); $requirements = []; $directiv...
php
{ "resource": "" }
q253057
Install.step3
validation
protected function step3(){ $this->view->addToBlock("form", "import://admin/setup/database"); $this->view->setData("step", "3"); $this->view->setData("randomstring", getRandomString('5')."_");
php
{ "resource": "" }
q253058
Install.step4
validation
protected function step4(){ //this is step 1; $this->view->addToBlock("form", "import://admin/setup/user"); $this->view->setData("step", "4"); $this->view->setData("title", t("Installation | Install SuperUser")); if ($this->application->input->methodIs("post")) { ...
php
{ "resource": "" }
q253059
IncludeComponentTrait.setServiceLocator
validation
public function setServiceLocator(ServiceLocatorInterface $serviceLocator) { $this->serviceLocator = $serviceLocator; $config = $serviceLocator->getServiceLocator()->get('config');
php
{ "resource": "" }
q253060
SampleBootstrap.addAppDependencies
validation
public function addAppDependencies() { /** * @var \Pimple\Container $container */ $container = $this->getContainer();
php
{ "resource": "" }
q253061
ListTable.cell_default
validation
public function cell_default($item, $column) { $ret = $this->val($item, $column);
php
{ "resource": "" }
q253062
ListTable.prepare_items
validation
function prepare_items() { $this->columns = array( $this->get_columns(), $this->get_hidden_columns(), $this->get_sortable_columns() );
php
{ "resource": "" }
q253063
ListTable.render_admin_header
validation
public function render_admin_header() { //$page = (isset($_GET['page'])) ? esc_attr($_GET['page']) : false; $page = filter_input(INPUT_GET, 'page'); if ($this->page != $page) { return; }
php
{ "resource": "" }
q253064
Stack.replace
validation
public function replace($middleware, $with) { $this->pipeline
php
{ "resource": "" }
q253065
Bomifier.detect
validation
public function detect() { $str = file_get_contents($this->uri); foreach ($this->getBom('all') as $encoding => $bom) { if
php
{ "resource": "" }
q253066
Bomifier.add
validation
public function add($encoding = 'UTF-8') { $str = file_get_contents($this->uri); return
php
{ "resource": "" }
q253067
Bomifier.remove
validation
public function remove($encoding) { $str = file_get_contents($this->uri); return
php
{ "resource": "" }
q253068
Bomifier.getBom
validation
public function getBom($encoding = 'UTF-8') { $boms = array( 'UTF-8' => pack('CCC', 0xef, 0xbb, 0xbf), 'UTF-16 Big Endian' => pack('CC', 0xfe, 0xff), 'UTF-16 Little Endian' => pack('CC', 0xff, 0xfe), 'UTF-32 Big Endian' => pack('CCCC', 0x0...
php
{ "resource": "" }
q253069
Bomifier.setUri
validation
public function setUri($uri) { if (!empty($uri) && !is_file($uri)) { throw new \Exception(sprintf('File
php
{ "resource": "" }
q253070
TaggedCollection.getByTag
validation
public function getByTag($tag) { $taggings = $this->getTaggings(); if (array_key_exists($tag, $taggings)) {
php
{ "resource": "" }
q253071
TaggedCollection.expand
validation
protected function expand() { foreach ($this as $key => $item) { $item['slug'] = $key; if (isset($item['date'])) {
php
{ "resource": "" }
q253072
Container.create
validation
public static function create($command, $app) { static $cache = []; $cacheKey = $command; if (isset($cache[$cacheKey])) { $class = $cache[$cacheKey]['class']; $command = $cache[$cacheKey]['command']; } else { if (false === strpos($command, '.')) ...
php
{ "resource": "" }
q253073
CacheConfigListener.getCache
validation
public function getCache() { if (! $this->cache) { $services = $this->getServices(); $cache = $services->get('Cache');
php
{ "resource": "" }
q253074
CacheConfigListener.doRestore
validation
public function doRestore(ModulesEvent $event) { $cache = $this->getCache(); $data = $cache->get('config'); if ($data) { $services = $this->getServices();
php
{ "resource": "" }
q253075
CacheConfigListener.doStore
validation
public function doStore(ModulesEvent $event) { $cache = $this->getCache();
php
{ "resource": "" }
q253076
UserRepository.save
validation
public function save(IUser $user): bool { if (!$user instanceof Entity) { return false;
php
{ "resource": "" }
q253077
Group.addAction
validation
public function addAction(AbstractAction $action) { $action->setGroup($this);
php
{ "resource": "" }
q253078
IdentityAsset.getLogo
validation
public function getLogo($size = null) { if (!$this->logoPath || !file_exists($this->logoPath)) { return; } $cacheLogo = $this->sizeImageCache($this->logoPath,
php
{ "resource": "" }
q253079
Cache.set
validation
public function set($key, $value) { if ($this->cacheEnabled) {
php
{ "resource": "" }
q253080
ImageTool.convert2Jpeg
validation
public static function convert2Jpeg($inputImg, $savePath = null, $quality = null, array $exifData = null) { $retval = false; $img = self::imgCreate($inputImg); $imgSize = self::size($img); $jpegImg = imagecreatetruecolor($imgSize[0], $imgSize[1]); imagecopy($jpegImg, $img, 0, 0, 0, 0, $imgSize[0], $imgSize[1...
php
{ "resource": "" }
q253081
ImageTool.size
validation
public static function size($inputImg) { if (is_string($inputImg)) $img = self::imgCreate($inputImg); else $img = $inputImg; $imgW = imagesx($img); $imgH =
php
{ "resource": "" }
q253082
Grid.extractInput
validation
private function extractInput() { $params = $this->request->getParams(); $period = $params[self::REQ_PERIOD] ?? ''; if (empty($period)) { $period = $this->hlpPeriod->getPeriodCurrent(null, 0, HPeriod::TYPE_MONTH); } else { $period = $this->hlpPeriod->normalize...
php
{ "resource": "" }
q253083
Grid.getBind
validation
private function getBind() { [$dsBegin, $treeType] = $this->extractInput(); $calcId = $this->getCalcId($dsBegin, $treeType); $bind = [
php
{ "resource": "" }
q253084
Grid.getCalcId
validation
private function getCalcId($dsBegin, $treeType) { $codeRegular = $codeForecast = ''; if ($treeType == OptionTreeType::VAL_PLAIN) { $codeRegular = Cfg::CODE_TYPE_CALC_PV_WRITE_OFF; $codeForecast = Cfg::CODE_TYPE_CALC_FORECAST_PLAIN; } elseif ($treeType == OptionTreeTyp...
php
{ "resource": "" }
q253085
LoadPeople.addAPerson
validation
private function addAPerson(array $person, ObjectManager $manager) { $p = new Person(); foreach ($person as $key => $value) { switch ($key) { case 'CountryOfBirth': case 'Nationality': $value = $this->getCountry($value); ...
php
{ "resource": "" }
q253086
LoadPeople.getRandomAddress
validation
private function getRandomAddress() { return (new Address()) ->setStreetAddress1($this->faker->streetAddress) ->setStreetAddress2( rand(0,9) > 5 ? $this->faker->streetAddress : '' ) ->se...
php
{ "resource": "" }
q253087
Benri_Db_Table_Row.reset
validation
final public function reset($column) { if ($this->isDirty($column)) {
php
{ "resource": "" }
q253088
Benri_Db_Table_Row.save
validation
final public function save() { $this->checkReadOnly(); /* * Allows pre-save logic to be applied to any row. * * Zend_Db_Table_Row only uses to do it on _insert OR _update, * here we can use the very same rules to be applied in both methods. */ $t...
php
{ "resource": "" }
q253089
Benri_Db_Table_Row.checkReadOnly
validation
private function checkReadOnly() { if (true === $this->_readOnly) { $this->_pushError( '', self::ERR_READ_ONLY,
php
{ "resource": "" }
q253090
SettingsProvider.getSettingsFromRealSource
validation
protected function getSettingsFromRealSource($namespace) { $arraySettings = $this->getSettingsArray($namespace); $namespaceOptions = $this->options->getNamespaceOptions($namespace); $entity = clone($namespaceOptions->getEntityPrototype()); if (!empty($arraySettings)) { $h...
php
{ "resource": "" }
q253091
XmlRpcBuilder.createFault
validation
public static function createFault($code, $message) { $response = new \SimpleXMLElement("<methodResponse></methodResponse>"); $struct = $response->addChild("fault")->addChild("value")->addChild("struct"); $member = $struct->addChild("member"); $member->addChild("name", "faultCode");...
php
{ "resource": "" }
q253092
Home.show
validation
public function show() { $response = new \Venus\lib\Response(); $response->setContent('<html><body><h1>Hello
php
{ "resource": "" }
q253093
AbstractWebCtrl.setLayout
validation
protected function setLayout(string $layoutName): void { if (is_null($this->view)) { throw new Exception("It's unable to set Layout without View.");
php
{ "resource": "" }
q253094
AbstractWebCtrl.redirect
validation
protected function redirect(string $uri, bool $isPermanent = false): void { $nCode = $isPermanent ? 301 : 302; Headers::getInstance()
php
{ "resource": "" }
q253095
Request.getHeader
validation
public function getHeader(string $name): ?string { $name = strtolower($name); foreach ($this->getAllHeaders() as $key => $value) { if
php
{ "resource": "" }
q253096
Request.getUrlPath
validation
public function getUrlPath(): ?string { $uri = $this->getServerParam('REQUEST_URI', \FILTER_SANITIZE_URL); if (!is_null($uri)) {
php
{ "resource": "" }
q253097
Request.isAjax
validation
public function isAjax(): bool { $param = $this->getServerParam('HTTP_X_REQUESTED_WITH', \FILTER_SANITIZE_STRING);
php
{ "resource": "" }
q253098
ControllerCookiesTrait.removeCookie
validation
private function removeCookie( $cookie, \Psr\Http\Message\ResponseInterface $response
php
{ "resource": "" }
q253099
DataItem.getHandler
validation
public function getHandler() { if ($this->pairedDataItem) { if (!isset($this->primaryObject)) { return $this->pairedDataItem;
php
{ "resource": "" }