_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q2500 | Reporter.on | train | public function on() : self
{
$this->handler->setErrorHandler();
| php | {
"resource": ""
} |
q2501 | Driver.start | train | public function start($type = '*firefox', $startUrl = 'http://localhost')
{
if (null !== $this->sessionId) {
throw new Exception("Session already started");
}
| php | {
"resource": ""
} |
q2502 | Driver.getString | train | public function getString($command, $target = null, $value = null)
{
$result = $this->doExecute($command, $target, $value);
if (!preg_match('/^OK,/', $result)) {
| php | {
"resource": ""
} |
q2503 | Driver.getStringArray | train | public function getStringArray($command, $target = null, $value = null)
{
$string = $this->getString($command, $target, $value);
$results = preg_split('/(?<!\\\),/', $string);
| php | {
"resource": ""
} |
q2504 | Driver.getNumber | train | public function getNumber($command, $target = null, $value = null)
{
| php | {
"resource": ""
} |
q2505 | Driver.getBoolean | train | public function getBoolean($command, $target = null, $value = null)
{
| php | {
"resource": ""
} |
q2506 | Driver.stop | train | public function stop()
{
if (null === $this->sessionId) {
throw new Exception("Session not started");
}
| php | {
"resource": ""
} |
q2507 | Driver.doExecute | train | protected function doExecute($command, $target = null, $value = null)
{
$postFields = array();
$query = array('cmd' => $command);
if ($target !== null) {
$postFields[1] = $target;
}
if ($value !== null) {
$postFields[2] = $value;
}
if (null !== $this->sessionId) {
$query['sessionId'] = $this->sessionId;
}
$query = http_build_query($query);
$url = $this->url.'?'.$query;
//open connection
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, count($postFields));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
| php | {
"resource": ""
} |
q2508 | StacktraceFormatterTrait.unpackThrowables | train | private function unpackThrowables($throwable)
{
if (!$throwable instanceof Throwable) {
return [];
}
$throwables = | php | {
"resource": ""
} |
q2509 | RenderViewHelper.renderStatic | train | public static function renderStatic(array $arguments, Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
/** @var FieldViewHelperService $fieldService */
$fieldService = Core::instantiate(FieldViewHelperService::class);
if (false === $fieldService->fieldContextExists()) {
throw ContextNotFoundException::slotRenderViewHelperFieldContextNotFound();
}
/** @var SlotViewHelperService $slotService */
$slotService = Core::instantiate(SlotViewHelperService::class);
$slotName = $arguments['slot'];
$result = '';
if ($slotService->hasSlot($slotName)) {
$currentVariables = version_compare(VersionNumberUtility::getCurrentTypo3Version(), '8.0.0', '<')
? $renderingContext->getTemplateVariableContainer()->getAll()
| php | {
"resource": ""
} |
q2510 | ExceptionHandler.handle | train | public function handle($throwable)
{
if ($throwable instanceof Exception) {
$response = $this->handler->handleException($this->defaultRequest, $this->defaultResponse, $throwable);
} elseif ($throwable instanceof Throwable) {
$response = $this->handler->handleThrowable($this->defaultRequest, $this->defaultResponse, $throwable);
} else {
| php | {
"resource": ""
} |
q2511 | FieldViewHelper.storeViewDataLegacy | train | protected function storeViewDataLegacy()
{
$originalArguments = [];
$variableProvider = $this->getVariableProvider();
foreach (self::$reservedVariablesNames as $key) {
if ($variableProvider->exists($key)) {
$originalArguments[$key] = $variableProvider->get($key);
}
}
$viewHelperVariableContainer = $this->renderingContext->getViewHelperVariableContainer();
$currentView = $viewHelperVariableContainer->getView();
return function (array $templateArguments) use ($originalArguments, $variableProvider, $viewHelperVariableContainer, $currentView) {
| php | {
"resource": ""
} |
q2512 | FieldViewHelper.injectFieldInService | train | protected function injectFieldInService($fieldName)
{
$formObject = $this->formService->getFormObject();
$formConfiguration = $formObject->getConfiguration();
if (false === is_string($fieldName)) {
throw InvalidArgumentTypeException::fieldViewHelperInvalidTypeNameArgument();
} elseif (false === $formConfiguration->hasField($fieldName)) {
| php | {
"resource": ""
} |
q2513 | FieldViewHelper.getLayout | train | protected function getLayout(View $viewConfiguration)
{
$layout = $this->arguments['layout'];
if (false === is_string($layout)) {
throw InvalidArgumentTypeException::invalidTypeNameArgumentFieldViewHelper($layout);
}
list($layoutName, $templateName) = GeneralUtility::trimExplode('.', $layout);
if (empty($templateName)) {
$templateName = 'default';
}
if (empty($layoutName)) {
throw InvalidArgumentValueException::fieldViewHelperEmptyLayout();
}
if (false === $viewConfiguration->hasLayout($layoutName)) {
throw | php | {
"resource": ""
} |
q2514 | FieldViewHelper.getTemplateArguments | train | protected function getTemplateArguments()
{
$templateArguments = $this->arguments['arguments'] ?: [];
| php | {
"resource": ""
} |
q2515 | Convert.valueToBytes | train | public static function valueToBytes($value): int
{
if (is_int($value)) {
return $value;
}
$value = trim($value);
// Native PHP check for digits in string
if (ctype_digit(ltrim($value, '-'))) {
return (int)$value;
}
$signed = (substr($value, 0, 1) === '-') ? -1 : 1;
// Kilobytes
if (preg_match('/(\d+)K$/i', $value, $matches)) {
return (int)($matches[1] * $signed * 1024);
}
// Megabytes
if (preg_match('/(\d+)M$/i', $value, $matches)) {
| php | {
"resource": ""
} |
q2516 | Convert.objectToArray | train | public static function objectToArray($source): array
{
$result = [];
if (is_array($source)) {
return $source;
}
if (!is_object($source)) {
return $result;
| php | {
"resource": ""
} |
q2517 | Convert.dataToJson | train | public static function dataToJson(string $data, bool $lint = false): stdClass
{
if ($lint) {
$linter = new JsonParser();
$linter->parse($data);
}
$data = json_decode($data);
| php | {
"resource": ""
} |
q2518 | URI.getQueryParam | train | public function getQueryParam(UriInterface $uri, $param)
{
if (!$query = $uri->getQuery()) {
return null;
}
| php | {
"resource": ""
} |
q2519 | URI.uriFor | train | public function uriFor($route, array $params = [], array $query = [])
{
if (!$route) { | php | {
"resource": ""
} |
q2520 | URI.absoluteURIFor | train | public function absoluteURIFor(UriInterface $uri, $route, array $params = [], array $query = [])
{
$path = $this->uriFor($route, $params);
return (string) $uri
->withUserInfo('')
| php | {
"resource": ""
} |
q2521 | FormBuilder.getTypeObject | train | private function getTypeObject($type, $args)
{
/* @var AbstractType $object */
if ($type instanceof AbstractType) {
$object = $type;
} else {
$class = $this->getTypeClass($type);
| php | {
"resource": ""
} |
q2522 | BehavioursManager.applyBehaviourOnFormInstance | train | public function applyBehaviourOnFormInstance(FormObject $formObject)
{
if ($formObject->hasForm()) {
$formInstance = $formObject->getForm();
foreach ($formObject->getConfiguration()->getFields() as $fieldName => $field) {
if (ObjectAccess::isPropertyGettable($formInstance, $fieldName)
&& ObjectAccess::isPropertySettable($formInstance, $fieldName)
) {
$propertyValue = ObjectAccess::getProperty($formInstance, $fieldName);
foreach ($field->getBehaviours() as $behaviour) {
| php | {
"resource": ""
} |
q2523 | ConditionFactory.registerCondition | train | public function registerCondition($name, $className)
{
if (false === is_string($name)) {
throw InvalidArgumentTypeException::conditionNameNotString($name);
}
if (false === class_exists($className)) {
| php | {
"resource": ""
} |
q2524 | ConditionFactory.registerDefaultConditions | train | public function registerDefaultConditions()
{
if (false === $this->defaultConditionsWereRegistered) {
$this->defaultConditionsWereRegistered = true;
$this->registerCondition(
FieldHasValueCondition::CONDITION_NAME,
FieldHasValueCondition::class
)->registerCondition(
FieldHasErrorCondition::CONDITION_NAME,
FieldHasErrorCondition::class
)->registerCondition(
FieldIsValidCondition::CONDITION_NAME,
FieldIsValidCondition::class
)->registerCondition(
| php | {
"resource": ""
} |
q2525 | TypoScriptService.getFormConfiguration | train | public function getFormConfiguration($formClassName)
{
$formzConfiguration = $this->getExtensionConfiguration();
| php | {
"resource": ""
} |
q2526 | TypoScriptService.getExtensionConfiguration | train | protected function getExtensionConfiguration()
{
$cacheInstance = CacheService::get()->getCacheInstance();
$hash = $this->getContextHash();
if ($cacheInstance->has($hash)) {
$result = $cacheInstance->get($hash);
} else {
$result = $this->getFullConfiguration();
$result = (ArrayUtility::isValidPath($result, self::EXTENSION_CONFIGURATION_PATH, '.'))
? ArrayUtility::getValueByPath($result, self::EXTENSION_CONFIGURATION_PATH, | php | {
"resource": ""
} |
q2527 | TypoScriptService.getFullConfiguration | train | protected function getFullConfiguration()
{
$contextHash = $this->getContextHash();
if (false === array_key_exists($contextHash, $this->configuration)) {
$typoScriptArray = ($this->environmentService->isEnvironmentInFrontendMode())
? $this->getFrontendTypoScriptConfiguration()
: $this->getBackendTypoScriptConfiguration(); | php | {
"resource": ""
} |
q2528 | Generator.generate | train | public function generate(
ContainerConfiguration $config,
ConfigCache $dump
): ContainerInterface {
| php | {
"resource": ""
} |
q2529 | HtmlToJson.toJson | train | public function toJson($html)
{
// Strip white space between tags to prevent creation of empty #text nodes
$html = preg_replace('~>\s+<~', '><', $html);
$document = new \DOMDocument();
// Load UTF-8 HTML hack (from http://bit.ly/pVDyCt)
$document->loadHTML('<?xml encoding="UTF-8">' . $html);
| php | {
"resource": ""
} |
q2530 | HtmlToJson.convert | train | private function convert(\DOMElement $node)
{
foreach ($this->converters as $converter) {
if ($converter->matches($node)) {
| php | {
"resource": ""
} |
q2531 | AbstractActivation.getConditions | train | public function getConditions()
{
$conditionList = $this->withFirstParent(
Form::class,
function (Form $formConfiguration) {
return $formConfiguration->getConditionList();
}
);
| php | {
"resource": ""
} |
q2532 | AbstractActivation.getCondition | train | public function getCondition($name)
{
if (false === $this->hasCondition($name)) {
throw EntryNotFoundException::activationConditionNotFound($name);
| php | {
"resource": ""
} |
q2533 | FormService.getFormWithErrors | train | public static function getFormWithErrors($formClassName)
{
GeneralUtility::logDeprecatedFunction();
| php | {
"resource": ""
} |
q2534 | ConditionParser.getNodeRecursive | train | protected function getNodeRecursive()
{
while (false === empty($this->scope->getExpression())) {
$currentExpression = $this->scope->getExpression();
$this->processToken($currentExpression[0]);
$this->processLogicalAndNode();
}
| php | {
"resource": ""
} |
q2535 | ConditionParser.processToken | train | protected function processToken($token)
{
switch ($token) {
case ')':
$this->processTokenClosingParenthesis();
break;
case '(':
$this->processTokenOpeningParenthesis();
break;
case self::LOGICAL_OR:
| php | {
"resource": ""
} |
q2536 | ConditionParser.processTokenOpeningParenthesis | train | protected function processTokenOpeningParenthesis()
{
$groupNode = $this->getGroupNode($this->scope->getExpression());
$scopeSave = $this->scope;
$expression = array_slice($scopeSave->getExpression(), count($groupNode) + | php | {
"resource": ""
} |
q2537 | ConditionParser.processTokenLogicalOperator | train | protected function processTokenLogicalOperator($operator)
{
if (null === $this->scope->getNode()) {
$this->addError('Logical operator must be preceded by a valid operation.', self::ERROR_CODE_LOGICAL_OPERATOR_PRECEDED);
} else {
if (self::LOGICAL_OR === $operator) {
if (null !== $this->scope->getLastOrNode()) {
/*
* If a `or` node was already registered, we create a new
| php | {
"resource": ""
} |
q2538 | ConditionParser.processTokenCondition | train | protected function processTokenCondition($condition)
{
if (false === $this->condition->hasCondition($condition)) {
$this->addError('The condition "' . $condition . '" does not | php | {
"resource": ""
} |
q2539 | ConditionParser.processLogicalAndNode | train | protected function processLogicalAndNode()
{
if (null !== $this->scope->getCurrentLeftNode()
&& null !== $this->scope->getNode()
&& null !== $this->scope->getCurrentOperator()
) {
$node = new BooleanNode($this->scope->getCurrentLeftNode(), $this->scope->getNode(), $this->scope->getCurrentOperator());
| php | {
"resource": ""
} |
q2540 | ConditionParser.processLastLogicalOperatorNode | train | protected function processLastLogicalOperatorNode()
{
if (null !== $this->scope->getCurrentLeftNode()) {
$this->addError('Logical operator must be followed by a valid operation.', self::ERROR_CODE_LOGICAL_OPERATOR_FOLLOWED);
} elseif (null !== $this->scope->getLastOrNode()) {
| php | {
"resource": ""
} |
q2541 | ConditionParser.getGroupNodeClosingIndex | train | protected function getGroupNodeClosingIndex(array $expression)
{
$parenthesis = 1;
$index = 0;
while ($parenthesis > 0) {
$index++;
if ($index > count($expression)) {
$this->addError('Parenthesis not correctly closed.', self::ERROR_CODE_CLOSING_PARENTHESIS_NOT_FOUND);
}
| php | {
"resource": ""
} |
q2542 | Salt.getSalt | train | public static function getSalt(): string
{
$result = '';
try {
$result = static::readSaltFromFile();
} catch (InvalidArgumentException $e) {
Log::warning("Failed to read salt from file");
}
if ($result) {
return $result;
}
try {
$salt = static::generateSalt();
static::writeSaltToFile($salt);
$result = static::readSaltFromFile();
} catch (InvalidArgumentException $e) {
| php | {
"resource": ""
} |
q2543 | Salt.readSaltFromFile | train | protected static function readSaltFromFile(): string
{
Utility::validatePath(static::$saltFile);
$result = file_get_contents(static::$saltFile);
| php | {
"resource": ""
} |
q2544 | Salt.writeSaltToFile | train | protected static function writeSaltToFile(string $salt): void
{
static::validateSalt($salt);
$result = @file_put_contents(static::$saltFile, $salt);
| php | {
"resource": ""
} |
q2545 | Salt.validateSalt | train | protected static function validateSalt(string $salt): void
{
if (!ctype_print($salt)) {
throw new InvalidArgumentException("Salt is not a printable string");
}
static::validateSaltMinLength();
$saltLength = strlen($salt);
if ($saltLength < static::$saltMinLength) {
| php | {
"resource": ""
} |
q2546 | Salt.generateSalt | train | protected static function generateSalt(): string
{
$result = '';
static::validateSaltMinLength();
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$poolSize = strlen($pool);
| php | {
"resource": ""
} |
q2547 | Client.getBrowser | train | public function getBrowser($startPage, $type = '*firefox')
{
$url = 'http://'.$this->host.':'.$this->port.'/selenium-server/driver/';
$driver = new Driver($url, $this->timeout);
| php | {
"resource": ""
} |
q2548 | MySQL.describeTable | train | public function describeTable($table)
{
if (!$this->connection->expr('show tables like []', [$table])->get()) {
return []; // no such table
}
$result = [];
foreach ($this->connection->expr('describe {}', [$table]) as $row) {
$row2 = [];
$row2['name'] = $row['Field']; | php | {
"resource": ""
} |
q2549 | FormObjectHash.getHash | train | public function getHash()
{
if (null === $this->hash) { | php | {
"resource": ""
} |
q2550 | ErrorHandler.register | train | public function register($handledErrors = E_ALL)
{
$errHandler = [$this, 'handleError'];
$exHandler = [$this, 'handleException'];
$handledErrors = is_int($handledErrors) ? $handledErrors : E_ALL;
| php | {
"resource": ""
} |
q2551 | ErrorHandler.registerShutdown | train | public function registerShutdown()
{
if (self::$reservedMemory === null) {
self::$reservedMemory = str_repeat('x', 10240);
register_shutdown_function(__CLASS__ . '::handleFatalError');
| php | {
"resource": ""
} |
q2552 | ConditionProcessorFactory.fetchProcessorInstanceFromCache | train | protected function fetchProcessorInstanceFromCache($cacheIdentifier, FormObject $formObject)
{
$cacheInstance = CacheService::get()->getCacheInstance();
/** @var ConditionProcessor $instance */
if ($cacheInstance->has($cacheIdentifier)) {
$instance = $cacheInstance->get($cacheIdentifier);
$instance->attachFormObject($formObject);
| php | {
"resource": ""
} |
q2553 | GoogleRecaptcha.verify | train | public function verify($response)
{
$result = $this->getVerificationResult($response);
if ($result['success']) {
| php | {
"resource": ""
} |
q2554 | GoogleRecaptcha.getScriptSrc | train | protected function getScriptSrc($onloadCallbackName)
{
$url = static::SCRIPT_URL;
$queryArgs = [];
\parse_str(\parse_url($url, PHP_URL_QUERY), $queryArgs);
$queryArgs['onload'] = $onloadCallbackName;
| php | {
"resource": ""
} |
q2555 | NegotiatingContentHandler.getContentTypeHandler | train | private function getContentTypeHandler(ServerRequestInterface $request)
{
$acceptHeader = $request->getHeaderLine('Accept');
$acceptedTypes = explode(',', $acceptHeader);
foreach ($this->handlers as $contentType => $handler) {
| php | {
"resource": ""
} |
q2556 | FootprintBehavior.beforeSave | train | public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options): void
{
if (! is_callable($this->getConfig('callback'))) {
return;
}
$user = call_user_func($this->getConfig('callback'));
if (empty($user['id'])) {
return;
}
// Set created_by only if that field is not set during entity creation
if ($entity->isNew() && empty($entity->get($this->getConfig('created_by')))) {
$entity->set($this->getConfig('created_by'), $user['id']);
| php | {
"resource": ""
} |
q2557 | BuilderAbstract.build | train | public function build(InputSettings $settings)
{
$this->settings = $settings;
$this->setElement();
$this->setValidator();
| php | {
"resource": ""
} |
q2558 | BuilderAbstract.initElement | train | public function initElement()
{
if(is_null($this->settings)) {
$this->settings = new InputSettings();
| php | {
"resource": ""
} |
q2559 | BuilderAbstract.setLabel | train | public function setLabel()
{
if($this->settings->getValue(InputSettings::LABEL_PARAM)) {
$this->element->setLabel($this->settings->getValue(InputSettings::LABEL_PARAM));
} else {
| php | {
"resource": ""
} |
q2560 | BuilderAbstract.setDefault | train | public function setDefault()
{
if($this->settings->getValue(InputSettings::DEFAULTS_PARAM)) {
| php | {
"resource": ""
} |
q2561 | BuilderAbstract.setAttributes | train | public function setAttributes()
{
if($this->settings->getValue(InputSettings::PLACEHOLDER_PARAM)) { | php | {
"resource": ""
} |
q2562 | DoctrineWriter.getNewInstance | train | protected function getNewInstance()
{
$className = $this->objectMetadata->getName();
if (class_exists($className) === false) {
throw new \RuntimeException('Unable | php | {
"resource": ""
} |
q2563 | DoctrineWriter.setValue | train | protected function setValue($object, $value, $setter)
{
if (method_exists($object, $setter)) {
| php | {
"resource": ""
} |
q2564 | AssetHandlerFactory.getAssetHandler | train | public function getAssetHandler($className)
{
if (false === array_key_exists($className, $this->instances)) {
if (false === class_exists($className)) {
throw ClassNotFoundException::wrongAssetHandlerClassName($className);
| php | {
"resource": ""
} |
q2565 | FormInitializationJavaScriptAssetHandler.getFormInitializationJavaScriptCode | train | public function getFormInitializationJavaScriptCode()
{
$formName = GeneralUtility::quoteJSvalue($this->getFormObject()->getName());
$formConfigurationJson = $this->handleFormConfiguration($this->getFormConfiguration());
| php | {
"resource": ""
} |
q2566 | FormInitializationJavaScriptAssetHandler.getFormConfiguration | train | protected function getFormConfiguration()
{
$formConfigurationArray = $this->getFormObject()->getConfiguration()->toArray();
$this->removeFieldsValidationConfiguration($formConfigurationArray)
| php | {
"resource": ""
} |
q2567 | FormInitializationJavaScriptAssetHandler.removeFieldsValidationConfiguration | train | protected function removeFieldsValidationConfiguration(array &$formConfiguration)
{
foreach ($formConfiguration['fields'] as $fieldName => $fieldConfiguration) {
if (true === isset($fieldConfiguration['validation'])) { | php | {
"resource": ""
} |
q2568 | FormzLocalizationJavaScriptAssetHandler.getJavaScriptCode | train | public function getJavaScriptCode()
{
$realTranslations = [];
$translationsBinding = [];
foreach ($this->translations as $key => $value) {
$hash = HashService::get()->getHash($value);
$realTranslations[$hash] = $value;
$translationsBinding[$key] | php | {
"resource": ""
} |
q2569 | FormzLocalizationJavaScriptAssetHandler.getTranslationKeysForFieldValidation | train | public function getTranslationKeysForFieldValidation(Field $field, $validationName)
{
$result = [];
if (true === $field->hasValidation($validationName)) {
| php | {
"resource": ""
} |
q2570 | FormzLocalizationJavaScriptAssetHandler.injectTranslationsForFormFieldsValidation | train | public function injectTranslationsForFormFieldsValidation()
{
$formConfiguration = $this->getFormObject()->getConfiguration();
foreach ($formConfiguration->getFields() as $field) {
| php | {
"resource": ""
} |
q2571 | FormzLocalizationJavaScriptAssetHandler.storeTranslationsForFieldValidation | train | protected function storeTranslationsForFieldValidation(Field $field)
{
if (false === $this->translationsForFieldValidationWereInjected($field)) {
$fieldName = $field->getName();
foreach ($field->getValidation() as $validationName => $validation) {
$messages = ValidatorService::get()->getValidatorMessages($validation->getClassName(), $validation->getMessages());
foreach ($messages as $key => $message) {
$message = MessageService::get()->parseMessageArray($message, ['{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}']);
$localizationKey = $this->getIdentifierForFieldValidationName($field, $validationName, $key);
$this->addTranslation($localizationKey, $message);
| php | {
"resource": ""
} |
q2572 | FormzLocalizationJavaScriptAssetHandler.translationsForFieldValidationWereInjected | train | protected function translationsForFieldValidationWereInjected(Field $field)
{
$key = $this->getFormObject()->getClassName() . '-' . $field->getName();
| php | {
"resource": ""
} |
q2573 | Configuration.getConfigurationObjectServices | train | public static function getConfigurationObjectServices()
{
return ServiceFactory::getInstance()
->attach(ServiceInterface::SERVICE_CACHE)
->with(ServiceInterface::SERVICE_CACHE)
->setOption(CacheService::OPTION_CACHE_NAME, InternalCacheService::CONFIGURATION_OBJECT_CACHE_IDENTIFIER) | php | {
"resource": ""
} |
q2574 | Configuration.addForm | train | public function addForm(FormObject $form)
{
if (true === $this->hasForm($form->getClassName(), $form->getName())) {
throw DuplicateEntryException::formWasAlreadyRegistered($form);
}
| php | {
"resource": ""
} |
q2575 | Configuration.calculateHash | train | public function calculateHash()
{
$fullArray = $this->toArray();
$configurationArray = [
'view' => $fullArray['view'],
| php | {
"resource": ""
} |
q2576 | MethodBuilder.buildCode | train | public function buildCode()
{
$code = '';
if ($this->documentation) {
$code .= ' /**'."\n";
$code .= ' * '.str_replace("\n", "\n * ", wordwrap($this->documentation, 73))."\n";
$code .= ' | php | {
"resource": ""
} |
q2577 | Taxonomy.createVocabulary | train | public function createVocabulary($name) {
if ($this->vocabulary->where('name', $name)->count()) {
throw new | php | {
"resource": ""
} |
q2578 | Taxonomy.getVocabularyByNameAsArray | train | public function getVocabularyByNameAsArray($name) {
$vocabulary = $this->vocabulary->where('name', $name)->first(); | php | {
"resource": ""
} |
q2579 | Taxonomy.getVocabularyByNameOptionsArray | train | public function getVocabularyByNameOptionsArray($name) {
$vocabulary = $this->vocabulary->where('name', $name)->first();
if (is_null($vocabulary)) {
return [];
}
$parents = $this->term->whereParent(0)
| php | {
"resource": ""
} |
q2580 | Taxonomy.recurse_children | train | private function recurse_children($parent, &$options, $depth = 1) {
$parent->childrens->map(function($child) use (&$options, $depth) {
$options[$child->id] = str_repeat('-', $depth) .' '. $child->name;
| php | {
"resource": ""
} |
q2581 | Taxonomy.deleteVocabularyByName | train | public function deleteVocabularyByName($name) {
$vocabulary = $this->vocabulary->where('name', $name)->first();
if (!is_null($vocabulary)) { | php | {
"resource": ""
} |
q2582 | Taxonomy.createTerm | train | public function createTerm($vid, $name, $parent = 0, $weight = 0) {
$vocabulary = $this->vocabulary->findOrFail($vid);
| php | {
"resource": ""
} |
q2583 | ConditionIsValidValidator.isValid | train | public function isValid($condition)
{
$conditionTree = ConditionParser::get()
->parse($condition);
if (true === $conditionTree->getValidationResult()->hasErrors()) {
$errorMessage = $this->translateErrorMessage(
'validator.form.condition_is_valid.error',
'formz',
[
$condition->getExpression(),
| php | {
"resource": ""
} |
q2584 | InjectorServiceProvider.alias | train | protected function alias($aliasKey, $serviceKey)
{
// Bound as a factory to ALWAYS pass through to underlying definition.
$this->bindFactory(
$aliasKey,
function (Container | php | {
"resource": ""
} |
q2585 | InjectorServiceProvider.autoBind | train | protected function autoBind($className, callable $parameterFactory = null)
{
$this->bind(
$className,
| php | {
"resource": ""
} |
q2586 | InjectorServiceProvider.autoBindFactory | train | protected function autoBindFactory($className, callable $parameterFactory = null)
{
$this->bindFactory(
$className,
| php | {
"resource": ""
} |
q2587 | Injector.create | train | public function create($className, $parameters = [])
{
$reflectionClass = new \ReflectionClass($className);
if (!$reflectionClass->hasMethod("__construct")) {
//This class doesn't have a constructor
return $reflectionClass->newInstanceWithoutConstructor();
}
if (!$reflectionClass->getMethod('__construct')->isPublic()) {
throw new InjectorInvocationException(
"Injector failed to create $className - constructor isn't public." .
" Do you need to use a static factory method instead?"
);
}
try {
$parameters = $this->buildParameterArray(
$this->inspector->getSignatureByReflectionClass($reflectionClass, "__construct"),
$parameters
);
return $reflectionClass->newInstanceArgs($parameters);
} catch (MissingRequiredParameterException $e) {
throw new InjectorInvocationException(
"Can't create $className " .
" - __construct() | php | {
"resource": ""
} |
q2588 | Injector.canAutoCreate | train | public function canAutoCreate($className)
{
foreach ($this->autoCreateWhiteList as $regex) {
if (preg_match($regex, $className)) { | php | {
"resource": ""
} |
q2589 | Injector.buildParameterArray | train | private function buildParameterArray($methodSignature, $providedParameters)
{
$parameters = [];
foreach ($methodSignature as $position => $parameterData) {
if (!isset($parameterData['variadic'])) {
$parameters[$position] = $this->resolveParameter($position, $parameterData, $providedParameters);
} else {
// variadic parameter must be the last one, so
// the rest of the provided paramters should be piped
| php | {
"resource": ""
} |
q2590 | ParameterInspector.getSignatureByReflectionClass | train | public function getSignatureByReflectionClass(\ReflectionClass $reflectionClass, $methodName)
{
$className = $reflectionClass->getName();
| php | {
"resource": ""
} |
q2591 | BindingClosureFactory.createAutoWireClosure | train | public function createAutoWireClosure($className, callable $parameterFactory = null)
{
return function (Container $app) use ($className, $parameterFactory) {
$parameters = $parameterFactory | php | {
"resource": ""
} |
q2592 | BindingClosureFactory.createProxy | train | private function createProxy($className, callable $serviceFactory, Container $app)
{
return $this->proxyFactory->createProxy(
$className,
function (&$wrappedObject, $proxy, $method, $parameters, &$initializer) use (
$className,
$serviceFactory,
$app
) {
| php | {
"resource": ""
} |
q2593 | Packages.classmap | train | public function classmap()
{
$path = $this->composerPath . $this->classmapName;
$i = 0;
if (is_file($path)) {
$data = include $path;
foreach ($data as $key => $value) {
if (false === empty($value)) {
$this->libs[addcslashes($key, '\\')] = $value;
$i++;
} | php | {
"resource": ""
} |
q2594 | Packages.psr0 | train | public function psr0()
{
$i = $this->load($this->composerPath . $this->psrZeroName);
if ($i !== false) {
$this->log[] = 'Imported ' . $i . ' classes from psr0';
| php | {
"resource": ""
} |
q2595 | Packages.psr4 | train | public function psr4()
{
$i = $this->load($this->composerPath . $this->psrFourName);
if ($i !== false) {
$this->log[] = 'Imported ' . $i . ' classes from psr4';
| php | {
"resource": ""
} |
q2596 | Packages.save | train | public function save($path)
{
if (count($this->libs) === 0) {
return false;
}
$handle = fopen($path, 'w');
if ($handle === false) {
throw new \InvalidArgumentException('This path is not writabled: ' . $path);
}
$first = true;
$eol = chr(10);
fwrite($handle, '<?php' . $eol . 'return array(');
foreach ($this->libs as $key => $value) {
$value = self::relativePath($value);
| php | {
"resource": ""
} |
q2597 | Packages.version | train | public static function version($name)
{
$file = INPHINIT_ROOT . 'composer.lock';
$data = is_file($file) ? json_decode(file_get_contents($file)) : false;
if (empty($data->packages)) {
| php | {
"resource": ""
} |
q2598 | ObjectArrayStorage.get | train | public function get($object) : array
{
$values = $this->storage->get($object);
| php | {
"resource": ""
} |
q2599 | ObjectArrayStorage.add | train | public function add($object, $value) : void
{
$values = $this->get($object);
| php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.