Process step 1 in CLI mode
@throws UnexpectedValueException
543429
protected function installCliStep1()
    {
        $this->data['step'] = 1;
        $this->setCliMessage('Configuring modules...');
        $result = $this->installModules($this->data, $this->db);

        if ($result['severity'] !== 'success') {
            throw new UnexpectedValueException($result['message']);
        }
    }
1042738
protected function initConnectionData()
    {
        if ($this->connectionData) {
            return;
        }

        if (!$this->connectionUrl) {
            throw new \UnexpectedValueException(
                'Expected a connectionUrl, got nowt.'
            );
        }

        $parsed = parse_url($this->connectionUrl);
        if ($parsed === false) {
            throw new UnexpectedValueException(
                'Expected a sensible connectionUrl, got nowt but rubbish.'
            );
        }
        $this->connectionData = $parsed;
    }
39587
public function process()
    {
        parent::process();

        if (!$this->processValue()) {
            return;
        }

        if ($this->required && $this->isSensitive()) {
            // When values are not serialized, an empty string is treated as
            // null. As a result, you should not use a null value and an empty
            // string value in the same flydown except when using serialized
            // values.
            if (
                ($this->serialize_values && $this->value === null) ||
                (!$this->serialize_values && $this->value == '')
            ) {
                $this->addMessage($this->getValidationMessage('required'));
            }
        }
    }
95681
protected function doProcessing()
    {
        $this->prepareProcessContext();


        // initialization process pipeline

        $initSteps = $this->initProcessSteps();

        if ( ! empty($initSteps)) {

            $this->context = app(Pipeline::class)
                 ->send($this->context)
                 ->through($initSteps)
                 ->then(function (ProcessContextInterface $context) {

                    return $context;
                 });

            $this->afterInitSteps();
        }


        // main pipeline (actual processing)

        $steps = $this->processSteps();

        if ($this->databaseTransaction) DB::beginTransaction();

        try {

            $this->context = app(Pipeline::class)
                 ->send($this->context)
                 ->through($steps)
                 ->then(function(ProcessContextInterface $context) {

                    if ($this->databaseTransaction) DB::commit();

                    return $context;
                 });

        } catch (Exception $e) {

            if ($this->databaseTransaction) DB::rollBack();

            $this->onExceptionInPipeline($e);

            throw $e;
        }

        $this->afterPipeline();


        $this->populateResult();
    }
1063266
private void runImpl() throws IOException, SQLException, Throwable {
		if(args!=null && args.length>0) {
			handleCommandImpl(args);
		} else {
			// The arguments that have been read so far
			List<String> arguments=new ArrayList<>();

			// The argument that is being read.
			StringBuilder argument=new StringBuilder();
			boolean hasArgument=false;
			int quoteChar=-1;

			if(isInteractive) {
				out.print(getPrompt());
				out.flush();
			}
			// Read until end of file or exit command
			int ch;
			while((ch=in.read())!=-1) {
				// Skip windows '\r'
				if(ch!='\r') {
					if(ch=='\\') {
						// Process escapes
						ch=in.read();
						if(ch==-1) throw new EOFException("unexpected EOF processing escape: \\");
						if(ch=='\r') {
							// Skip windows '\r'
							ch=in.read();
							if(ch==-1) throw new EOFException("unexpected EOF processing escape: \\");
						}
						// Skip '\n' when it is escaped
						if(ch=='\n') {
							if(isInteractive) {
								out.print("\\> ");
								out.flush();
							}
						} else {
							// skip the escape only when followed by ' when using single quotes
							if(quoteChar=='\'' && ch!='\'') {
								argument.append('\\').append((char)ch);
								hasArgument=true;
							} else {
								// use the second character for anything left
								argument.append((char)ch);
								hasArgument=true;
							}
						}
					} else if(quoteChar=='\'') {
						// Handle reading single quote
						if(ch=='\'') quoteChar=-1;
						else {
							argument.append((char)ch);
							if(isInteractive && ch=='\n') {
								out.print("'> ");
								out.flush();
							}
						}
					} else if(quoteChar=='"') {
						// Handle reading double quote
						if(ch=='"') quoteChar=-1;
						else {
							argument.append((char)ch);
							if(isInteractive && ch=='\n') {
								out.print("\"> ");
								out.flush();
							}
						}
					} else {
						// Read as unquoted input
						if(ch=='\n') {
							// End of line means end of command if not in a quote mode
							if(hasArgument) {
								arguments.add(argument.toString());
								argument.setLength(0);
								hasArgument=false;
							}
							if(isInteractive) printFinishedJobs();
							if(arguments.size()>0) {
								boolean doMore=handleCommandImpl(arguments);
								arguments.clear();
								if(!doMore) break;
							}
							if(isInteractive) {
								out.print(getPrompt());
								out.flush();
							}
						} else if(ch<=' ') {
							// Whitespace separates commands or is skipped
							if(hasArgument) {
								arguments.add(argument.toString());
								argument.setLength(0);
								hasArgument=false;
							}
						} else if(ch=='\'' || ch=='"') {
							// Beginning quote
							quoteChar=ch;
							hasArgument=true;
						} else {
							// Everything else is part of the argument are begins the next argument
							argument.append((char)ch);
							hasArgument=true;
						}
					}
				}
			}
			// If currently parsing quote, throw error
			if(quoteChar!=-1) throw new EOFException("unexpected EOF when processing quote: "+quoteChar);

			// If commands have been parsed and not executed, run them now
			if(hasArgument) {
				arguments.add(argument.toString());
				argument.setLength(0);
			}
			if(arguments.size()>0) {
				handleCommandImpl(arguments);
				arguments.clear();
			}
			if(status==null || "Running".equals(status)) status="Done";
		}
		// Make the parent of all children the parent of this, and add children to the parents processes
		ShellInterpreter myparent=this.parent;
		synchronized(jobs) {
			for (ShellInterpreter shell : jobs) {
				shell.parent=myparent;
				if(myparent!=null) myparent.jobs.add(shell); // Should this synchronize myparent.jobs, too?
			}
			jobs.clear();
		}
	}
1259642
public function grant()
    {
        if (!$this->name) {
            throw new UnexpectedValueException(
                'Cannot grant privileges to a user with no name'
            );
        }
        if (!$this->grants) {
            throw new UnexpectedValueException(
                'Cannot grant privileges without being told what privileges to grant'
            );
        }
        if (!$this->grantLevel) {
            throw new UnexpectedValueException(
                'Cannot grant privileges without being told on what to grant them'
            );
        }

        $params = array();
        $parts = array(
            sprintf(
                'GRANT %s ON %s',
                strtolower($this->grants) == 'all'
                    ? 'ALL PRIVILEGES'
                    : $this->grants,
                $this->grantLevel
            )
        );

        $parts[] = 'TO :user';
        $params[':user'] = $this->name;

        if ($this->host) {
            $parts[] = '@:host';
            $params[':host'] = strtolower($this->host) == 'any' ? '%' : $this->host;
        }

        if ($this->grantGrant) {
            $parts[] = 'WITH GRANT OPTION';
        }
        
        // Wrap in 'FLUSH PRIVILEGES' commands to update in-memory state
        $this->client->execute('FLUSH PRIVILEGES');
        $this->client->execute(implode(' ', $parts), $params);
        $this->client->execute('FLUSH PRIVILEGES');
    }
371041
public function asPrintableString(): Primitive\PrintableString
    {
        if (!$this->_element instanceof Primitive\PrintableString) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_PRINTABLE_STRING));
        }
        return $this->_element;
    }
515492
protected function initContainer()
    {
        $container = $this->loadContainer(Configuration::projectDir() . $this->config['container']);

        if (!$container instanceof ContainerInterface) {
            throw new \UnexpectedValueException("Failed to get a container from '{$this->config['container']}'");
        }

        return $container;
    }
183137
private void processCommand(List<String> command) throws Exception {
        processBuilder.command(command);
        Process p = processBuilder.start();
        checkReturnCode(p, processBuilder.command().toString(), ReturnCode.OK.getValue(), ReturnCode.ALREADY_EXISTS.getValue());
        if (!acceptLicense) {
            throw new BuildException("To install a feature, you must accept the feature's license terms and conditions.");
        }
    }
429310
protected function installCliStep3()
    {
        $this->data['step'] = 3;
        $result = $this->installFinish($this->data, $this->db);

        if ($result['severity'] !== 'success') {
            throw new UnexpectedValueException($result['message']);
        }
    }
1179120
public void perform() {
		log.info(toString());

		WebElement element = finder.find();

		switch (stepMode) {
			case CHECK_VALUE:
				String checkValue = retrieveValue();
				if (checkTrafo != null) {
					checkValue = checkTrafo.trafo(checkValue);
				}
				checkValue(element, checkValue);
				break;

			case CHECK_DEFAULT:
				checkState(defaultsProvider != null, "No DefaultsProvider set when StepMode is CHECK_DEFAULT.");
				checkValue(element, defaultsProvider.get(element, dataSet, dataKey, dataIndex));
				break;

			case SET_VALUE:
				String setValue = retrieveValue();
				if (setTrafo != null) {
					setValue = setTrafo.trafo(setValue);
				}

				if (element.getTagName().equalsIgnoreCase(WebConstants.SELECT)) {

					Select select = new Select(element);
					// First check if a matching value can be found
					List<WebElement> options = select.getOptions();
					boolean found = false;
					for (WebElement option : options) {
						String optionValue = option.getAttribute(WebConstants.VALUE);
						if (StringUtils.equals(optionValue, setValue)) {
							/*
							 * WebElement with matching value could be found --> we are finished
							 */
							found = true;
							select.selectByValue(setValue);
							break;
						}
					}

					if (!found) {
						/*
						 * Fallback: look for a WebElement with a matching visible text
						 */
						for (WebElement option : options) {
							String visibleText = option.getText();
							if (StringUtils.equals(visibleText, setValue)) {
								/*
								 * WebElement with matching value could be found --> we are finished
								 */
								found = true;
								select.selectByVisibleText(setValue);
								break;
							}
						}
					}

					if (!found) {
						throw new JFunkException("Could not find a matching option element in " + element + " , By: "
								+ finder.getBy());
					}

				} else if (WebConstants.INPUT.equalsIgnoreCase(element.getTagName())
						&& WebConstants.RADIO.equals(element.getAttribute(WebConstants.TYPE))) {

					List<WebElement> elements = finder.findAll();
					for (WebElement webElement : elements) {
						String elVal = webElement.getAttribute(WebConstants.VALUE);
						if (elVal.equals(setValue) && !webElement.isSelected()) {
							webElement.click();
						}
					}

				} else if (WebConstants.CHECKBOX.equals(element.getAttribute(WebConstants.TYPE))) {

					if (Boolean.valueOf(setValue) && !element.isSelected() || !Boolean.valueOf(setValue) && element.isSelected()) {
						element.click();
					}

				} else {

					if (element.getAttribute("readonly") == null || element.getAttribute("readonly").equals("false")) {
						element.clear();
						element.sendKeys(setValue);
					} else {
						log.warn("Element is invisible or disabled, value cannot be set");
					}

				}
				break;

			case NONE:
				// do nothing
				break;

			default:
				throw new IllegalArgumentException("Unhandled StepMode=" + stepMode);
		}
	}
285949
protected void handleProcessTimeout(String[] cmd) throws IOException {
        StringBuilder bld   = new StringBuilder();
        boolean       first = true;
        for (String c : cmd) {
            if (first) {
                first = false;
            } else {
                bld.append(" ");
            }

            String esc = Strings.escape(c);

            // Quote where escaping is needed, OR the argument
            // contains a literal space.
            if (!c.equals(esc) || c.contains(" ")) {
                bld.append('\"')
                   .append(esc)
                   .append('\"');
            } else {
                bld.append(c);
            }
        }

        throw new IOException("Process took too long: " + bld.toString());
    }
147010
public function handle(Filesystem $filesystem, AddonEnvironment $env)
    {
        // make addons/
        $addons_directory = $env->path();
        if (!$filesystem->exists($addons_directory)) {
            $filesystem->makeDirectory($addons_directory);
        }

        $addon_name = $this->argument('addon');
        if (! $addon_name) {
            $addons = $env->addons();

            $this->line('--------');
            foreach ($addons as $addon) {
                $this->dump($addon);
                $this->line('--------');
            }
        }
        else {
            $addon = $env->addon($addon_name);

            // check addon
            if ($addon === null) {
                throw new UnexpectedValueException(sprintf('Addon "%s" is not found.', $addon_name));
            }

            $this->dump($addon);
        }
    }
919561
public function getHandler()
    {
        if(!$this->_handler instanceof KUserSessionHandlerInterface)
        {
            $this->_handler = $this->getObject($this->_handler);

            if(!$this->_handler instanceof KUserSessionHandlerInterface)
            {
                throw new UnexpectedValueException(
                    'Handler: '.get_class($this->_handler).' does not implement KUserSessionHandlerInterface'
                );
            }
        }

        return $this->_handler;
    }
193452
function (opts1 /*, …options*/) {
		var result = create(null);
		forEach.call(arguments, function (options) {
			if (!isValue$2(options)) { return; }
			process(Object(options), result);
		});
		return result;
	}
326012
private function processValue($value, $rootLevel = 0, $level = 0)
    {
        if ($value instanceof ServiceClosureArgument) {
            $value->setValues($this->processValue($value->getValues(), 1, 1));
        } elseif ($value instanceof ArgumentInterface) {
            $value->setValues($this->processValue($value->getValues(), $rootLevel, 1 + $level));
        } elseif ($value instanceof Definition) {
            if ($value->isSynthetic() || $value->isAbstract()) {
                return $value;
            }
            $value->setArguments($this->processValue($value->getArguments(), 0));
            $value->setProperties($this->processValue($value->getProperties(), 1));
            $value->setMethodCalls($this->processValue($value->getMethodCalls(), 2));
        } elseif (\is_array($value)) {
            $i = 0;

            foreach ($value as $k => $v) {
                if (!$rootLevel) {
                    $this->currentId = $k;
                }
                try {
                    if (false !== $i && $k !== $i++) {
                        $i = false;
                    }
                    if ($v !== $processedValue = $this->processValue($v, $rootLevel, 1 + $level)) {
                        $value[$k] = $processedValue;
                    }
                } catch (RuntimeException $e) {
                    if ($rootLevel < $level || ($rootLevel && !$level)) {
                        unset($value[$k]);
                    } elseif ($rootLevel) {
                        throw $e;
                    } else {
                        $value[$k] = null;
                    }
                }
            }

            // Ensure numerically indexed arguments have sequential numeric keys.
            if (false !== $i) {
                $value = array_values($value);
            }
        } elseif ($value instanceof Reference) {
            if ($this->container->has($id = (string) $value)) {
                return $value;
            }
            $invalidBehavior = $value->getInvalidBehavior();

            if (ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior && $value instanceof TypedReference && !$this->container->has($id)) {
                $e = new ServiceNotFoundException($id, $this->currentId);

                // since the error message varies by $id and $this->currentId, so should the id of the dummy errored definition
                $this->container->register($id = sprintf('.errored.%s.%s', $this->currentId, $id), $value->getType())
                    ->addError($e->getMessage());

                return new TypedReference($id, $value->getType(), $value->getInvalidBehavior());
            }

            // resolve invalid behavior
            if (ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) {
                $value = null;
            } elseif (ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) {
                if (0 < $level || $rootLevel) {
                    throw $this->signalingException;
                }
                $value = null;
            }
        }

        return $value;
    }
287445
public function activate($id, $args = [])
    {
        $plugin = $this->drivers->getDriver()->getPlugin($id);

        if (! $plugin) {
            throw new UnexpectedValueException("[W608] Cannot find the plugin: {$id}.");
        }

        $this->update($plugin, ['status' => 'activate']);
    }