_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q266200
Journal.addSuccess
test
public function addSuccess($time) { $total = ( $this->data['avg'] * $this->data['works'] ) + $time; $this->data['works']++;
php
{ "resource": "" }
q266201
Journal.addIdle
test
public function addIdle() { $time = microtime(true) - $this->idleSince; $this->idleSince
php
{ "resource": "" }
q266202
Account.getAmountEstimated
test
public function getAmountEstimated() { $accountsVirtual = $this->getAllAccountsVirtual(); $amount = 0.0; foreach ($accountsVirtual as $account) {
php
{ "resource": "" }
q266203
Route.getRequestMethods
test
public function getRequestMethods(): array { if (null === $this->requestMethods) { $this->requestMethods = [
php
{ "resource": "" }
q266204
DisableAutoUpdateHandler.disableWpAutoUpdate
test
protected function disableWpAutoUpdate() { $this->wpMockery->addFilter('automatic_updater_disabled', '__return_true'); $this->wpMockery->addFilter('allow_minor_auto_core_updates', '__return_false'); $this->wpMockery->addFilter('allow_major_auto_core_updates', '__return_false'); $this->wpMockery->addFilter('allow_dev_auto_core_updates', '__return_false'); $this->wpMockery->addFilter('auto_update_core', '__return_false'); $this->wpMockery->addFilter('wp_auto_update_core', '__return_false'); $this->wpMockery->addFilter('send_core_update_notification_email', '__return_false'); $this->wpMockery->addFilter('auto_update_translation', '__return_false'); $this->wpMockery->addFilter('auto_core_update_send_email', '__return_false'); $this->wpMockery->addFilter('auto_update_plugin', '__return_false');
php
{ "resource": "" }
q266205
DisableAutoUpdateHandler.blockWpRequest
test
public function blockWpRequest($pre, $args, $url) { if (empty($url)) { return $pre; } /* Invalid host */ if (!$host = $this->wpMockery->parseUrl($url, PHP_URL_HOST)) { return $pre; } $urlData = $this->wpMockery->parseUrl($url); /* block request */
php
{ "resource": "" }
q266206
DisableAutoUpdateHandler.hideAdminNag
test
protected function hideAdminNag() { if (!function_exists("remove_action")) { return; } /** * Hide maintenance and update nag */ $this->wpMockery->removeAction('admin_notices', 'update_nag', 3); $this->wpMockery->removeAction('network_admin_notices', 'update_nag', 3);
php
{ "resource": "" }
q266207
Quadrilateral.isValidPoint
test
public function isValidPoint(PointInterface $a) { return (bool) ( $this->getSegmentAB()->isValidPoint($a) || $this->getSegmentBC()->isValidPoint($a) ||
php
{ "resource": "" }
q266208
Quadrilateral.isParallelogram
test
public function isParallelogram() { $centerdiag1 = $this->getFirstDiagonal(); $centerdiag2 = $this->getSecondDiagonal();
php
{ "resource": "" }
q266209
Descendable.get
test
public function get($composite_key, $default_value = null) { $array_keys = explode($this->separator, $composite_key); $container = $this->container; foreach ($array_keys as $key) { if (!$this->hasChild($container, $key)) {
php
{ "resource": "" }
q266210
Descendable.has
test
public function has($composite_key) { $array_keys = explode($this->separator, $composite_key); $container = $this->container; foreach ($array_keys as $key) { if (!$this->hasChild($container, $key)) {
php
{ "resource": "" }
q266211
ApplicationManager.find
test
public function find($id) { $application = $this->repository->find($id); if (null == $application) { return null; } // Load tests
php
{ "resource": "" }
q266212
ApplicationManager.findAll
test
public function findAll() { $applications = array(); foreach ($this->repository->findAll() as $application) { // Load tests
php
{ "resource": "" }
q266213
NumberSystem.equals
test
public function equals(NumberSystem $comparedNumberSystem) { if ($this->getBase() !== $comparedNumberSystem->getBase() ||
php
{ "resource": "" }
q266214
NumberSystem.getDigits
test
public function getDigits(Number $number) { if (null === $this->delimiter) { return str_split($number->value());
php
{ "resource": "" }
q266215
NumberSystem.buildNumber
test
public function buildNumber(array $digits) { $newNumberString = implode($this->delimiter, $digits);
php
{ "resource": "" }
q266216
NumberSystem.validateNumberValue
test
public function validateNumberValue($value) { if (null === $this->delimiter) { $parts = str_split($value); } else { $parts = explode($this->delimiter, $value); } foreach ($parts as $numberSymbol) {
php
{ "resource": "" }
q266217
PHPRedis.makeCall
test
public function makeCall($name, array $arguments = []) { if (!$this->connected) { $this->_connect(); } // ignore connect commands if (in_array($name, ['connect', 'pconnect'])) { return; } $log = true; switch (strtolower($name)) { case 'open': case 'popen': case 'close': case 'setoption': case 'getoption': case 'auth': case 'select': $log = false; break; } $ts = microtime(true); $result = call_user_func_array('parent::'.$name, $arguments); $ts = (microtime(true) - $ts) * 1000; $isError = false; if ($error = $this->getLastError()) { $this->clearLastError();
php
{ "resource": "" }
q266218
PHPRedis.generateKey
test
public function generateKey($kp) { $arguments = func_get_args(); if
php
{ "resource": "" }
q266219
PHPRedis._connect
test
private function _connect($bailOnError = false) { $this->connected = $this->connect( $this->parameters['host'], $this->parameters['port'], ($this->parameters['timeout'] ?: 0) ); if ($this->connected) { if ($this->parameters['auth']) { $this->auth($this->parameters['auth']); } if ($this->select($this->parameters['database'])) { // setup default options $this->setOption(\Redis::OPT_PREFIX, $this->parameters['prefix']); $this->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP); return true;
php
{ "resource": "" }
q266220
PHPRedis.getCommandString
test
private function getCommandString($command, array $arguments) { $list = []; foreach ($arguments as $argument) {
php
{ "resource": "" }
q266221
MongoEventStore.getMongoDocument
test
protected function getMongoDocument(DomainEventMessageInterface $domainEventMessage): array { $payload = $this ->getSerializer() ->serialize($domainEventMessage->getPayload()); return [ 'aggregate_id' => $domainEventMessage->getAggregateId(), 'sequence' => $domainEventMessage->getSequence(), 'occurred_on' => new UTCDateTime( $domainEventMessage ->getOccurredOn()
php
{ "resource": "" }
q266222
MongoEventStore.getDomainEventMessage
test
protected function getDomainEventMessage(array $document): DomainEventMessageInterface { $payload = $this ->getSerializer() ->unserialize(new SerializedObject( $document['payload']['name'],
php
{ "resource": "" }
q266223
Base.reset
test
public function reset() { unset($this->entity); unset($this->entities); unset($this->forms); unset($this->valid); unset($this->params); $this->setOperation(self::OPERATION_NONE);
php
{ "resource": "" }
q266224
Base.normalizeMessages
test
protected function normalizeMessages($messages) { $queue = array(); foreach ($messages as $key => $value) { if (is_array($value) && count($value))
php
{ "resource": "" }
q266225
Base.postValidate
test
protected function postValidate($valid, Params $params, $options = array()) { if ($valid) { foreach ($this->getEntities() as $tag => $entity) { $this->em()->persist($entity); }
php
{ "resource": "" }
q266226
Base.formDataEvent
test
protected function formDataEvent($tag, $callable = null) { $this->getEventManager()->attach(self::EVENT_FORM_DATA.$tag, function ($event) use ($callable) { $eventParams = $event->getParams(); /* @var $form \Zend\Form\Form */
php
{ "resource": "" }
q266227
Base.getForms
test
public function getForms() { if (!isset($this->forms)) { $forms = array(); $entities = $this->getEntities(); // set up any connections $this->beforeFormGeneration($entities); foreach ($entities as $tag => $entity) { /* @var $form \Zend\Form\Form */ $form = $this->entityToForm($entity); $this->getEventManager() ->trigger(self::EVENT_CONFIGURE_FORM.$tag, $this, array(
php
{ "resource": "" }
q266228
Base.removeStringFromArray
test
protected function removeStringFromArray(&$list, $value) { $index = array_search($value, $list); if ($index !== false) {
php
{ "resource": "" }
q266229
Base.getEntities
test
final public function getEntities() { if (!isset($this->entities)) { $this->entities = array(); $entities = $this->generateEntities(); $entities[static::MAIN_TAG] = $this->getEntity(); /* @var $entity \FzyCommon\Entity\BaseInterface */ foreach ($entities as $tag => $entity) { $this->getEventManager() ->trigger(self::EVENT_CONFIGURE_ENTITY.$tag, $this, array( 'tag' => $tag,
php
{ "resource": "" }
q266230
Base.swapEntity
test
final public function swapEntity($tag, BaseInterface $entity) { if (!isset($this->entities[$tag])) { throw new \RuntimeException("Unable to swap entity that does not exist"); } $this->entities[$tag] = $entity;
php
{ "resource": "" }
q266231
Base.configureFormToExcludeData
test
public function configureFormToExcludeData($tag, array $elementNames) { $removeCallable = array($this, 'removeStringFromArray'); $self = $this; $this->getEventManager()->attach(self::EVENT_CONFIGURE_FORM.$tag, function (Event $event) use ($elementNames, $self) { /* @var $form \Zend\Form\Form */ $form = $event->getParam('form');
php
{ "resource": "" }
q266232
Base.setSubFormDataHandler
test
public function setSubFormDataHandler($tag, $paramName) { $this->formDataEvent($tag, function (Params $params) use
php
{ "resource": "" }
q266233
Base.afterAttach
test
public function afterAttach($formObject, $form, $mainEntity, $tag) { foreach ($this->getExcludedFieldsForEntityTag($tag) as
php
{ "resource": "" }
q266234
HTTP_Request2_Adapter_Mock.addResponse
test
public function addResponse($response, $url = null) { if (is_string($response)) { $response = self::createResponseFromString($response); } elseif (is_resource($response)) { $response = self::createResponseFromFile($response); } elseif (!$response instanceof HTTP_Request2_Response && !$response instanceof
php
{ "resource": "" }
q266235
HTTP_Request2_Adapter_Mock.createResponseFromString
test
public static function createResponseFromString($str) { $parts = preg_split('!(\r?\n){2}!m', $str, 2); $headerLines = explode("\n", $parts[0]); $response = new HTTP_Request2_Response(array_shift($headerLines)); foreach ($headerLines as $headerLine) { $response->parseHeaderLine($headerLine); }
php
{ "resource": "" }
q266236
HTTP_Request2_Adapter_Mock.createResponseFromFile
test
public static function createResponseFromFile($fp) { $response = new HTTP_Request2_Response(fgets($fp)); do { $headerLine = fgets($fp);
php
{ "resource": "" }
q266237
Versions.makeHeadVersion
test
public function makeHeadVersion($entity) { if($entity->isHead()) { return false; } $oldHead = $entity->getHead(); // update references on all old versions $this->entities->createQueryBuilder() ->update($this->entityName, 'o') ->set('o.headVersion', ':newHead') ->where('o.headVersion = :oldHead') ->setParameter('newHead', $entity) ->setParameter('oldHead', $oldHead) ->getQuery() ->execute();
php
{ "resource": "" }
q266238
Versions.needsNewVersion
test
protected function needsNewVersion($entity) { if(!$entity->isHead()) { return false; } if(!$entity->hasVersions()) { return true;
php
{ "resource": "" }
q266239
Versions.persist
test
public function persist($entity, $version = 'guess') { $this->entities->persist($entity); if($version === 'new' || ($version === 'guess' && $this->needsNewVersion($entity))) {
php
{ "resource": "" }
q266240
Versions.clearVersions
test
public function clearVersions($entity) { $entity = $entity->getHead(); $versions = $entity->getVersions(); foreach($versions as $version) { $this->delete($version, false); }
php
{ "resource": "" }
q266241
Uploader.cleanUp
test
private function cleanUp($path) { $fs = $this->getFilesystem(); $parts = explode('/', $path); while (0 < count($parts)) { $key = implode('/', $parts); if ($fs->has($key)) { $dir = $fs->get($key); if (!$dir->isDir() || 0 < count($fs->listContents($key))) { break; }
php
{ "resource": "" }
q266242
Uploader.checkKey
test
private function checkKey($sourceKey) { if ($this->mountManager->has($sourceKey)) { return true; } if ($this->reconnectDistantFs($sourceKey)) {
php
{ "resource": "" }
q266243
Uploader.moveKey
test
private function moveKey($sourceKey, $targetKey) { if (!$this->isDistant($sourceKey)) { return $this->mountManager->move($sourceKey, $targetKey); } if ($this->mountManager->copy($sourceKey, $targetKey)) { return true; } if ($this->reconnectDistantFs($sourceKey)) {
php
{ "resource": "" }
q266244
Uploader.reconnectDistantFs
test
private function reconnectDistantFs($key) { /** @noinspection PhpUnusedLocalVariableInspection */ list($prefix, $args) = $this->mountManager->filterPrefix([$key]); /** @var \League\Flysystem\FileSystem $fs */ $fs = $this->mountManager->getFilesystem($prefix); $adapter = $fs->getAdapter(); // Try reconnection
php
{ "resource": "" }
q266245
Uploader.isDistant
test
private function isDistant($key) { /** @noinspection PhpUnusedLocalVariableInspection */ list($prefix, $args) = $this->mountManager->filterPrefix([$key]); /** @var \League\Flysystem\FileSystem $fs */ $fs = $this->mountManager->getFilesystem($prefix);
php
{ "resource": "" }
q266246
OwpDkim.createPath
test
static private function createPath($path) { if (is_dir($path)) return true; $prev_path = substr($path, 0, (strrpos($path, '/', -2) + 1)); $return
php
{ "resource": "" }
q266247
PDORepository.find
test
public function find($id, bool $getRelations = null): ? Entity { if (! \is_string($id) && ! \is_int($id)) { throw new InvalidArgumentException('ID should be an int or string only.'); } return $this->findBy(
php
{ "resource": "" }
q266248
PDORepository.create
test
public function create(Entity $entity): bool { $this->validateEntity($entity);
php
{ "resource": "" }
q266249
PDORepository.save
test
public function save(Entity $entity): bool { $this->validateEntity($entity);
php
{ "resource": "" }
q266250
PDORepository.delete
test
public function delete(Entity $entity): bool { $this->validateEntity($entity);
php
{ "resource": "" }
q266251
PDORepository.validateEntity
test
protected function validateEntity(Entity $entity): void { if (! ($entity instanceof $this->entity)) { throw new InvalidEntityException( 'This repository expects entities to be instances of ' . $this->entity
php
{ "resource": "" }
q266252
PDORepository.select
test
protected function select( array $columns = null, array $criteria = null, array $orderBy = null, int $limit = null, int $offset = null, bool $getRelations = null ) { // Build the query $query = $this->selectQueryBuilder($columns, $criteria, $orderBy, $limit, $offset); // Create a new PDO statement from the query builder $stmt = $this->store->prepare($query->getQuery()); // Iterate through the criteria once more foreach ($criteria as $column => $criterion) { // If the criterion is null if ($criterion === null) { // Skip as we've already set the where to IS NULL continue; } // If the criterion is an array if (\is_array($criterion)) { // Iterate through the criterion and bind each value individually foreach ($criterion as $index => $criterionItem) {
php
{ "resource": "" }
q266253
PDORepository.selectQueryBuilder
test
protected function selectQueryBuilder( array $columns = null, array $criteria = null, array $orderBy = null, int $limit = null, int $offset = null ): QueryBuilder { // Create a new query $query = $this->entityManager ->getQueryBuilder() ->select($columns) ->table($this->table); // If criteria has been passed if (null !== $criteria) { $this->setCriteriaInQuery($query, $criteria); } // If order by has been passed
php
{ "resource": "" }
q266254
PDORepository.setCriteriaInQuery
test
protected function setCriteriaInQuery(QueryBuilder $query, array $criteria): void { // Iterate through each criteria and set the column = :column // so we can use bindColumn() in PDO later foreach ($criteria as $column => $criterion) { // If the criterion is null if ($criterion === null) { $this->setNullCriterionInQuery($query, $column);
php
{ "resource": "" }
q266255
PDORepository.setArrayCriterionInQuery
test
protected function setArrayCriterionInQuery(QueryBuilder $query, string $column, array $criterion): void { $criterionConcat = ''; $lastIndex = \count($criterion) - 1; // Iterate through the criterion and set each item individually to be bound later
php
{ "resource": "" }
q266256
PDORepository.setOrderByInQuery
test
protected function setOrderByInQuery(QueryBuilder $query, array $orderBy): void { // Iterate through each order by foreach ($orderBy as $column => $order) { // Switch through the order (value) set switch ($order) { // If the order is ascending case OrderBy::ASC: // Set the column via the orderByAsc method $query->orderByAsc($column); break; // If the order is descending
php
{ "resource": "" }
q266257
PDORepository.saveCreateDelete
test
protected function saveCreateDelete(string $type, Entity $entity): int { if (! $this->store->inTransaction()) { $this->store->beginTransaction(); } // Create a new query $query = $this->entityManager ->getQueryBuilder() ->table($this->table) ->{$type}(); $idField = $entity::getIdField(); $properties = $entity->forDataStore(); /* @var QueryBuilder $query */ // If this is an insert if ($type === 'insert') { // Ensure all the required properties are set $this->ensureRequiredProperties($entity, $properties); } // If this type isn't an insert if ($type !== 'insert') { // Set the id for the where clause $query->where($idField . ' = ' . $this->criterionParam($idField)); } if ($type !== 'delete') { // Set the properties $this->setPropertiesForSaveCreateDeleteQuery($query, $properties); } // Prepare a PDO statement with the query $stmt = $this->store->prepare($query->getQuery());
php
{ "resource": "" }
q266258
PDORepository.setPropertiesForSaveCreateDeleteQuery
test
protected function setPropertiesForSaveCreateDeleteQuery(QueryBuilder $query, array $properties): void { // Iterate through the properties foreach ($properties as $column => $property) { if ($property === null) {
php
{ "resource": "" }
q266259
PDORepository.setPropertiesForSaveCreateDeleteStatement
test
protected function setPropertiesForSaveCreateDeleteStatement(PDOStatement $statement, array $properties): void { // Iterate through the properties foreach ($properties as $column => $property) { if ($property === null) { continue; } // If the property is an object, then serialize it if (\is_object($property)) { $property = \serialize($property); } // Otherwise json encode if its an array elseif (\is_array($property)) { $property
php
{ "resource": "" }
q266260
PDORepository.getEntityRelations
test
protected function getEntityRelations(Entity $entity): Entity { $propertyTypes = $entity::getPropertyTypes(); $propertyMapper = $entity->getPropertyMapper(); // Iterate through the property types foreach ($propertyTypes as $property => $type) { $entityName = \is_array($type) ? $type[0] : $type; $propertyMap = $propertyMapper[$property] ?? null; if (null !== $propertyMap && (\is_array($type) || ! PropertyType::isValid($type))) { $repository = $this->entityManager->getRepository($entityName); $orderBy = $propertyMap[PropertyMap::ORDER_BY] ?? null; $limit = $propertyMap[PropertyMap::LIMIT] ?? null; $offset = $propertyMap[PropertyMap::OFFSET] ?? null; $columns = $propertyMap[PropertyMap::COLUMNS] ?? null; $getRelations = $propertyMap[PropertyMap::GET_RELATIONS] ?? true; unset( $propertyMap[PropertyMap::ORDER_BY], $propertyMap[PropertyMap::LIMIT],
php
{ "resource": "" }
q266261
PDORepository.ensureRequiredProperties
test
protected function ensureRequiredProperties(Entity $entity, array $properties): void { // Iterate through the required properties foreach ($entity::getRequiredProperties() as $requiredProperty) { // If the required property is not set if (! isset($properties[$requiredProperty]))
php
{ "resource": "" }
q266262
Steemit.broadcast
test
private function broadcast($body) { $method = 'POST'; $url = "{$this->domain}/broadcast"; $headears = $this->getHeaders(); $body = json_encode($body); try { $request = $this->getClient()->request($method, $url, [ 'headers' => $headears, 'body' => $body ]); $response = $request->getBody()->getContents(); return json_decode($response, true); } catch
php
{ "resource": "" }
q266263
Steemit.exec
test
public function exec($do, array $params) { $body = call_user_func_array(array($this->operations,
php
{ "resource": "" }
q266264
NoCaptcha.getScriptSrc
test
private function getScriptSrc($callbackName = null) { $queries = []; if ($this->hasLang()) { array_set($queries, 'hl', $this->lang); }
php
{ "resource": "" }
q266265
NoCaptcha.display
test
public function display($name = null, array $attributes = []) { $output = $this->attributes->build($this->siteKey, array_merge(
php
{ "resource": "" }
q266266
NoCaptcha.image
test
public function image($name = null, array $attributes = []) { return $this->display(
php
{ "resource": "" }
q266267
NoCaptcha.audio
test
public function audio($name = null, array $attributes = []) { return $this->display(
php
{ "resource": "" }
q266268
NoCaptcha.verify
test
public function verify($response, $clientIp = null) { if (empty($response)) return false; $response = $this->sendVerifyRequest([ 'secret' => $this->secret, 'response' => $response,
php
{ "resource": "" }
q266269
NoCaptcha.verifyRequest
test
public function verifyRequest(ServerRequestInterface $request) { $body = $request->getParsedBody(); $server = $request->getServerParams(); $response = isset($body[self::CAPTCHA_NAME]) ? $body[self::CAPTCHA_NAME] : '';
php
{ "resource": "" }
q266270
NoCaptcha.script
test
public function script($callbackName = null) { $script = ''; if ( ! $this->scriptLoaded) { $script = '<script src="'
php
{ "resource": "" }
q266271
NoCaptcha.scriptWithCallback
test
public function scriptWithCallback(array $captchas, $callbackName = 'captchaRenderCallback') { $script = $this->script($callbackName); if (empty($script) || empty($captchas)) { return $script; } return implode(PHP_EOL, [implode(PHP_EOL, [ '<script>', " var ".implode(',', $captchas).";
php
{ "resource": "" }
q266272
NoCaptcha.checkKey
test
private function checkKey($name, &$value) { $this->checkIsString($name, $value);
php
{ "resource": "" }
q266273
NoCaptcha.checkIsString
test
private function checkIsString($name, $value) { if ( ! is_string($value)) { throw new Exceptions\ApiException(
php
{ "resource": "" }
q266274
NoCaptcha.sendVerifyRequest
test
private function sendVerifyRequest(array $query = []) { $query = array_filter($query); $url = static::VERIFY_URL . '?' .
php
{ "resource": "" }
q266275
View.init
test
public function init() { parent::init(); if (is_array($this->theme)) { if (!isset($this->theme['class'])) { $this->theme['class'] = 'Reaction\Base\Theme';
php
{ "resource": "" }
q266276
View.findViewFile
test
public function findViewFile($view, $context = null) { if (strncmp($view, '@', 1) === 0) { // e.g. "@app/views/main" $file = \Reaction::$app->getAlias($view); } elseif (strncmp($view, '//', 2) === 0) { // e.g. "//layouts/main" $file = Reaction::$app->getViewPath() . DIRECTORY_SEPARATOR . ltrim($view, '/'); } elseif ($context instanceof ViewContextInterface) { $view = ltrim($view, '/'); $file = $context->getViewPath() . DIRECTORY_SEPARATOR . $view; } elseif (($currentViewFile = $this->getViewFile()) !== false) { $file = dirname($currentViewFile) . DIRECTORY_SEPARATOR . $view; } else {
php
{ "resource": "" }
q266277
View.renderPhpStateless
test
public static function renderPhpStateless($_file_, $_params_ = []) { $_file_ = Reaction::$app->getAlias($_file_); $_obInitialLevel_ = ob_get_level(); ob_start(); ob_implicit_flush(false); extract($_params_, EXTR_OVERWRITE); try { require $_file_; return ob_get_clean(); } catch (\Exception $e) { while (ob_get_level() > $_obInitialLevel_) { if (!@ob_end_clean()) {
php
{ "resource": "" }
q266278
Helper.registerPostTypes
test
public function registerPostTypes() { if (!function_exists('register_post_type')) { return; } $this->postTypes->rewind(); while ($this->postTypes->valid()) { $postType = $this->postTypes->current();
php
{ "resource": "" }
q266279
TokenFactory.generateToken
test
public function generateToken($token, KeyPairReference $keyPair
php
{ "resource": "" }
q266280
TokenFactory.generateMemoryToken
test
public function generateMemoryToken($token, KeyPairReference $keyPair = null) { return new
php
{ "resource": "" }
q266281
ExecutePrototypeInstaller.execute
test
public function execute(string $projectFolder) { $shell = $this->getShell()->setDirectory(implode(DIRECTORY_SEPARATOR, [rtrim($this->getBaseFolder(),
php
{ "resource": "" }
q266282
TwigExtension.messageFilterCallback
test
public function messageFilterCallback( $key /*...*/ ) { $params = func_get_args(); array_shift( $params ); if ( count( $params ) == 1 && is_array( $params[0] ) ) { // Unwrap args array
php
{ "resource": "" }
q266283
StdioLogger.notice
test
public function notice($message, array $context = array(), $traceShift =
php
{ "resource": "" }
q266284
StdioLogger.info
test
public function info($message, array $context = array(), $traceShift =
php
{ "resource": "" }
q266285
StdioLogger.debug
test
public function debug($message, array $context = array(), $traceShift =
php
{ "resource": "" }
q266286
StdioLogger.logRaw
test
public function logRaw($message, array $context = array(), $traceShift =
php
{ "resource": "" }
q266287
StdioLogger.profileEnd
test
public function profileEnd($endId, $message = null, $traceShift = null) {
php
{ "resource": "" }
q266288
StdioLogger.log
test
public function log($level, $message, array $context = [], $traceShift = 0) { $this->checkCorrectLogLevel($level); $message = $this->convertMessageToString($message); $message = $this->processPlaceHolders($message, $context); if (strlen($message) > 0 && mb_substr($message, -1) !== "\n" && !$this->newLine) { $message .= self::NEW_LINE; } if ($this->hideLevel === false) { $logColors = isset(static::$LOG_COLORS[$level]) ? static::$LOG_COLORS[$level] : []; if ($level !== static::LOG_LEVEL_RAW) { $message = str_pad('[' . $level . ']', 10, ' ') . $message; } if (!empty($logColors)) { $message = $this->colorizeText($message, $logColors); } } if ($this->newLine === true) { $message .= self::NEW_LINE; } //Add script and line number if ($this->withLineNum) {
php
{ "resource": "" }
q266289
StdioLogger.convertMessageToString
test
protected function convertMessageToString($message) { $messageStr = $message; if ($message === null) { $messageStr = 'NULL'; } elseif ($message instanceof \Throwable) { $messageStr = $this->convertErrorToString($message); } elseif (is_bool($message)) {
php
{ "resource": "" }
q266290
StdioLogger.convertErrorToString
test
protected function convertErrorToString(\Throwable $e, $withTrace = true) { $message = [ $e->getMessage(), !empty($e->getFile()) ? $e->getFile() . ' #' . $e->getLine() : "", $e->getTraceAsString(), ]; if ($withTrace) {
php
{ "resource": "" }
q266291
StdioLogger.colorizeText
test
protected function colorizeText($text, ...$colors) { if (is_array($colors[0])) { $colors = $colors[0]; } for ($i = 0; $i < count($colors); $i++) {
php
{ "resource": "" }
q266292
StdioLogger.getCalleeData
test
private function getCalleeData($trace, $pos = 0) { $traceRow = isset($trace[$pos]) ? $trace[$pos] : end($trace); $file = isset($traceRow['file'])
php
{ "resource": "" }
q266293
StdioLogger.processPlaceHolders
test
protected function processPlaceHolders(string $message, array $context): string { if (false === strpos($message, '{')) { return $message; } $replacements = []; foreach ($context as $key => $value) {
php
{ "resource": "" }
q266294
StdioLogger.formatValue
test
protected function formatValue($value): string { if (is_null($value) || is_scalar($value) || (is_object($value) && method_exists($value, '__toString'))) { return (string)$value; } if (is_object($value))
php
{ "resource": "" }
q266295
Seo.find
test
public static function find(ActiveRecord $owner, $condition = 0) { $seo = new self(); $seo->_owner = $owner; $condition = (int)$condition; $data = $owner->getIsNewRecord() ? false : (new Query()) ->from(Seo::tableName($owner)) ->limit(1) ->andWhere([ 'condition' => $condition, 'model_id' => $owner->getPrimaryKey(),
php
{ "resource": "" }
q266296
Seo.tableName
test
public static function tableName(ActiveRecord $activeRecord) { $tableName = $activeRecord->tableName(); if (substr($tableName, -2) == '}}') { return preg_replace('/{{(.+)}}/',
php
{ "resource": "" }
q266297
Seo.deleteAll
test
public static function deleteAll(ActiveRecord $owner) { $owner->getDb()->createCommand()->delete(self::tableName($owner),
php
{ "resource": "" }
q266298
Seo.save
test
public function save() { if (empty($this->_owner)) { $this->addError('owner', "You can't use Seo model without owner"); return false; } $this->model_id = $this->_owner->getPrimaryKey(); $command = $this->_owner->getDb()->createCommand(); $attributes = ['title', 'keywords', 'description']; $tableName = self::tableName($this->_owner); if ($this->_isNewRecord) { if (empty(array_filter($this->getAttributes($attributes)))) { // don't save new SEO data with empty values return true;
php
{ "resource": "" }
q266299
DB.init
test
static function init(){ global $databaseConfig; if (!isset($databaseConfig)) { $databaseConfig = array ( 'server' => SS_DATABASE_SERVER, 'username' => SS_DATABASE_USERNAME, 'password' => SS_DATABASE_PASSWORD, 'database' => SS_DATABASE_NAME,
php
{ "resource": "" }