_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q12500 | MissingCommand.getOldLemmas | train | protected function getOldLemmas($file_lang_path, array $values = [])
{
if (!is_writable(dirname($file_lang_path))) {
$this->error(" > Unable to write file in directory " . dirname($file_lang_path));
die();
}
if (!file_exists($file_lang_path)) {
$this->info(" > File has been created");
}
if (!touch($file_lang_path)) {
$this->error(" > Unable to touch file {$file_lang_path}");
die();
}
if (!is_readable($file_lang_path)) {
$this->error(" > Unable to read file {$file_lang_path}");
die(); | php | {
"resource": ""
} |
q12501 | SqlEngineFactory.build | train | public static function build($pdo, $table)
{
$mapper = new | php | {
"resource": ""
} |
q12502 | MemberAddress.canCreate | train | public function canCreate($member = null)
{
if (!$member) {
$member = Member::currentUser();
}
$extended = $this->extendedCan('canCreate', $member);
| php | {
"resource": ""
} |
q12503 | Connector.login | train | public function login($username, $password)
{
// @ - intentionally, because false is enough
if (@ftp_login($this->stream, $username, $password)) {
$this->loggedIn = | php | {
"resource": ""
} |
q12504 | ImageProcessor.text | train | public function text($text, $fontFile, $size, array $rgb = array(0, 0, 0), $corner = self::IMG_CENTER_CORNER, $offsetX = 0, $offsetY = 0, $angle = 0)
{
$box = imagettfbbox($size, $angle, $fontFile, $text);
// Calculate width and height for the text
$height = $box[1] - $box[7];
$width = $box[2] - $box[0];
// Calculate positions according to corner's value
switch ($corner) {
case self::IMG_CENTER_CORNER:
$x = floor(($this->width - $width) / 2);
$y = floor(($this->height - $height) / 2);
break;
case self::IMG_LEFT_TOP_CORNER:
$x = $offsetX;
$y = $offsetY;
break;
case self::IMG_RIGHT_TOP_CORNER:
$x = $this->width - $width - $offsetX;
$y = $offsetY;
break;
case self::IMG_LEFT_BOTTOM_CORNER:
| php | {
"resource": ""
} |
q12505 | ImageProcessor.flip | train | public function flip($type)
{
// Initial positioning
$x = 0;
$y = 0;
// Save original dimensions
$width = $this->width;
$height = $this->height;
switch ($type) {
case self::IMG_FLIP_BOTH:
$x = $this->width - 1;
$y = $this->height - 1;
$width = -$this->width;
$height = -$this->height;
break;
case self::IMG_FLIP_HORIZONTAL:
$x = $this->width - 1;
$width = -$this->width;
break;
case self::IMG_FLIP_VERTICAL:
$y = $this->height - 1;
$height = -$this->height;
break;
default:
| php | {
"resource": ""
} |
q12506 | ImageProcessor.watermark | train | public function watermark($watermarkFile, $corner = self::IMG_RIGHT_BOTTOM_CORNER, $offsetX = 10, $offsetY = 10)
{
// The very first thing we gotta do is to load watermark's image file
$watermark = new ImageFile($watermarkFile);
// Initial positioning
$x = 0;
$y = 0;
// Walk through supported values
switch ($corner) {
case self::IMG_RIGHT_BOTTOM_CORNER:
$x = $this->width - $watermark->getWidth() - $offsetX;
$y = $this->height - $watermark->getHeight() - $offsetY;
break;
case self::IMG_RIGHT_TOP:
$x = $this->width - $watermark->getWidth() - $offsetX;
$y = $offsetY;
break;
case self::IMG_LEFT_CORNER:
$x = $offsetX;
$y = $offsetY;
break;
case self::IMG_LEFT_BOTTOM_CORNER:
$x = $offsetX;
| php | {
"resource": ""
} |
q12507 | ImageProcessor.blackwhite | train | public function blackwhite()
{
imagefilter($this->image, \IMG_FILTER_GRAYSCALE);
imagefilter($this->image, | php | {
"resource": ""
} |
q12508 | ImageProcessor.resize | train | public function resize($x, $y, $proportional = true)
{
// Check firstly values
if ($x === null || $x > $this->width) {
$x = $this->width;
}
if ($y === null || $y > $this->height) {
$y = $this->height;
}
if ($proportional === true) {
$height = $y;
$width = round($height / $this->height * $this->width);
if ($width < $x) {
$width = $x;
$height = round($width / $this->width * $this->height);
}
} else {
// When no proportionality required, then use target dimensions
$width = $x;
$height = $y;
}
// Done calculating. Create a new image in memory
| php | {
"resource": ""
} |
q12509 | ImageProcessor.crop | train | public function crop($width, $height, $startX = null, $startY = null)
{
if ($width === null) {
$width = $this->width;
}
if ($height === null) {
$height = $this->height;
}
if ($startX === null) {
$startX = floor(($this->width - $width) / 2);
}
if ($startY === null) {
$startY = floor(($this->height - $height) / 2);
}
// Calculate dimensions
$startX = max(0, min($this->width, $startX));
$startY = max(0, min($this->height, $startY));
$width = min($width, $this->width - $startX);
$height | php | {
"resource": ""
} |
q12510 | ImageProcessor.thumb | train | public function thumb($width, $height)
{
$this->resize($width, $height)
| php | {
"resource": ""
} |
q12511 | ImageProcessor.rotate | train | public function rotate($degrees)
{
// Cast to the int, in case we got a numeric string
$degrees = (int) $degrees;
$this->image = imagerotate($this->image, $degrees, 0);
| php | {
"resource": ""
} |
q12512 | ImageProcessor.preserveTransparency | train | private function preserveTransparency($image)
{
$transparencyColor = array(0, 0, 0);
switch ($this->type) {
case \IMAGETYPE_GIF:
$color = imagecolorallocate($image, $transparencyColor[0], $transparencyColor[1], $transparencyColor[2]);
imagecolortransparent($image, $color);
imagetruecolortopalette($image, false, 256);
break;
case \IMAGETYPE_PNG:
imagealphablending($image, false);
| php | {
"resource": ""
} |
q12513 | EventManager.attach | train | public function attach($event, Closure $listener)
{
if (!is_callable($listener)) {
throw new InvalidArgumentException(sprintf(
'Second argument must be callable not "%s"', gettype($listener)
| php | {
"resource": ""
} |
q12514 | EventManager.attachMany | train | public function attachMany(array $collection)
{
foreach ($collection as | php | {
"resource": ""
} |
q12515 | EventManager.detach | train | public function detach($event)
{
if ($this->has($event)) {
unset($this->listeners[$event]);
} else {
throw new RuntimeException(sprintf(
| php | {
"resource": ""
} |
q12516 | EventManager.hasMany | train | public function hasMany(array $events)
{
foreach ($events as $event) {
| php | {
"resource": ""
} |
q12517 | EnvTasks.envUp | train | public function envUp($opts = [
'native' => false,
'no-hostname' => false,
'no-browser' => false
])
{
$this->executeCommandHook(__FUNCTION__, 'before');
/** @var EngineType $engine */
$engine = $this->engineInstance();
if ($engine instanceof DockerEngineType) {
if ($opts['native']) {
$engine->disableDockerSync();
}
}
$status = $engine->up();
| php | {
"resource": ""
} |
q12518 | EnvTasks.envRebuild | train | public function envRebuild()
{
$this->executeCommandHook(__FUNCTION__, 'before');
$this->engineInstance()->rebuild();
$this->projectInstance()->rebuildSettings(); | php | {
"resource": ""
} |
q12519 | EnvTasks.envDown | train | public function envDown($opts = [
'include-network' => false,
])
{
$this->executeCommandHook(__FUNCTION__, 'before');
$this->engineInstance()->down($opts['include-network']);
// Allow projects to react to the engine shutdown.
$this->invokeEngineEvent('onEngineDown');
| php | {
"resource": ""
} |
q12520 | EnvTasks.envResume | train | public function envResume()
{
$this->executeCommandHook(__FUNCTION__, 'before');
| php | {
"resource": ""
} |
q12521 | EnvTasks.envRestart | train | public function envRestart()
{
$this->executeCommandHook(__FUNCTION__, 'before');
| php | {
"resource": ""
} |
q12522 | EnvTasks.envReboot | train | public function envReboot($opts = [
'include-network' => false,
])
{
$this->executeCommandHook(__FUNCTION__, 'before');
| php | {
"resource": ""
} |
q12523 | EnvTasks.envHalt | train | public function envHalt()
{
$this->executeCommandHook(__FUNCTION__, 'before');
| php | {
"resource": ""
} |
q12524 | EnvTasks.envInstall | train | public function envInstall()
{
$this->executeCommandHook(__FUNCTION__, 'before');
| php | {
"resource": ""
} |
q12525 | EnvTasks.envSsh | train | public function envSsh($opts = ['service' => null])
{
$this->executeCommandHook(__FUNCTION__, 'before');
$this->engineInstance()->ssh($opts['service']);
| php | {
"resource": ""
} |
q12526 | EnvTasks.envLogs | train | public function envLogs($opts = ['show' => 'all', 'follow' => false, 'service' => null])
{
$this->executeCommandHook(__FUNCTION__, 'before');
| php | {
"resource": ""
} |
q12527 | EnvTasks.envExec | train | public function envExec(array $execute_command, $opts = ['service' => null])
{
$this->executeCommandHook(__FUNCTION__, 'before');
$this->engineInstance()->exec(
implode(' ', $execute_command),
| php | {
"resource": ""
} |
q12528 | EnvTasks.addHostName | train | protected function addHostName($no_browser)
{
$host = ProjectX::getProjectConfig()
->getHost();
if (!empty($host)) {
$hostsfile = (new HostsFile())
->setLine('127.0.0.1', $host['name']);
(new HostsFileWriter($hostsfile))->add();
$this->say(
sprintf('Added %s to hosts file.', $host['name'])
);
| php | {
"resource": ""
} |
q12529 | EnvTasks.removeHostName | train | protected function removeHostName()
{
$host = ProjectX::getProjectConfig()
->getHost();
if (!empty($host)) {
$hostsfile = (new HostsFile())
->setLine('127.0.0.1', $host['name']);
(new HostsFileWriter($hostsfile))->remove();
| php | {
"resource": ""
} |
q12530 | EnvTasks.invokeEngineEvent | train | protected function invokeEngineEvent($method)
{
$project = $this->getProjectInstance();
if ($project instanceof EngineEventInterface) {
call_user_func_array([$project, $method], []);
}
$platform = $this->getPlatformInstance();
| php | {
"resource": ""
} |
q12531 | ModelDocument.setFile | train | public function setFile(UploadedFile $file = null)
{
$this->file = $file;
$this->name = $file->getClientOriginalName();
// check if we have an old image path
if (isset($this->path)) {
// store the old name to delete after the update | php | {
"resource": ""
} |
q12532 | ModuleManager.exists | train | public static function exists($string)
{
$instance = self::getInstance();
foreach ($instance->getModules() as $module) {
if ($module->title === | php | {
"resource": ""
} |
q12533 | ModuleManager.existsController | train | public static function existsController($key)
{
$instance = self::getInstance();
foreach ($instance->getModules() as $module) {
foreach ($module->getControllers() as $controller => $file) {
if | php | {
"resource": ""
} |
q12534 | ModuleManager.run | train | public function run($url = null, $method = null)
{
$request = new Request($method, $url);
try {
// foreach ($this->modules as $module) {
//
// }
Profiler::start('router');
if ($match = $this->router->match($url, $method)) {
if ($match['name'] === 'handleFilesystem') {
Profiler::stop('router');
return $this->handleFilesystem($match['params'], $request);
} else {
$target = $match['target'];
$module = $target[0];
if ($module instanceof Module) {
if ($this->isEnabled($module->title)) {
$this->runningModule = $module;
$controller = $target[1];
$request->setParams($match['params']);
Profiler::stop('router');
return $module->run($controller, $request);
} else {
Profiler::stop('router');
return $this->mainModule->run(new ErrorController("This module is disabled by your
policy"),
$request);
| php | {
"resource": ""
} |
q12535 | ModuleManager.getRoutes | train | public function getRoutes()
{
if ($this->config['app']['debug']) {
$html = '<pre>';
$result = array();
foreach ($this->modules as $module) {
$list = $module->getControllersUrlRoutes();
| php | {
"resource": ""
} |
q12536 | ModuleManager.handleFilesystem | train | public function handleFilesystem($args, $request)
{
$file = urldecode($args['name']);
$filesystem = new Filesystem($file);
if ($filesystem->exists()) {
if ($filesystem->isPublic()) {
header('Content-Type: ' . mime_content_type($filesystem->getAbsolutePath()));
| php | {
"resource": ""
} |
q12537 | ExtraAdminController.trashAction | train | public function trashAction()
{
if (false === $this->admin->isGranted('LIST')) {
throw new AccessDeniedException();
}
$em = $this->getDoctrine()->getManager();
$em->getFilters()->disable('softdeleteable');
$em->getFilters()->enable('softdeleteabletrash');
$em->getFilters()->getFilter("softdeleteabletrash")->enableForEntity($this->admin->getClass());
$datagrid = $this->admin->getDatagrid();
$formView = $datagrid->getForm()->createView();
// set the theme | php | {
"resource": ""
} |
q12538 | Paginator.formatToArrayStandard | train | function formatToArrayStandard($route = null,array $parameters = array()) {
$links = array(
'self' => array('href' => ''),
'first' => array('href' => ''),
'last' => array('href' => ''),
'next' => array('href' => ''),
'previous' => array('href' => ''),
);
$paginator = array(
'currentPage' => $this->getCurrentPage(),
| php | {
"resource": ""
} |
q12539 | Paginator.formatToArrayDataTables | train | function formatToArrayDataTables($route = null,array $parameters = array()) {
$results = $this->getCurrentPageResults()->getArrayCopy();
$data = array(
| php | {
"resource": ""
} |
q12540 | Paginator.toArray | train | function toArray($route = null,array $parameters = array(),$format = null) {
if($format === null){
$format = $this->defaultFormat;
| php | {
"resource": ""
} |
q12541 | Paginator.generateUrl | train | protected function generateUrl($route,array $parameters){
| php | {
"resource": ""
} |
q12542 | Paginator.getLinks | train | protected function getLinks($route,array $parameters = array()){
$links = array();
if($route != null){
$baseParams = $_GET;
unset($baseParams["page"]);
$parameters = array_merge($parameters,$baseParams);
$links['first']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => 1)));
$links['self']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => $this->getCurrentPage())));
$links['last']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => $this->getNbPages())));
if($this->hasPreviousPage()){ | php | {
"resource": ""
} |
q12543 | Paginator.setRequest | train | function setRequest(\Symfony\Component\HttpFoundation\Request $request) {
$this->request = $request;
if(self::FORMAT_ARRAY_DATA_TABLES == $this->defaultFormat){
//Ejemplo start(20) / length(10) = 2
$start = (int)$request->get("start",0);//Elemento inicio
$length = (int)$request->get("length",10);//Cantidad de elementos por pagina
$this->draw = $request->get("draw", $this->draw) + 1;//No cache
if($start > 0){
$page = (int)($start / $length);
$page = $page + 1;
}else{
$page = 1;
}
if(!is_int($length)){
$length = 10;
}
if(!is_int($page)){
$page = 1;
| php | {
"resource": ""
} |
q12544 | Filesystem.allocate | train | public static function allocate($filename = null, $extension = ".rnd", $folder = null)
{
if ($filename === null) {
$filename = sha1(time() . "_" . microtime(true));
}
if ($folder) {
| php | {
"resource": ""
} |
q12545 | Filesystem.getFilesystemFolder | train | public function getFilesystemFolder()
{
$config = Bootstrap::getSingleton()->getConfig();
if (isset($config['app']['filesystem'])) {
return Bootstrap::getSingleton()->getDirectory() . '/' . | php | {
"resource": ""
} |
q12546 | Filesystem.url | train | public function url($expires = null)
{
$this->setPublic($expires);
return | php | {
"resource": ""
} |
q12547 | PimpleDumper._writePHPStorm | train | protected function _writePHPStorm($map, $className)
{
$fileName = $this->_root . DIRECTORY_SEPARATOR . self::FILE_PHPSTORM;
if (is_dir($fileName)) {
$fileName .= DIRECTORY_SEPARATOR . 'pimple.meta.php';
}
$list = array();
foreach ($map as $data) {
if ($data['type'] === 'class') {
$list[] = " '{$data['name']}' instanceof {$data['value']},";
}
}
$tmpl = array(
'<?php',
'/**',
' * ProcessWire PhpStorm Meta',
' *',
' * This file is not a CODE, it makes no sense and won\'t run or validate',
' * Its AST serves PhpStorm IDE as DATA source to make advanced type inference decisions.',
' * ',
' * @see https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata',
' */',
'',
'namespace PHPSTORM_META {',
| php | {
"resource": ""
} |
q12548 | PimpleDumper._updateFile | train | protected function _updateFile($fileName, $content)
{
$oldContent = null;
if (file_exists($fileName)) {
$oldContent = file_get_contents($fileName);
}
| php | {
"resource": ""
} |
q12549 | ForwardableHandler.forwardMessage | train | public function forwardMessage($toChatId, bool $disableNotification = false): void
{
$m = $this->bot->forwardMessage();
$m->setChatId($toChatId);
$m->setFromChatId($this->message->getChat()->getId());
| php | {
"resource": ""
} |
q12550 | JsonStorage.load | train | public function load()
{
// Initial state, is always empty array
$data = array();
// Alter $data in case it exists and its valid
if ($this->storageAdapter->has($this->key)) {
$target = $this->serializer->unserialize($this->storageAdapter->get($this->key));
// If $target is null, then data either | php | {
"resource": ""
} |
q12551 | JsonStorage.save | train | public function save(array $data)
{
// This is what we're going to store
$seriaziledData = $this->serializer->serialize($data);
| php | {
"resource": ""
} |
q12552 | JsonStorage.clear | train | public function clear()
{
if ($this->storageAdapter->has($this->key)) {
| php | {
"resource": ""
} |
q12553 | FtpFactory.build | train | public static function build($host, $username = null, $password = null, $timeout = 90, $port = 21, $ssl = false)
{
$connector = new Connector($host, $timeout, $port, $ssl);
if (!$connector->connect()) {
throw new RuntimeException('Cannot connect to remote FTP server');
}
if ($username !== null && $password !== null) {
| php | {
"resource": ""
} |
q12554 | TableType.isColumn | train | protected function isColumn(ResolvedBlockTypeInterface $type)
{
if ('table_column' === $type->getBlockPrefix()) {
return true;
}
if (null !== | php | {
"resource": ""
} |
q12555 | SecurityHandler.checkSecurity | train | public function checkSecurity($rol,$parameters = null) {
if($rol === null){
throw $this->createAccessDeniedHttpException($this->trans($this->genericMessage));
}
$roles = $rol;
if(!is_array($rol)){
$roles = array($rol);
}
$valid = $this->getSecurityContext()->isGranted($roles,$parameters);
| php | {
"resource": ""
} |
q12556 | SecurityHandler.buildMessage | train | private function buildMessage($rol,$prefix = '403')
{
return $this->trans(sprintf('%s.%s.%s', | php | {
"resource": ""
} |
q12557 | SecurityHandler.setFlash | train | protected function setFlash($type,$message,$parameters = array(),$domain = 'flashes') | php | {
"resource": ""
} |
q12558 | AbstractImageManagerFactory.build | train | final public function build()
{
return new ImageManager($this->getPath(), | php | {
"resource": ""
} |
q12559 | DiggStyle.getPageNumbers | train | public function getPageNumbers(array $pages, $current)
{
$result = array();
$amount = count($pages);
$start = 3;
if ($amount > $start) {
// this specifies the range of pages we want to show in the middle
$min = max($current - 2, 2);
$max = min($current + 2, $amount - 1);
// we always show the first page
$result[] = 1;
// we're more than one space away from the beginning, so we need a separator
if ($min > 2) {
$result[] = '...';
}
// generate the middle numbers
for ($i = $min; $i < $max + 1; $i++) {
$result[] = $i;
}
// we're more than one space | php | {
"resource": ""
} |
q12560 | ControllerFactory.build | train | public function build($controller, $action, array $options)
{
$class = Ns::normalize($controller);
// PSR-0 Autoloader will do its own job by default when calling class_exists() function
if (class_exists($class)) {
// Target module which is going to be instantiated
$module = Ns::extractVendorNs($controller);
$controller = new $class($this->serviceLocator, $module, $options);
| php | {
"resource": ""
} |
q12561 | RoutesManager.getRoutesFromIndex | train | private function getRoutesFromIndex (&$routes, &$routesIndex, &$requestMethod, &$requestPathParts, $requestPathIndex = 0) {
if (!empty($requestPathParts[$requestPathIndex])) {
$requestPathPart = $requestPathParts[$requestPathIndex];
if (array_key_exists($requestPathPart, $routesIndex)) {
$this->getRoutesFromIndex($routes,$routesIndex[$requestPathPart], $requestMethod, $requestPathParts, $requestPathIndex + 1);
}
if (array_key_exists(self::ROUTE_PARAMETER_WILDCARD, $routesIndex)) {
$this->getRoutesFromIndex($routes,$routesIndex[self::ROUTE_PARAMETER_WILDCARD], $requestMethod, $requestPathParts, $requestPathIndex + 1);
}
}
else if (array_key_exists(self::ROUTE_ACTIONS_KEY, $routesIndex)) {
| php | {
"resource": ""
} |
q12562 | RoutesManager.getRoutesFromIndexActions | train | private function getRoutesFromIndexActions (&$routes, array &$routeActions, &$requestMethod, array &$requestPathParts) {
foreach ($routeActions as $routeData) {
$routePath = $routeData[0];
$routeAction = $routeData[1];
$routeParameters = [];
if (strpos($routePath, self::ROUTE_PARAMETER_PREFIX) !== false || strpos($routePath, self::ROUTE_GENERIC_PATH) !== false) {
$routePathParts = explode(self::ROUTE_PATH_SEPARATOR, trim($routePath, self::ROUTE_PATH_SEPARATOR));;
for ($i = 0; $i < sizeof($routePathParts); $i++) {
$routePathPart = $routePathParts[$i];
if ($routePathPart == self::ROUTE_GENERIC_PATH) {
$path = array_slice($requestPathParts, $i);
$routeParameters[self::ROUTE_PATH_PARAMETER_NAME] = $path;
break;
}
else if ($routePathPart[0] == self::ROUTE_PARAMETER_PREFIX) | php | {
"resource": ""
} |
q12563 | DynamicDoctrineChoiceLoader.getRealValues | train | protected function getRealValues(array $values, $value = null)
{
$value = $this->getCallableValue($value);
foreach ($values as | php | {
"resource": ""
} |
q12564 | GoogleTasks.listTasklists | train | public function listTasklists(
array $queryParameters = []
): array {
$parameters = [
'maxResults' => 100,
];
$parameters = array_merge($parameters, $queryParameters);
return $this
| php | {
"resource": ""
} |
q12565 | GoogleTasks.listTasks | train | public function listTasks(
string $taskListId,
Carbon $dueMin = null,
array $queryParameters = []
): array {
$parameters = [
'showCompleted' => false,
'showDeleted' => true,
'showHidden' => true,
| php | {
"resource": ""
} |
q12566 | GoogleTasks.getTask | train | public function getTask(string $taskId): Google_Service_Tasks
{
| php | {
"resource": ""
} |
q12567 | GoogleTasks.insertTask | train | public function insertTask($task): Google_Service_Tasks
{
if ($task instanceof Tasks) { | php | {
"resource": ""
} |
q12568 | GoogleTasks.deleteTask | train | public function deleteTask($taskId)
{
if ($taskId instanceof Tasks) {
| php | {
"resource": ""
} |
q12569 | Input.getFiles | train | public function getFiles($name = null)
{
if ($name !== null) {
if (!array_key_exists($name, $this->files)) {
throw new RuntimeException(sprintf(
| php | {
"resource": ""
} |
q12570 | Input.hydrateAll | train | private function hydrateAll(array $files)
{
foreach ($files as $name => $file) {
// Recursive protection
if (!is_array($file)) {
continue;
}
foreach ($file as $key => $value) | php | {
"resource": ""
} |
q12571 | Input.hydrate | train | private function hydrate(array $file)
{
$entity = new FileEntity();
$entity->setType($file['type'])
->setName($file['name'])
->setTmpName($file['tmp_name'])
| php | {
"resource": ""
} |
q12572 | Input.removeBrokenFiles | train | private function removeBrokenFiles(array $files)
{
// Recursive logic to replace broken arrays with empty ones (which to be removed later)
if (isset($files['error'])) {
return $files['error'] == 4 ? array() : $files;
}
foreach ($files as $key => $value) {
| php | {
"resource": ""
} |
q12573 | Routes.handleRequestNotFound | train | private static function handleRequestNotFound () {
$response = get_response();
$response->clear();
$response->statusCode(Response::HTTP_NOT_FOUND);
$notFoundRoutes = self::$notFoundRoutes->getRoutes();
if (!empty($notFoundRoutes)) {
foreach ($notFoundRoutes as $notFoundRoute) {
$routeResult = self::executeAction($notFoundRoute->getAction(), array_merge($_REQUEST, $notFoundRoute->getParameters()));
| php | {
"resource": ""
} |
q12574 | KernelFactory.build | train | public static function build(array $config)
{
$input = new Input();
$input->setQuery($_GET)
->setPost($_POST)
->setCookie($_COOKIE)
->setFiles($_FILES)
| php | {
"resource": ""
} |
q12575 | ThumbFactory.build | train | public function build($dir, $quality, array $options = array())
{
// Alter default quality on demand
if (isset($options['quality'])) {
| php | {
"resource": ""
} |
q12576 | SqlConfigService.store | train | public function store($module, $name, $value)
{
$this->initializeOnDemand();
if (!$this->has($module, $name)) {
if ($this->configMapper->insert($module, $name, $value)) {
$this->arrayConfig->add($module, $name, $value);
return true;
}
| php | {
"resource": ""
} |
q12577 | SqlConfigService.storeModule | train | public function storeModule($module, array $vars)
{
foreach ($vars as $key => $value) {
if (!$this->store($module, $key, $value)) { | php | {
"resource": ""
} |
q12578 | SqlConfigService.get | train | public function get($module, $name, $default = false)
{
$this->initializeOnDemand();
| php | {
"resource": ""
} |
q12579 | SqlConfigService.has | train | public function has($module, $name)
{
$this->initializeOnDemand();
return | php | {
"resource": ""
} |
q12580 | SqlConfigService.removeAll | train | public function removeAll()
{
$this->initializeOnDemand();
if ($this->configMapper->truncate()) {
$this->arrayConfig->clear();
| php | {
"resource": ""
} |
q12581 | SqlConfigService.remove | train | public function remove($module, $name)
{
$this->initializeOnDemand();
if ($this->exists($module, $name) && $this->configMapper->delete($module, | php | {
"resource": ""
} |
q12582 | SqlConfigService.removeAllByModule | train | public function removeAllByModule($module)
{
$this->initializeOnDemand();
if ($this->arrayConfig->hasModule($module) && | php | {
"resource": ""
} |
q12583 | GitAuthorExtractor.isDirtyFile | train | private function isDirtyFile($path, $git)
{
if (!\is_file($path)) {
return false;
}
$status = (array) $git->status()->short()->getIndexStatus();
$relPath = (string) \substr($path, (\strlen($git->getRepositoryPath()) + 1));
| php | {
"resource": ""
} |
q12584 | GitAuthorExtractor.getAuthorListFrom | train | private function getAuthorListFrom()
{
$filePath = $this->getFilePathCollection($this->currentPath);
$authors = [];
foreach ((array) $filePath['commits'] as $commit) {
if ($this->isMergeCommit($commit)
|| isset($authors[\md5($commit['name'])])
) {
continue;
}
$authors[\md5($commit['name'])] = $commit;
}
if (isset($filePath['pathHistory'])) {
foreach ((array) $filePath['pathHistory'] as $pathHistory) {
foreach ((array) $pathHistory['commits'] as $commitHistory) {
| php | {
"resource": ""
} |
q12585 | GitAuthorExtractor.collectFilesWithCommits | train | public function collectFilesWithCommits(GitRepository $git)
{
// git show --format="%H" --quiet
$lastCommitId = $git->show()->format('%H')->execute('--quiet');
$cacheId = \md5(__FUNCTION__ . $lastCommitId);
if ($this->cachePool->has($cacheId)) {
$fromCache = $this->cachePool->get($cacheId);
$this->commitCollection = $fromCache['commitCollection'];
$this->filePathMapping = $fromCache['filePathMapping'];
$this->filePathCollection = $fromCache['filePathCollection'];
return;
}
$commitCollection = [];
$filePathMapping = [];
$filePathCollection = [];
$this->prepareCommitCollection(
$git,
$this->fetchAllCommits($git, $lastCommitId),
$commitCollection,
$filePathMapping,
$filePathCollection
| php | {
"resource": ""
} |
q12586 | GitAuthorExtractor.prepareCommitCollection | train | private function prepareCommitCollection(
GitRepository $git,
array $logList,
array &$commitCollection,
array &$filePathMapping,
array &$filePathCollection
) {
foreach ($logList as $log) {
$currentCacheId = \md5(__FUNCTION__ . $log['commit']);
if ($this->cachePool->has($currentCacheId)) {
$fromCurrentCache = $this->cachePool->get($currentCacheId);
$commitCollection = \array_merge($filePathMapping, $fromCurrentCache['commitCollection']);
$filePathMapping = \array_merge($filePathMapping, $fromCurrentCache['filePathMapping']);
| php | {
"resource": ""
} |
q12587 | GitAuthorExtractor.prepareChangeCollection | train | private function prepareChangeCollection(
array $commit,
array $changeCollection,
array &$commitCollection,
array &$filePathMapping,
array &$filePathCollection
) {
foreach ($changeCollection as $change) {
if (!isset($commit['containedPath'])) {
$commit['containedPath'] = [];
}
if (!isset($commit['information'])) {
$commit['information'] = [];
}
if (isset($change['criteria'])) {
$changeToHash = \md5($change['to']);
$changeFromHash = \md5($change['from']);
| php | {
"resource": ""
} |
q12588 | GitAuthorExtractor.getFilePathCollection | train | private function getFilePathCollection($path)
{
$key = \array_flip($this->filePathMapping)[$path];
| php | {
"resource": ""
} |
q12589 | GitAuthorExtractor.setFilePathCollection | train | private function setFilePathCollection($path, array $data)
{
$key = \array_flip($this->filePathMapping)[$path]; | php | {
"resource": ""
} |
q12590 | GitAuthorExtractor.countMergeCommits | train | private function countMergeCommits(array $commitList)
{
$count = 0;
foreach ($commitList as $filePathCommit) {
| php | {
"resource": ""
} |
q12591 | GitAuthorExtractor.buildFileHistory | train | private function buildFileHistory(GitRepository $git)
{
$filePath = $this->getFilePathCollection($this->currentPath);
// If the commit history only merges,
// then use the last merge commit for find the renaming file for follow the history.
if (\count((array) $filePath['commits']) === $this->countMergeCommits($filePath['commits'])) {
$commit = $filePath['commits'][\array_reverse(\array_keys($filePath['commits']))[0]];
if ($this->isMergeCommit($commit)) {
$parents = \explode(' ', $commit['parent']);
$arguments = [
$git->getConfig()->getGitExecutablePath(),
'diff',
$commit['commit'],
$parents[1],
| php | {
"resource": ""
} |
q12592 | GitAuthorExtractor.getFileContent | train | private function getFileContent($search, GitRepository $git)
{
$cacheId = \md5(__FUNCTION__ . $search);
if (!$this->cachePool->has($cacheId)) {
$fileContent = $git->show()->execute($search);
| php | {
"resource": ""
} |
q12593 | GitAuthorExtractor.fetchNameStatusFromCommit | train | private function fetchNameStatusFromCommit($commitId, GitRepository $git)
{
$arguments = [
$git->getConfig()->getGitExecutablePath(),
| php | {
"resource": ""
} |
q12594 | GitAuthorExtractor.fetchCurrentCommit | train | private function fetchCurrentCommit(GitRepository $git)
{
return \json_decode(
\sprintf(
'[%s]',
// git show --format=$this->logFormat() --quiet
| php | {
"resource": ""
} |
q12595 | GitAuthorExtractor.fetchAllCommits | train | private function fetchAllCommits(GitRepository $git)
{
$currentCommit = $this->fetchCurrentCommit($git);
$cacheId = \md5(__FUNCTION__ . \serialize($currentCommit));
if (!$this->cachePool->has($cacheId)) {
$logList = \json_decode(
\sprintf(
'[%s]',
\trim(
// git log --simplify-merges --format=$this->logFormat()
| php | {
"resource": ""
} |
q12596 | GitAuthorExtractor.fetchFileHistory | train | private function fetchFileHistory($path, GitRepository $git)
{
$fileHistory = [];
foreach ($this->fetchCommitCollectionByPath($path, $git) as $logItem) {
// If the renaming/copy to not found in the file history, then continue the loop.
if (\count($fileHistory) && !\in_array($logItem['to'], $fileHistory)) {
continue;
}
// If the file history empty (also by the start for the detection) and the to path not exactly the same
| php | {
"resource": ""
} |
q12597 | GitAuthorExtractor.fetchCommitCollectionByPath | train | private function fetchCommitCollectionByPath($path, GitRepository $git)
{
// git log --follow --name-status --format='%H' -- $path
$log = $git->log()->follow()->revisionRange('--name-status')->revisionRange('--format=%H')->execute($path);
\preg_match_all(
"/^(?'commit'.*)\n+(?'criteria'[RC])(?'index'[\d]{3})\t(?'from'.+)\t(?'to'.+)\n/m",
$log,
$matches,
PREG_SET_ORDER
);
if (!\count($matches)) {
| php | {
"resource": ""
} |
q12598 | GitAuthorExtractor.executeFollowDetection | train | private function executeFollowDetection(array $logItem, array &$fileHistory, GitRepository $git)
{
$currentCommit = $this->commitCollection[$logItem['commit']];
if (($logItem['index'] <= 70) && \in_array($logItem['criteria'], ['R', 'C'])) {
if (isset($currentCommit['information'][\md5($logItem['to'])])) {
$pathInformation = $currentCommit['information'][\md5($logItem['to'])];
| php | {
"resource": ""
} |
q12599 | GitAuthorExtractor.renamingDetection | train | private function renamingDetection(array $logItem, array $currentCommit, array &$fileHistory, GitRepository $git)
{
if ($logItem['criteria'] !== 'R') {
return;
}
if ((int) $logItem['index'] >= 75) {
$fileHistory[\md5($logItem['from'])] = $logItem['from'];
return;
}
$fromFileContent = $this->getFileContent($currentCommit['parent'] . ':' . $logItem['from'], $git);
$toFileContent = $this->getFileContent($logItem['commit'] . ':' . $logItem['to'], $git);
$tempFrom =
$this->createTempFile($logItem['commit'] . ':' . $logItem['from'], $fromFileContent);
$tempTo | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.