diff --git a/Nette/Application/MicroPresenter.php b/Nette/Application/MicroPresenter.php index 59f36f4a53..abed12e26d 100644 --- a/Nette/Application/MicroPresenter.php +++ b/Nette/Application/MicroPresenter.php @@ -63,7 +63,7 @@ public function run(Application\Request $request) $params = $request->getParameters(); if (!isset($params['callback'])) { - throw new Application\BadRequestException("Parameter callback is missing."); + throw new Application\BadRequestException('Parameter callback is missing.'); } $params['presenter'] = $this; $callback = $params['callback']; diff --git a/Nette/Application/Responses/JsonResponse.php b/Nette/Application/Responses/JsonResponse.php index 7d8c06cad0..21f11afe91 100644 --- a/Nette/Application/Responses/JsonResponse.php +++ b/Nette/Application/Responses/JsonResponse.php @@ -34,7 +34,7 @@ class JsonResponse extends Nette\Object implements Nette\Application\IResponse public function __construct($payload, $contentType = NULL) { if (!is_array($payload) && !is_object($payload)) { - throw new Nette\InvalidArgumentException("Payload must be array or object class, " . gettype($payload) . " given."); + throw new Nette\InvalidArgumentException(sprintf('Payload must be array or object class, %s given.', gettype($payload))); } $this->payload = $payload; $this->contentType = $contentType ? $contentType : 'application/json'; diff --git a/Nette/Application/Routers/RouteList.php b/Nette/Application/Routers/RouteList.php index 79ab753a07..961ec5f273 100644 --- a/Nette/Application/Routers/RouteList.php +++ b/Nette/Application/Routers/RouteList.php @@ -119,7 +119,7 @@ public function constructUrl(Nette\Application\Request $appRequest, Nette\Http\U public function offsetSet($index, $route) { if (!$route instanceof Nette\Application\IRouter) { - throw new Nette\InvalidArgumentException("Argument must be IRouter descendant."); + throw new Nette\InvalidArgumentException('Argument must be IRouter descendant.'); } parent::offsetSet($index, $route); } diff --git a/Nette/Application/UI/PresenterComponent.php b/Nette/Application/UI/PresenterComponent.php index 9cbdd86b11..fec5b7ff48 100644 --- a/Nette/Application/UI/PresenterComponent.php +++ b/Nette/Application/UI/PresenterComponent.php @@ -166,7 +166,7 @@ public function saveState(array & $params, $reflection = NULL) $type = gettype($meta['def']); if (!PresenterComponentReflection::convertType($params[$name], $type)) { - throw new InvalidLinkException("Invalid value for persistent parameter '$name' in '{$this->getName()}', expected " . ($type === 'NULL' ? 'scalar' : $type) . "."); + throw new InvalidLinkException(sprintf("Invalid value for persistent parameter '%s' in '%s', expected %s.", $name, $this->getName(), $type === 'NULL' ? 'scalar' : $type)); } if ($params[$name] === $meta['def'] || ($meta['def'] === NULL && is_scalar($params[$name]) && (string) $params[$name] === '')) { diff --git a/Nette/Caching/Storages/FileStorage.php b/Nette/Caching/Storages/FileStorage.php index 7a28e3bcaf..96767c2906 100644 --- a/Nette/Caching/Storages/FileStorage.php +++ b/Nette/Caching/Storages/FileStorage.php @@ -147,16 +147,11 @@ public function lock($key) if ($this->useDirs && !is_dir($dir = dirname($cacheFile))) { @mkdir($dir); // @ - directory may already exist } - $handle = @fopen($cacheFile, 'r+b'); // @ - file may not exist - if (!$handle) { - $handle = fopen($cacheFile, 'wb'); - if (!$handle) { - return; - } + $handle = fopen($cacheFile, 'c+b'); + if ($handle) { + $this->locks[$key] = $handle; + flock($handle, LOCK_EX); } - - $this->locks[$key] = $handle; - flock($handle, LOCK_EX); } diff --git a/Nette/ComponentModel/Container.php b/Nette/ComponentModel/Container.php index 9b96e96e21..d4af706da2 100644 --- a/Nette/ComponentModel/Container.php +++ b/Nette/ComponentModel/Container.php @@ -47,7 +47,7 @@ public function addComponent(IComponent $component, $name, $insertBefore = NULL) $name = (string) $name; } elseif (!is_string($name)) { - throw new Nette\InvalidArgumentException("Component name must be integer or string, " . gettype($name) . " given."); + throw new Nette\InvalidArgumentException(sprintf('Component name must be integer or string, %s given.', gettype($name))); } elseif (!preg_match('#^[a-zA-Z0-9_]+\z#', $name)) { throw new Nette\InvalidArgumentException("Component name must be non-empty alphanumeric string, '$name' given."); @@ -120,7 +120,7 @@ public function getComponent($name, $need = TRUE) $name = (string) $name; } elseif (!is_string($name)) { - throw new Nette\InvalidArgumentException("Component name must be integer or string, " . gettype($name) . " given."); + throw new Nette\InvalidArgumentException(sprintf('Component name must be integer or string, %s given.', gettype($name))); } else { $a = strpos($name, self::NAME_SEPARATOR); @@ -131,7 +131,7 @@ public function getComponent($name, $need = TRUE) if ($name === '') { if ($need) { - throw new Nette\InvalidArgumentException("Component or subcomponent name must not be empty string."); + throw new Nette\InvalidArgumentException('Component or subcomponent name must not be empty string.'); } return; } diff --git a/Nette/DI/Compiler.php b/Nette/DI/Compiler.php index e08f314724..42bf52248f 100644 --- a/Nette/DI/Compiler.php +++ b/Nette/DI/Compiler.php @@ -257,7 +257,7 @@ public static function parseService(ServiceDefinition $definition, $config) $known = array('class', 'create', 'arguments', 'setup', 'autowired', 'inject', 'parameters', 'implement', 'run', 'tags'); if ($error = array_diff(array_keys($config), $known)) { - throw new Nette\InvalidStateException("Unknown or deprecated key '" . implode("', '", $error) . "' in definition of service."); + throw new Nette\InvalidStateException(sprintf("Unknown or deprecated key '%s' in definition of service.", implode("', '", $error))); } $arguments = array(); diff --git a/Nette/DI/Config/Adapters/IniAdapter.php b/Nette/DI/Config/Adapters/IniAdapter.php index cf6027bb3d..d35ddd7b3b 100644 --- a/Nette/DI/Config/Adapters/IniAdapter.php +++ b/Nette/DI/Config/Adapters/IniAdapter.php @@ -135,7 +135,7 @@ private static function build($input, & $output, $prefix) $output[] = "$prefix$key = \"$val\""; } else { - throw new Nette\InvalidArgumentException("The '$prefix$key' item must be scalar or array, " . gettype($val) ." given."); + throw new Nette\InvalidArgumentException(sprintf("The '%s' item must be scalar or array, %s given.", $prefix . $key, gettype($val))); } } } diff --git a/Nette/DI/Container.php b/Nette/DI/Container.php index 7ad0f647a9..a666d88ee4 100644 --- a/Nette/DI/Container.php +++ b/Nette/DI/Container.php @@ -60,18 +60,18 @@ public function addService($name, $service) throw new Nette\DeprecatedException('Parameter $meta has been removed.'); } elseif (!is_string($name) || !$name) { - throw new Nette\InvalidArgumentException('Service name must be a non-empty string, ' . gettype($name) . ' given.'); + throw new Nette\InvalidArgumentException(sprintf('Service name must be a non-empty string, %s given.', gettype($name))); } elseif (isset($this->registry[$name])) { throw new Nette\InvalidStateException("Service '$name' already exists."); } elseif (is_string($service) || is_array($service) || $service instanceof \Closure || $service instanceof Nette\Callback) { - trigger_error('Passing factories to ' . __METHOD__ . '() is deprecated; pass the object itself.', E_USER_DEPRECATED); + trigger_error(sprintf('Passing factories to %s() is deprecated; pass the object itself.', __METHOD__), E_USER_DEPRECATED); $service = is_string($service) && !preg_match('#\x00|:#', $service) ? new $service : call_user_func($service, $this); } if (!is_object($service)) { - throw new Nette\InvalidArgumentException('Service must be a object, ' . gettype($service) . ' given.'); + throw new Nette\InvalidArgumentException(sprintf('Service must be a object, %s given.', gettype($service))); } $this->registry[$name] = $service; @@ -141,8 +141,7 @@ public function createService($name, array $args = array()) { $method = Container::getMethodName($name); if (isset($this->creating[$name])) { - throw new Nette\InvalidStateException("Circular reference detected for services: " - . implode(', ', array_keys($this->creating)) . "."); + throw new Nette\InvalidStateException(sprintf('Circular reference detected for services: %s.', implode(', ', array_keys($this->creating)))); } elseif (!method_exists($this, $method) || $this->getReflection()->getMethod($method)->getName() !== $method) { throw new MissingServiceException("Service '$name' not found."); @@ -244,7 +243,7 @@ public function createInstance($class, array $args = array()) public function callInjects($service) { if (!is_object($service)) { - throw new Nette\InvalidArgumentException('Service must be object, ' . gettype($service) . ' given.'); + throw new Nette\InvalidArgumentException(sprintf('Service must be object, %s given.', gettype($service))); } foreach (array_reverse(get_class_methods($service)) as $method) { diff --git a/Nette/DI/ContainerBuilder.php b/Nette/DI/ContainerBuilder.php index f0ca28fba7..4d15747bef 100644 --- a/Nette/DI/ContainerBuilder.php +++ b/Nette/DI/ContainerBuilder.php @@ -53,7 +53,7 @@ class ContainerBuilder extends Nette\Object public function addDefinition($name, ServiceDefinition $definition = NULL) { if (!is_string($name) || !$name) { // builder is not ready for falsy names such as '0' - throw new Nette\InvalidArgumentException("Service name must be a non-empty string, " . gettype($name) . " given."); + throw new Nette\InvalidArgumentException(sprintf('Service name must be a non-empty string, %s given.', gettype($name))); } elseif (isset($this->definitions[$name])) { throw new Nette\InvalidStateException("Service '$name' has already been added."); @@ -295,7 +295,7 @@ public function prepareClassList() private function resolveClass($name, $recursive = array()) { if (isset($recursive[$name])) { - throw new ServiceCreationException('Circular reference detected for services: ' . implode(', ', array_keys($recursive)) . '.'); + throw new ServiceCreationException(sprintf('Circular reference detected for services: %s.', implode(', ', array_keys($recursive)))); } $recursive[$name] = TRUE; @@ -320,12 +320,12 @@ private function resolveClass($name, $recursive = array()) } } if (!is_callable($factory)) { - throw new ServiceCreationException("Factory '" . Nette\Utils\Callback::toString($factory) . "' is not callable."); + throw new ServiceCreationException(sprintf("Factory '%s' is not callable.", Nette\Utils\Callback::toString($factory))); } try { $reflection = Nette\Utils\Callback::toReflection($factory); } catch (\ReflectionException $e) { - throw new ServiceCreationException("Missing factory '" . Nette\Utils\Callback::toString($factory) . "'."); + throw new ServiceCreationException(sprintf("Missing factory '%s'.", Nette\Utils\Callback::toString($factory))); } $def->class = preg_replace('#[|\s].*#', '', $reflection->getAnnotation('return')); if ($def->class && $reflection instanceof \ReflectionMethod) { @@ -417,7 +417,7 @@ public function generateClasses($className = 'Container', $parentName = 'Nette\D throw new ServiceCreationException('Name contains invalid characters.'); } $containerClass->addMethod($methodName) - ->addDocument("@return " . ($def->implement ?: $def->class)) + ->addDocument('@return ' . ($def->implement ?: $def->class)) ->setBody($name === self::THIS_CONTAINER ? 'return $this;' : $this->generateService($name)) ->setParameters($def->implement ? array() : $this->convertParameters($def->parameters)); } catch (\Exception $e) { @@ -568,7 +568,7 @@ public function formatStatement(Statement $statement) return $this->formatPhp("new $entity" . ($arguments ? '(?*)' : ''), array($arguments)); } elseif (!Nette\Utils\Arrays::isList($entity) || count($entity) !== 2) { - throw new ServiceCreationException("Expected class, method or property, " . PhpHelpers::dump($entity) . " given."); + throw new ServiceCreationException(sprintf('Expected class, method or property, %s given.', PhpHelpers::dump($entity))); } elseif ($entity[0] === '') { // globalFunc return $this->formatPhp("$entity[1](?*)", array($arguments)); diff --git a/Nette/DI/Helpers.php b/Nette/DI/Helpers.php index 30a37c5dd3..1dcaa17b42 100644 --- a/Nette/DI/Helpers.php +++ b/Nette/DI/Helpers.php @@ -56,10 +56,14 @@ public static function expand($var, array $params, $recursive = FALSE) $res .= '%'; } elseif (isset($recursive[$part])) { - throw new Nette\InvalidArgumentException('Circular reference detected for variables: ' . implode(', ', array_keys($recursive)) . '.'); + throw new Nette\InvalidArgumentException(sprintf('Circular reference detected for variables: %s.', implode(', ', array_keys($recursive)))); } else { - $val = Nette\Utils\Arrays::get($params, explode('.', $part)); + try { + $val = Nette\Utils\Arrays::get($params, explode('.', $part)); + } catch (Nette\InvalidArgumentException $e) { + throw new Nette\InvalidArgumentException("Missing parameter '$part'.", 0, $e); + } if ($recursive) { $val = self::expand($val, $params, (is_array($recursive) ? $recursive : array()) + array($part => 1)); } diff --git a/Nette/Database/Drivers/OdbcDriver.php b/Nette/Database/Drivers/OdbcDriver.php index 9951c2078b..d7d0a622a8 100644 --- a/Nette/Database/Drivers/OdbcDriver.php +++ b/Nette/Database/Drivers/OdbcDriver.php @@ -53,7 +53,7 @@ public function formatBool($value) */ public function formatDateTime(/*\DateTimeInterface*/ $value) { - return $value->format("#m/d/Y H:i:s#"); + return $value->format('#m/d/Y H:i:s#'); } diff --git a/Nette/Database/Drivers/SqliteDriver.php b/Nette/Database/Drivers/SqliteDriver.php index 2ea23bfa89..abf78cdc6b 100644 --- a/Nette/Database/Drivers/SqliteDriver.php +++ b/Nette/Database/Drivers/SqliteDriver.php @@ -149,7 +149,7 @@ public function getColumns($table) 'nullable' => $row['notnull'] == '0', 'default' => $row['dflt_value'], 'autoincrement' => (bool) preg_match($pattern, $meta['sql']), - 'primary' => $row['pk'] == '1', + 'primary' => $row['pk'] > 0, 'vendor' => (array) $row, ); } diff --git a/Nette/Database/Helpers.php b/Nette/Database/Helpers.php index 404af97410..b7af9e271c 100644 --- a/Nette/Database/Helpers.php +++ b/Nette/Database/Helpers.php @@ -86,7 +86,7 @@ public static function dumpSql($sql, array $params = NULL) $sql = preg_replace("#(?<=[\\s,(])($keywords1)(?=[\\s,)])#i", "\n\$1", $sql); // reduce spaces - $sql = preg_replace('#[ \t]{2,}#', " ", $sql); + $sql = preg_replace('#[ \t]{2,}#', ' ', $sql); $sql = wordwrap($sql, 100); $sql = preg_replace('#([ \t]*\r?\n){2,}#', "\n", $sql); @@ -126,7 +126,7 @@ public static function dumpSql($sql, array $params = NULL) if ($type === 'stream') { $info = stream_get_meta_data($param); } - return '<' . htmlSpecialChars($type) . " resource> "; + return '<' . htmlSpecialChars($type) . ' resource> '; } else { return htmlspecialchars($param); @@ -177,7 +177,7 @@ public static function detectType($type) /** - * Import SQL dump from file - extreme fast. + * Import SQL dump from file - extremely fast. * @return int count of commands */ public static function loadFromFile(Connection $connection, $file) diff --git a/Nette/Database/Table/ActiveRow.php b/Nette/Database/Table/ActiveRow.php index 10ad5b676c..9216b5cb2f 100644 --- a/Nette/Database/Table/ActiveRow.php +++ b/Nette/Database/Table/ActiveRow.php @@ -284,7 +284,7 @@ public function &__get($key) } catch(MissingReferenceException $e) {} $this->removeAccessColumn($key); - throw new Nette\MemberAccessException("Cannot read an undeclared column \"$key\"."); + throw new Nette\MemberAccessException("Cannot read an undeclared column '$key'."); } diff --git a/Nette/Database/Table/Selection.php b/Nette/Database/Table/Selection.php index e4ce2ce05d..7051adfaad 100644 --- a/Nette/Database/Table/Selection.php +++ b/Nette/Database/Table/Selection.php @@ -143,7 +143,7 @@ public function getName() public function getPrimary($need = TRUE) { if ($this->primary === NULL && $need) { - throw new \LogicException("Table \"{$this->name}\" does not have a primary key."); + throw new \LogicException("Table '{$this->name}' does not have a primary key."); } return $this->primary; } @@ -602,7 +602,7 @@ protected function loadRefCache() /** - * Returns general cache key indenpendent on query parameters or sql limit + * Returns general cache key independent on query parameters or sql limit * Used e.g. for previously accessed columns caching * @return string */ diff --git a/Nette/Diagnostics/templates/bluescreen.css b/Nette/Diagnostics/templates/bluescreen.css index 397ddcc2c3..9724241f64 100644 --- a/Nette/Diagnostics/templates/bluescreen.css +++ b/Nette/Diagnostics/templates/bluescreen.css @@ -9,11 +9,6 @@ html { overflow-y: scroll; } -body { - margin: 0 0 2em; - padding: 0; -} - #netteBluescreen { font: 9pt/1.5 Verdana, sans-serif; background: white; diff --git a/Nette/Diagnostics/templates/bluescreen.phtml b/Nette/Diagnostics/templates/bluescreen.phtml index 91defd30a1..fea7044b96 100644 --- a/Nette/Diagnostics/templates/bluescreen.phtml +++ b/Nette/Diagnostics/templates/bluescreen.phtml @@ -46,7 +46,7 @@ $counter = 0;

getCode() ? ' #' . $exception->getCode() : '') ?>

-

getMessage(), ENT_IGNORE) ?> getMessage())) ?>" id="netteBsSearch">search►

+

getMessage(), ENT_IGNORE) ?> getMessage())) ?>" id="netteBsSearch" rel="noreferrer">search►

getPrevious()): ?> diff --git a/Nette/Forms/Container.php b/Nette/Forms/Container.php index 5730cef30a..75c883227c 100644 --- a/Nette/Forms/Container.php +++ b/Nette/Forms/Container.php @@ -65,7 +65,7 @@ public function setValues($values, $erase = FALSE) $values = iterator_to_array($values); } elseif (!is_array($values)) { - throw new Nette\InvalidArgumentException('First parameter must be an array, ' . gettype($values) . ' given.'); + throw new Nette\InvalidArgumentException(sprintf('First parameter must be an array, %s given.', gettype($values))); } foreach ($this->getComponents() as $name => $control) { diff --git a/Nette/Forms/Controls/BaseControl.php b/Nette/Forms/Controls/BaseControl.php index ffb7c438be..de8e9a1b8e 100644 --- a/Nette/Forms/Controls/BaseControl.php +++ b/Nette/Forms/Controls/BaseControl.php @@ -561,7 +561,7 @@ protected static function exportRules($rules) /** - * Equal validator: are control's value and second parameter equal? + * Is control's value equal with second parameter? * @return bool */ public static function validateEqual(IControl $control, $arg) @@ -590,7 +590,7 @@ public static function validateNotEqual(IControl $control, $arg) /** - * Filled validator: is control filled? + * Is control filled? * @return bool */ public static function validateFilled(IControl $control) @@ -610,7 +610,7 @@ public static function validateBlank(IControl $control) /** - * Valid validator: is control valid? + * Is control valid? * @return bool */ public static function validateValid(IControl $control) @@ -620,7 +620,7 @@ public static function validateValid(IControl $control) /** - * Rangle validator: is a control's value number in specified range? + * Is a control's value number in specified range? * @param Nette\Forms\IControl * @param array min and max value pair * @return bool @@ -646,7 +646,7 @@ public static function validateLength(IControl $control, $range) /** - * Min-length validator: has control's value minimal count/length? + * Has control's value minimal count/length? * @return bool */ public static function validateMinLength(IControl $control, $length) @@ -656,7 +656,7 @@ public static function validateMinLength(IControl $control, $length) /** - * Max-length validator: is control's value count/length in limit? + * Is control's value count/length in limit? * @return bool */ public static function validateMaxLength(IControl $control, $length) diff --git a/Nette/Forms/Controls/Checkbox.php b/Nette/Forms/Controls/Checkbox.php index 76cdc2b6a4..0b7fa33eda 100644 --- a/Nette/Forms/Controls/Checkbox.php +++ b/Nette/Forms/Controls/Checkbox.php @@ -40,7 +40,7 @@ public function __construct($label = NULL) public function setValue($value) { if (!is_scalar($value) && $value !== NULL) { - throw new Nette\InvalidArgumentException('Value must be scalar or NULL, ' . gettype($value) . " given in field '{$this->name}'."); + throw new Nette\InvalidArgumentException(sprintf("Value must be scalar or NULL, %s given in field '%s'.", gettype($value), $this->name)); } $this->value = (bool) $value; return $this; diff --git a/Nette/Forms/Controls/ChoiceControl.php b/Nette/Forms/Controls/ChoiceControl.php index 2755320709..b536a1c5a2 100644 --- a/Nette/Forms/Controls/ChoiceControl.php +++ b/Nette/Forms/Controls/ChoiceControl.php @@ -58,8 +58,8 @@ public function loadHttpData() */ public function setValue($value) { - if ($value !== NULL && !isset($this->items[(string) $value])) { - $range = Nette\Utils\Strings::truncate(implode(', ', array_map(function($s) { return var_export($s, TRUE); }, $this->items)), 70, '...'); + if ($value !== NULL && !array_key_exists((string) $value, $this->items)) { + $range = Nette\Utils\Strings::truncate(implode(', ', array_map(function($s) { return var_export($s, TRUE); }, array_keys($this->items))), 70, '...'); throw new Nette\InvalidArgumentException("Value '$value' is out of allowed range [$range] in field '{$this->name}'."); } $this->value = $value === NULL ? NULL : key(array((string) $value => NULL)); @@ -73,7 +73,7 @@ public function setValue($value) */ public function getValue() { - return isset($this->items[$this->value]) ? $this->value : NULL; + return array_key_exists($this->value, $this->items) ? $this->value : NULL; } diff --git a/Nette/Forms/Controls/HiddenField.php b/Nette/Forms/Controls/HiddenField.php index b30efdea70..664fcbc336 100644 --- a/Nette/Forms/Controls/HiddenField.php +++ b/Nette/Forms/Controls/HiddenField.php @@ -41,7 +41,7 @@ public function __construct($persistentValue = NULL) public function setValue($value) { if (!is_scalar($value) && $value !== NULL && !method_exists($value, '__toString')) { - throw new Nette\InvalidArgumentException('Value must be scalar or NULL, ' . gettype($value) . " given in field '{$this->name}'."); + throw new Nette\InvalidArgumentException(sprintf("Value must be scalar or NULL, %s given in field '%s'.", gettype($value), $this->name)); } if (!$this->persistValue) { $this->value = (string) $value; diff --git a/Nette/Forms/Controls/MultiChoiceControl.php b/Nette/Forms/Controls/MultiChoiceControl.php index 3ae3a1cc43..c5bac0fcac 100644 --- a/Nette/Forms/Controls/MultiChoiceControl.php +++ b/Nette/Forms/Controls/MultiChoiceControl.php @@ -57,18 +57,18 @@ public function setValue($values) if (is_scalar($values) || $values === NULL) { $values = (array) $values; } elseif (!is_array($values)) { - throw new Nette\InvalidArgumentException('Value must be array or NULL, ' . gettype($values) . " given in field '{$this->name}'."); + throw new Nette\InvalidArgumentException(sprintf("Value must be array or NULL, %s given in field '%s'.", gettype($values), $this->name)); } $flip = array(); foreach ($values as $value) { if (!is_scalar($value) && !method_exists($value, '__toString')) { - throw new Nette\InvalidArgumentException('Values must be scalar, ' . gettype($value) . " given in field '{$this->name}'."); + throw new Nette\InvalidArgumentException(sprintf("Values must be scalar, %s given in field '%s'.", gettype($value), $this->name)); } $flip[(string) $value] = TRUE; } $values = array_keys($flip); if ($diff = array_diff($values, array_keys($this->items))) { - $range = Nette\Utils\Strings::truncate(implode(', ', array_map(function($s) { return var_export($s, TRUE); }, $this->items)), 70, '...'); + $range = Nette\Utils\Strings::truncate(implode(', ', array_map(function($s) { return var_export($s, TRUE); }, array_keys($this->items))), 70, '...'); $vals = (count($diff) > 1 ? 's' : '') . " '" . implode("', '", $diff) . "'"; throw new Nette\InvalidArgumentException("Value$vals are out of allowed range [$range] in field '{$this->name}'."); } diff --git a/Nette/Forms/Controls/RadioList.php b/Nette/Forms/Controls/RadioList.php index 8d70b97bee..2ab3578aa1 100644 --- a/Nette/Forms/Controls/RadioList.php +++ b/Nette/Forms/Controls/RadioList.php @@ -82,7 +82,7 @@ public function getContainerPrototype() public function getControl($key = NULL) { if ($key !== NULL) { - trigger_error('Partial ' . __METHOD__ . '() is deprecated; use getControlPart() instead.', E_USER_DEPRECATED); + trigger_error(sprintf('Partial %s() is deprecated; use getControlPart() instead.', __METHOD__), E_USER_DEPRECATED); return $this->getControlPart($key); } @@ -116,7 +116,7 @@ public function getControl($key = NULL) public function getLabel($caption = NULL, $key = NULL) { if ($key !== NULL) { - trigger_error('Partial ' . __METHOD__ . '() is deprecated; use getLabelPart() instead.', E_USER_DEPRECATED); + trigger_error(sprintf('Partial %s() is deprecated; use getLabelPart() instead.', __METHOD__), E_USER_DEPRECATED); return $this->getLabelPart($key); } return parent::getLabel($caption)->for(NULL); diff --git a/Nette/Forms/Controls/SelectBox.php b/Nette/Forms/Controls/SelectBox.php index 45e24a144d..9ef152ffe9 100644 --- a/Nette/Forms/Controls/SelectBox.php +++ b/Nette/Forms/Controls/SelectBox.php @@ -111,7 +111,7 @@ public function getControl() public function validate() { parent::validate(); - if (!$this->isDisabled() && $this->prompt === FALSE && $this->getValue() === NULL) { + if (!$this->isDisabled() && $this->prompt === FALSE && $this->getValue() === NULL && $this->options) { $this->addError(Nette\Forms\Rules::$defaultMessages[self::VALID]); } } diff --git a/Nette/Forms/Controls/TextBase.php b/Nette/Forms/Controls/TextBase.php index 021bd09896..58693d2ea0 100644 --- a/Nette/Forms/Controls/TextBase.php +++ b/Nette/Forms/Controls/TextBase.php @@ -42,7 +42,7 @@ public function setValue($value) if ($value === NULL) { $value = ''; } elseif (!is_scalar($value) && !method_exists($value, '__toString')) { - throw new Nette\InvalidArgumentException('Value must be scalar or NULL, ' . gettype($value) . " given in field '{$this->name}'."); + throw new Nette\InvalidArgumentException(sprintf("Value must be scalar or NULL, %s given in field '%s'.", gettype($value), $this->name)); } $this->rawValue = $this->value = $value; return $this; @@ -129,8 +129,7 @@ public function addRule($operation, $message = NULL, $arg = NULL) /** - * Email validator: is control's value valid email address? - * @param TextBase + * Is control's value valid email address? * @return bool */ public static function validateEmail(TextBase $control) @@ -140,8 +139,7 @@ public static function validateEmail(TextBase $control) /** - * URL validator: is control's value valid URL? - * @param TextBase + * Is control's value valid URL? * @return bool */ public static function validateUrl(TextBase $control) @@ -177,9 +175,7 @@ public static function validateRegexp(TextBase $control, $regexp) /** - * Regular expression validator: matches control's value regular expression? - * @param TextBase - * @param string + * Matches control's value regular expression? * @return bool */ public static function validatePattern(TextBase $control, $pattern) @@ -189,8 +185,7 @@ public static function validatePattern(TextBase $control, $pattern) /** - * Integer validator: is a control's value decimal number? - * @param TextBase + * Is a control's value decimal number? * @return bool */ public static function validateInteger(TextBase $control) @@ -206,8 +201,7 @@ public static function validateInteger(TextBase $control) /** - * Float validator: is a control's value float number? - * @param TextBase + * Is a control's value float number? * @return bool */ public static function validateFloat(TextBase $control) diff --git a/Nette/Forms/Controls/UploadControl.php b/Nette/Forms/Controls/UploadControl.php index 9d643efb62..3061e67063 100644 --- a/Nette/Forms/Controls/UploadControl.php +++ b/Nette/Forms/Controls/UploadControl.php @@ -95,9 +95,7 @@ public function isFilled() /** - * FileSize validator: is file size in limit? - * @param UploadControl - * @param int file size limit + * Is file size in limit? * @return bool */ public static function validateFileSize(UploadControl $control, $limit) @@ -112,9 +110,7 @@ public static function validateFileSize(UploadControl $control, $limit) /** - * MimeType validator: has file specified mime type? - * @param UploadControl - * @param array|string mime type + * Has file specified mime type? * @return bool */ public static function validateMimeType(UploadControl $control, $mimeType) @@ -131,7 +127,7 @@ public static function validateMimeType(UploadControl $control, $mimeType) /** - * Image validator: is file image? + * Is file image? * @return bool */ public static function validateImage(UploadControl $control) diff --git a/Nette/Forms/Rendering/DefaultFormRenderer.php b/Nette/Forms/Rendering/DefaultFormRenderer.php index 5c8ab5911d..a81e7084e3 100644 --- a/Nette/Forms/Rendering/DefaultFormRenderer.php +++ b/Nette/Forms/Rendering/DefaultFormRenderer.php @@ -324,7 +324,7 @@ public function renderBody() public function renderControls($parent) { if (!($parent instanceof Nette\Forms\Container || $parent instanceof Nette\Forms\ControlGroup)) { - throw new Nette\InvalidArgumentException("Argument must be FormContainer or FormGroup instance."); + throw new Nette\InvalidArgumentException('Argument must be FormContainer or FormGroup instance.'); } $container = $this->getWrapper('controls container'); @@ -389,7 +389,7 @@ public function renderPairMulti(array $controls) $s = array(); foreach ($controls as $control) { if (!$control instanceof Nette\Forms\IControl) { - throw new Nette\InvalidArgumentException("Argument must be array of IFormControl instances."); + throw new Nette\InvalidArgumentException('Argument must be array of IFormControl instances.'); } $description = $control->getOption('description'); if ($description instanceof Html) { @@ -406,7 +406,7 @@ public function renderPairMulti(array $controls) } $pair = $this->getWrapper('pair container'); $pair->add($this->renderLabel($control)); - $pair->add($this->getWrapper('control container')->setHtml(implode(" ", $s))); + $pair->add($this->getWrapper('control container')->setHtml(implode(' ', $s))); return $pair->render(0); } diff --git a/Nette/Forms/Rules.php b/Nette/Forms/Rules.php index c393b79757..67176effb1 100644 --- a/Nette/Forms/Rules.php +++ b/Nette/Forms/Rules.php @@ -329,5 +329,4 @@ public static function formatMessage($rule, $withValue) return $message; } - } diff --git a/Nette/Http/FileUpload.php b/Nette/Http/FileUpload.php index 27eb9b2048..1409b19c69 100644 --- a/Nette/Http/FileUpload.php +++ b/Nette/Http/FileUpload.php @@ -118,7 +118,7 @@ public function getTemporaryFile() */ public function __toString() { - return $this->tmpName; + return (string) $this->tmpName; } diff --git a/Nette/Http/Response.php b/Nette/Http/Response.php index dfa3bf3a21..3382f32c66 100644 --- a/Nette/Http/Response.php +++ b/Nette/Http/Response.php @@ -92,7 +92,7 @@ public function getCode() public function setHeader($name, $value) { self::checkHeaders(); - if ($value === NULL && function_exists('header_remove')) { + if ($value === NULL) { header_remove($name); } elseif (strcasecmp($name, 'Content-Length') === 0 && ini_get('zlib.output_compression')) { // ignore, PHP bug #44164 diff --git a/Nette/Iterators/CachingIterator.php b/Nette/Iterators/CachingIterator.php index 75e933b485..4a6489eef6 100644 --- a/Nette/Iterators/CachingIterator.php +++ b/Nette/Iterators/CachingIterator.php @@ -47,7 +47,7 @@ public function __construct($iterator) } } else { - throw new Nette\InvalidArgumentException("Invalid argument passed to foreach resp. " . __CLASS__ . "; array or Traversable expected, " . (is_object($iterator) ? get_class($iterator) : gettype($iterator)) ." given."); + throw new Nette\InvalidArgumentException(sprintf('Invalid argument passed to foreach resp. %s; array or Traversable expected, %s given.', __CLASS__, is_object($iterator) ? get_class($iterator) : gettype($iterator))); } parent::__construct($iterator, 0); diff --git a/Nette/Latte/Macros/CoreMacros.php b/Nette/Latte/Macros/CoreMacros.php index dd5e0002af..1335521a03 100644 --- a/Nette/Latte/Macros/CoreMacros.php +++ b/Nette/Latte/Macros/CoreMacros.php @@ -143,7 +143,7 @@ public function macroElse(MacroNode $node, PhpWriter $writer) $ifNode = $node->parentNode; if ($ifNode && $ifNode->name === 'if' && $ifNode->data->capture) { if (isset($ifNode->data->else)) { - throw new CompileException("Macro {if} supports only one {else}."); + throw new CompileException('Macro {if} supports only one {else}.'); } $ifNode->data->else = TRUE; return 'ob_start()'; @@ -244,7 +244,7 @@ public function macroCapture(MacroNode $node, PhpWriter $writer) */ public function macroCaptureEnd(MacroNode $node, PhpWriter $writer) { - return $node->data->variable . $writer->write(" = %modify(ob_get_clean())"); + return $node->data->variable . $writer->write(' = %modify(ob_get_clean())'); } @@ -362,7 +362,7 @@ public function macroVar(MacroNode $node, PhpWriter $writer) $var = TRUE; } elseif ($var === NULL && $node->name === 'default' && !$tokens->isCurrent(Latte\MacroTokens::T_WHITESPACE)) { - throw new CompileException("Unexpected '" . $tokens->currentValue() . "' in {default $node->args}"); + throw new CompileException("Unexpected '{$tokens->currentValue()}' in {default $node->args}"); } else { $res->append($tokens->currentToken()); diff --git a/Nette/Latte/PhpWriter.php b/Nette/Latte/PhpWriter.php index 6b63a3230e..e171baf68e 100644 --- a/Nette/Latte/PhpWriter.php +++ b/Nette/Latte/PhpWriter.php @@ -325,7 +325,7 @@ public function modifiersFilter(MacroTokens $tokens, $var) $inside = TRUE; } } else { - throw new CompileException("Modifier name must be alphanumeric string, '" . $tokens->currentValue() . "' given."); + throw new CompileException("Modifier name must be alphanumeric string, '{$tokens->currentValue()}' given."); } } } diff --git a/Nette/Mail/Message.php b/Nette/Mail/Message.php index acfef6bd1d..54909ab5bf 100644 --- a/Nette/Mail/Message.php +++ b/Nette/Mail/Message.php @@ -244,7 +244,7 @@ public function setHtmlBody($html, $basePath = NULL) foreach (array_reverse($matches) as $m) { $file = rtrim($basePath, '/\\') . '/' . $m[3][0]; if (!isset($cids[$file])) { - $cids[$file] = substr($this->addEmbeddedFile($file)->getHeader("Content-ID"), 1, -1); + $cids[$file] = substr($this->addEmbeddedFile($file)->getHeader('Content-ID'), 1, -1); } $html = substr_replace($html, "{$m[1][0]}{$m[2][0]}cid:{$cids[$file]}", diff --git a/Nette/Mail/MimePart.php b/Nette/Mail/MimePart.php index fb5b674131..a819968870 100644 --- a/Nette/Mail/MimePart.php +++ b/Nette/Mail/MimePart.php @@ -72,7 +72,7 @@ public function setHeader($name, $value, $append = FALSE) Nette\Utils\Validators::assert($recipient, 'unicode', "header '$name'"); } if (preg_match('#[\r\n]#', $recipient)) { - throw new Nette\InvalidArgumentException("Name must not contain line separator."); + throw new Nette\InvalidArgumentException('Name must not contain line separator.'); } Nette\Utils\Validators::assert($email, 'email', "header '$name'"); $tmp[$email] = $recipient; @@ -81,7 +81,7 @@ public function setHeader($name, $value, $append = FALSE) } else { $value = (string) $value; if (!Strings::checkEncoding($value)) { - throw new Nette\InvalidArgumentException("Header is not valid UTF-8 string."); + throw new Nette\InvalidArgumentException('Header is not valid UTF-8 string.'); } $this->headers[$name] = preg_replace('#[\r\n]+#', ' ', $value); } @@ -257,7 +257,7 @@ public function getEncodedMessage() if ($body !== '') { switch ($this->getEncoding()) { case self::ENCODING_QUOTED_PRINTABLE: - $output .= function_exists('quoted_printable_encode') ? quoted_printable_encode($body) : self::encodeQuotedPrintable($body); + $output .= quoted_printable_encode($body); break; case self::ENCODING_BASE64: diff --git a/Nette/Mail/SendmailMailer.php b/Nette/Mail/SendmailMailer.php index 14c22017f0..875b7a164b 100644 --- a/Nette/Mail/SendmailMailer.php +++ b/Nette/Mail/SendmailMailer.php @@ -34,8 +34,8 @@ public function send(Message $mail) $parts = explode(Message::EOL . Message::EOL, $tmp->generateMessage(), 2); $args = array( - $mail->getEncodedHeader('To'), - $mail->getEncodedHeader('Subject'), + str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('To')), + str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')), str_replace(Message::EOL, PHP_EOL, $parts[1]), str_replace(Message::EOL, PHP_EOL, $parts[0]), ); diff --git a/Nette/Reflection/AnnotationsParser.php b/Nette/Reflection/AnnotationsParser.php index 041df03162..8923b801da 100644 --- a/Nette/Reflection/AnnotationsParser.php +++ b/Nette/Reflection/AnnotationsParser.php @@ -28,6 +28,9 @@ class AnnotationsParser /** @var bool */ public static $useReflection; + /** @var bool */ + public static $useAnnotationClasses = TRUE; + /** @var array */ public static $inherited = array('description', 'param', 'return'); @@ -248,7 +251,7 @@ private static function parseComment($comment) } $class = $name . 'Annotation'; - if (class_exists($class)) { + if (self::$useAnnotationClasses && class_exists($class)) { $res[$name][] = new $class(is_array($value) ? $value : array('value' => $value)); } else { diff --git a/Nette/Security/Permission.php b/Nette/Security/Permission.php index 9d34a32d59..ca1ace7de5 100644 --- a/Nette/Security/Permission.php +++ b/Nette/Security/Permission.php @@ -114,7 +114,7 @@ public function hasRole($role) private function checkRole($role, $need = TRUE) { if (!is_string($role) || $role === '') { - throw new Nette\InvalidArgumentException("Role must be a non-empty string."); + throw new Nette\InvalidArgumentException('Role must be a non-empty string.'); } elseif ($need && !isset($this->roles[$role])) { throw new Nette\InvalidStateException("Role '$role' does not exist."); @@ -294,7 +294,7 @@ public function hasResource($resource) private function checkResource($resource, $need = TRUE) { if (!is_string($resource) || $resource === '') { - throw new Nette\InvalidArgumentException("Resource must be a non-empty string."); + throw new Nette\InvalidArgumentException('Resource must be a non-empty string.'); } elseif ($need && !isset($this->resources[$resource])) { throw new Nette\InvalidStateException("Resource '$resource' does not exist."); diff --git a/Nette/Security/SimpleAuthenticator.php b/Nette/Security/SimpleAuthenticator.php index 0841e30bef..4acc7c9265 100644 --- a/Nette/Security/SimpleAuthenticator.php +++ b/Nette/Security/SimpleAuthenticator.php @@ -44,7 +44,7 @@ public function authenticate(array $credentials) if ((string) $pass === (string) $password) { return new Identity($name); } else { - throw new AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL); + throw new AuthenticationException('Invalid password.', self::INVALID_CREDENTIAL); } } } diff --git a/Nette/Utils/Callback.php b/Nette/Utils/Callback.php index 18ba0990f9..0960c1eb8e 100644 --- a/Nette/Utils/Callback.php +++ b/Nette/Utils/Callback.php @@ -70,7 +70,7 @@ public static function check($callable, $syntax = FALSE) if (!is_callable($callable, $syntax)) { throw new Nette\InvalidArgumentException($syntax ? 'Given value is not a callable type.' - : "Callback '" . self::toString($callable) . "' is not callable." + : sprintf("Callback '%s' is not callable.", self::toString($callable)) ); } return $callable; diff --git a/Nette/Utils/Html.php b/Nette/Utils/Html.php index cd22d22bd0..63b5b8f0da 100644 --- a/Nette/Utils/Html.php +++ b/Nette/Utils/Html.php @@ -84,7 +84,7 @@ public static function el($name = NULL, $attrs = NULL) public function setName($name, $isEmpty = NULL) { if ($name !== NULL && !is_string($name)) { - throw new Nette\InvalidArgumentException("Name must be string or NULL, " . gettype($name) ." given."); + throw new Nette\InvalidArgumentException(sprintf('Name must be string or NULL, %s given.', gettype($name))); } $this->name = $name; @@ -237,7 +237,7 @@ public function href($path, $query = NULL) public function setHtml($html) { if (is_array($html)) { - throw new Nette\InvalidArgumentException("Textual content must be a scalar, " . gettype($html) ." given."); + throw new Nette\InvalidArgumentException(sprintf('Textual content must be a scalar, %s given.', gettype($html))); } $this->removeChildren(); $this->children[] = (string) $html; @@ -331,7 +331,7 @@ public function insert($index, $child, $replace = FALSE) } } else { - throw new Nette\InvalidArgumentException("Child node must be scalar or Html object, " . (is_object($child) ? get_class($child) : gettype($child)) ." given."); + throw new Nette\InvalidArgumentException(sprintf('Child node must be scalar or Html object, %s given.', is_object($child) ? get_class($child) : gettype($child))); } return $this; diff --git a/Nette/Utils/Json.php b/Nette/Utils/Json.php index ab39bd5a27..d7299ebf8b 100644 --- a/Nette/Utils/Json.php +++ b/Nette/Utils/Json.php @@ -26,10 +26,7 @@ class Json JSON_ERROR_STATE_MISMATCH => 'Syntax error, malformed JSON', JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', - 5 /*JSON_ERROR_UTF8*/ => 'Invalid UTF-8 sequence', - 6 /*JSON_ERROR_RECURSION*/ => 'Recursion detected', - 7 /*JSON_ERROR_INF_OR_NAN*/ => 'Inf and NaN cannot be JSON encoded', - 8 /*JSON_ERROR_UNSUPPORTED_TYPE*/ => 'Type is not supported', + 5 /*JSON_ERROR_UTF8*/ => 'Invalid UTF-8 sequence', // exists since 5.3.3, but is returned since 5.3.1 ); @@ -50,24 +47,27 @@ final public function __construct() */ public static function encode($value, $options = 0) { - if (function_exists('ini_set')) { // workaround for PHP bugs #52397, #54109, #63004 - $old = ini_set('display_errors', 0); // needed to receive 'Invalid UTF-8 sequence' error + if (PHP_VERSION_ID < 50500) { + set_error_handler(function($severity, $message) { // needed to receive 'recursion detected' error + restore_error_handler(); + throw new JsonException($message); + }); } - set_error_handler(function($severity, $message) { // needed to receive 'recursion detected' error - restore_error_handler(); - throw new JsonException($message); - }); + $json = json_encode( $value, PHP_VERSION_ID >= 50400 ? (JSON_UNESCAPED_UNICODE | ($options & self::PRETTY ? JSON_PRETTY_PRINT : 0)) : 0 ); - restore_error_handler(); - if (isset($old)) { - ini_set('display_errors', $old); + + if (PHP_VERSION_ID < 50500) { + restore_error_handler(); } if ($error = json_last_error()) { - throw new JsonException(isset(static::$messages[$error]) ? static::$messages[$error] : 'Unknown error', $error); + $message = isset(static::$messages[$error]) ? static::$messages[$error] + : (PHP_VERSION_ID >= 50500 ? json_last_error_msg() : 'Unknown error'); + throw new JsonException($message, $error); } + $json = str_replace(array("\xe2\x80\xa8", "\xe2\x80\xa9"), array('\u2028', '\u2029'), $json); return $json; } @@ -93,7 +93,7 @@ public static function decode($json, $options = 0) } $value = call_user_func_array('json_decode', $args); - if ($value === NULL && $json !== '' && strcasecmp($json, 'null')) { // '' do not clean json_last_error + if ($value === NULL && $json !== '' && strcasecmp($json, 'null')) { // '' is not clearing json_last_error $error = json_last_error(); throw new JsonException(isset(static::$messages[$error]) ? static::$messages[$error] : 'Unknown error', $error); } diff --git a/Nette/Utils/MimeTypeDetector.php b/Nette/Utils/MimeTypeDetector.php index 0694a1b32b..0b41ee8a4e 100644 --- a/Nette/Utils/MimeTypeDetector.php +++ b/Nette/Utils/MimeTypeDetector.php @@ -43,13 +43,13 @@ public static function fromFile($file) return $info['mime']; } elseif (extension_loaded('fileinfo')) { - $type = preg_replace('#[\s;].*\z#', '', finfo_file(finfo_open(FILEINFO_MIME), $file)); + $type = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $file); } elseif (function_exists('mime_content_type')) { $type = mime_content_type($file); } - return isset($type) && preg_match('#^\S+/\S+\z#', $type) ? $type : 'application/octet-stream'; + return isset($type) && strpos($type, '/') ? $type : 'application/octet-stream'; } @@ -60,8 +60,8 @@ public static function fromFile($file) */ public static function fromString($data) { - if (extension_loaded('fileinfo') && preg_match('#^(\S+/[^\s;]+)#', finfo_buffer(finfo_open(FILEINFO_MIME), $data), $m)) { - return $m[1]; + if (extension_loaded('fileinfo') && strpos($type = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $data), '/')) { + return $type; } elseif (strncmp($data, "\xff\xd8", 2) === 0) { return 'image/jpeg'; diff --git a/Nette/Utils/Strings.php b/Nette/Utils/Strings.php index 2be31b031c..2e6b97a1f2 100644 --- a/Nette/Utils/Strings.php +++ b/Nette/Utils/Strings.php @@ -48,9 +48,8 @@ public static function checkEncoding($s, $encoding = 'UTF-8') public static function fixEncoding($s, $encoding = 'UTF-8') { // removes xD800-xDFFF, x110000 and higher - if (strcasecmp($encoding, 'UTF-8')) { - ini_set('mbstring.substitute_character', 'none'); - return mb_convert_encoding($s, $encoding, $encoding); + if (PHP_VERSION_ID < 50400 || strcasecmp($encoding, 'UTF-8')) { + return @iconv('UTF-16', $encoding . '//IGNORE', iconv($encoding, 'UTF-16//IGNORE', $s)); // intentionally @ } else { return htmlspecialchars_decode(htmlspecialchars($s, ENT_NOQUOTES | ENT_IGNORE, 'UTF-8'), ENT_NOQUOTES); } diff --git a/Nette/Utils/Validators.php b/Nette/Utils/Validators.php index f6562e1629..471586073b 100644 --- a/Nette/Utils/Validators.php +++ b/Nette/Utils/Validators.php @@ -260,7 +260,7 @@ public static function isUrl($value) /** - * Checks whether the input is a class, interface or trait + * Checks whether the input is a class, interface or trait. * @param string * @return bool */ diff --git a/Nette/common/ArrayHash.php b/Nette/common/ArrayHash.php index 6613ed9369..1fbed7b89d 100644 --- a/Nette/common/ArrayHash.php +++ b/Nette/common/ArrayHash.php @@ -64,7 +64,7 @@ public function count() public function offsetSet($key, $value) { if (!is_scalar($key)) { // prevents NULL - throw new InvalidArgumentException("Key must be either a string or an integer, " . gettype($key) ." given."); + throw new Nette\InvalidArgumentException(sprintf('Key must be either a string or an integer, %s given.', gettype($key))); } $this->$key = $value; } diff --git a/Nette/common/ArrayList.php b/Nette/common/ArrayList.php index 590d5ada51..d5691f8e0e 100644 --- a/Nette/common/ArrayList.php +++ b/Nette/common/ArrayList.php @@ -55,7 +55,7 @@ public function offsetSet($index, $value) $this->list[] = $value; } elseif ($index < 0 || $index >= count($this->list)) { - throw new OutOfRangeException("Offset invalid or out of range"); + throw new OutOfRangeException('Offset invalid or out of range'); } else { $this->list[(int) $index] = $value; @@ -72,7 +72,7 @@ public function offsetSet($index, $value) public function offsetGet($index) { if ($index < 0 || $index >= count($this->list)) { - throw new OutOfRangeException("Offset invalid or out of range"); + throw new OutOfRangeException('Offset invalid or out of range'); } return $this->list[(int) $index]; } @@ -98,7 +98,7 @@ public function offsetExists($index) public function offsetUnset($index) { if ($index < 0 || $index >= count($this->list)) { - throw new OutOfRangeException("Offset invalid or out of range"); + throw new OutOfRangeException('Offset invalid or out of range'); } array_splice($this->list, (int) $index, 1); } diff --git a/Nette/common/Configurator.php b/Nette/common/Configurator.php index bca7aea588..de68e2d85d 100644 --- a/Nette/common/Configurator.php +++ b/Nette/common/Configurator.php @@ -21,10 +21,11 @@ */ class Configurator extends Object { + const AUTO = TRUE; + /** @deprecated */ const DEVELOPMENT = 'development', PRODUCTION = 'production', - AUTO = TRUE, NONE = FALSE; /** @var array of function(Configurator $sender, DI\Compiler $compiler); Occurs after the compiler is created */ diff --git a/Nette/common/Framework.php b/Nette/common/Framework.php index 92ea4a4c2b..9397be312a 100644 --- a/Nette/common/Framework.php +++ b/Nette/common/Framework.php @@ -20,9 +20,9 @@ class Framework /** Nette Framework version identification */ const NAME = 'Nette Framework', - VERSION = '2.1.2', - VERSION_ID = 20102, - REVISION = 'released on 2014-03-17'; + VERSION = '2.1.3', + VERSION_ID = 20103, + REVISION = 'released on 2014-05-12'; /** diff --git a/Nette/common/Image.php b/Nette/common/Image.php index 931223b16d..5b9e0f5b69 100755 --- a/Nette/common/Image.php +++ b/Nette/common/Image.php @@ -154,7 +154,7 @@ public static function rgb($red, $green, $blue, $transparency = 0) public static function fromFile($file, & $format = NULL) { if (!extension_loaded('gd')) { - throw new NotSupportedException("PHP extension GD is not loaded."); + throw new NotSupportedException('PHP extension GD is not loaded.'); } $info = @getimagesize($file); // @ - files smaller than 12 bytes causes read error @@ -197,7 +197,7 @@ public static function getFormatFromString($s) public static function fromString($s, & $format = NULL) { if (!extension_loaded('gd')) { - throw new NotSupportedException("PHP extension GD is not loaded."); + throw new NotSupportedException('PHP extension GD is not loaded.'); } $format = static::getFormatFromString($s); @@ -216,7 +216,7 @@ public static function fromString($s, & $format = NULL) public static function fromBlank($width, $height, $color = NULL) { if (!extension_loaded('gd')) { - throw new NotSupportedException("PHP extension GD is not loaded."); + throw new NotSupportedException('PHP extension GD is not loaded.'); } $width = (int) $width; @@ -539,7 +539,7 @@ public function save($file = NULL, $quality = NULL, $type = NULL) return imagegif($this->getImageResource(), $file); default: - throw new InvalidArgumentException("Unsupported image type."); + throw new InvalidArgumentException('Unsupported image type.'); } } @@ -582,7 +582,7 @@ public function __toString() public function send($type = self::JPEG, $quality = NULL) { if ($type !== self::GIF && $type !== self::PNG && $type !== self::JPEG) { - throw new InvalidArgumentException("Unsupported image type."); + throw new InvalidArgumentException('Unsupported image type.'); } header('Content-Type: ' . image_type_to_mime_type($type)); return $this->save(NULL, $quality, $type); diff --git a/Nette/loader.php b/Nette/loader.php index 7e4c994364..f1ffe5fea2 100644 --- a/Nette/loader.php +++ b/Nette/loader.php @@ -1,7 +1,7 @@ setTempDirectory(TEMP_DIR)->createContainer(); - -test(function() use ($container) { - $factory = new PresenterFactory(NULL, $container); +test(function() { + $factory = new PresenterFactory(NULL, new Nette\DI\Container); $factory->setMapping(array( 'Foo2' => 'App2\*\*Presenter', @@ -38,8 +36,8 @@ test(function() use ($container) { }); -test(function() use ($container) { - $factory = new PresenterFactory(NULL, $container); +test(function() { + $factory = new PresenterFactory(NULL, new Nette\DI\Container); $factory->setMapping(array( 'Foo2' => 'App2\*Presenter', diff --git a/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt b/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt index 5812967e55..87e4c1a174 100644 --- a/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt +++ b/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt @@ -13,9 +13,7 @@ use Nette\Application\PresenterFactory, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); - -$factory = new PresenterFactory('base', $container); +$factory = new PresenterFactory('base', new Nette\DI\Container); test(function() use ($factory) { $factory->setMapping(array( diff --git a/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt b/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt index dd0ef2041e..299fc3b4f4 100644 --- a/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt +++ b/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt @@ -13,9 +13,7 @@ use Nette\Application\PresenterFactory, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); - -$factory = new PresenterFactory(NULL, $container); +$factory = new PresenterFactory(NULL, new Nette\DI\Container); test(function() use ($factory) { $factory->setMapping(array( diff --git a/tests/Nette/Caching/FileStorage.stress.phpt b/tests/Nette/Caching/FileStorage.stress.phpt index 1b1f014c1d..84d744a7dd 100644 --- a/tests/Nette/Caching/FileStorage.stress.phpt +++ b/tests/Nette/Caching/FileStorage.stress.phpt @@ -8,7 +8,6 @@ */ use Nette\Caching\Storages\FileStorage, - Nette\Diagnostics\Debugger, Tester\Assert; @@ -44,8 +43,6 @@ for ($i=0; $i<=COUNT_FILES; $i++) { // test loop -Debugger::timer(); - $hits = array('ok' => 0, 'notfound' => 0, 'error' => 0, 'cantwrite' => 0, 'cantdelete' => 0); for ($counter=0; $counter<1000; $counter++) { // write @@ -64,7 +61,6 @@ for ($counter=0; $counter<1000; $counter++) { elseif (checkStr($res)) $hits['ok']++; else $hits['error']++; } -$time = Debugger::timer(); Assert::same( array( @@ -83,4 +79,3 @@ Assert::same( array( // [cantdelete] => 0 // means 'delete() has timeout', should be 0 Assert::same(0, $hits['error']); -// takes $time ms diff --git a/tests/Nette/ComponentModel/Container.iterator.phpt b/tests/Nette/ComponentModel/Container.iterator.phpt index 5693fa83ce..bc76181917 100644 --- a/tests/Nette/ComponentModel/Container.iterator.phpt +++ b/tests/Nette/ComponentModel/Container.iterator.phpt @@ -8,13 +8,16 @@ use Nette\ComponentModel\Component, Nette\ComponentModel\Container, - Nette\Forms\Controls\Button, Tester\Assert; require __DIR__ . '/../bootstrap.php'; +class Button extends Component +{ +} + class ComponentX extends Component { } @@ -23,11 +26,11 @@ $c = new Container(NULL, 'top'); $c->addComponent(new Container, 'one'); $c->addComponent(new ComponentX, 'two'); -$c->addComponent(new Button('label'), 'button1'); +$c->addComponent(new Button, 'button1'); $c->getComponent('one')->addComponent(new ComponentX, 'inner'); $c->getComponent('one')->addComponent(new Container, 'inner2'); -$c->getComponent('one')->getComponent('inner2')->addComponent(new Button('label'), 'button2'); +$c->getComponent('one')->getComponent('inner2')->addComponent(new Button, 'button2'); // Normal @@ -40,7 +43,7 @@ Assert::same( array( // Filter -$list = $c->getComponents(FALSE, 'Nette\Forms\Controls\Button'); +$list = $c->getComponents(FALSE, 'Button'); Assert::same( array( "button1", ), array_keys(iterator_to_array($list)) ); @@ -83,7 +86,7 @@ Assert::same( array( // Recursive & filter I -$list = $c->getComponents(TRUE, 'Nette\Forms\Controls\Button'); +$list = $c->getComponents(TRUE, 'Button'); Assert::same( array( "button2", "button1", diff --git a/tests/Nette/DI/Compiler.services.autowiring.phpt b/tests/Nette/DI/Compiler.services.autowiring.phpt index 2676d75391..be8f1ac941 100644 --- a/tests/Nette/DI/Compiler.services.autowiring.phpt +++ b/tests/Nette/DI/Compiler.services.autowiring.phpt @@ -36,12 +36,15 @@ class Model class Lorem { /** autowiring using parameters */ - static function test(Nette\Security\SimpleAuthenticator $arg) + static function test(Ipsum $arg) { Notes::add(__METHOD__); } } +class Ipsum +{} + $loader = new DI\Config\Loader; $compiler = new DI\Compiler; diff --git a/tests/Nette/DI/Container.expand.phpt b/tests/Nette/DI/Container.expand.phpt index 743917172d..179ab911ca 100644 --- a/tests/Nette/DI/Container.expand.phpt +++ b/tests/Nette/DI/Container.expand.phpt @@ -24,7 +24,11 @@ Assert::same( array('cache' => '/temp'), $container->expand('%dirs%') ); Assert::exception(function() use ($container) { $container->expand('%bar%'); -}, 'Nette\InvalidArgumentException', "Missing item 'bar'."); +}, 'Nette\InvalidArgumentException', "Missing parameter 'bar'."); + +Assert::exception(function() use ($container) { + $container->expand('%foo.bar%'); +}, 'Nette\InvalidArgumentException', "Missing parameter 'foo.bar'."); Assert::exception(function() use ($container) { $container->parameters['bar'] = array(); diff --git a/tests/Nette/DI/Helpers.expand().phpt b/tests/Nette/DI/Helpers.expand().phpt index 76018ce919..d522d106e9 100644 --- a/tests/Nette/DI/Helpers.expand().phpt +++ b/tests/Nette/DI/Helpers.expand().phpt @@ -33,7 +33,7 @@ Assert::same( Assert::exception(function() { Helpers::expand('%missing%', array()); -}, 'Nette\InvalidArgumentException', "Missing item 'missing'."); +}, 'Nette\InvalidArgumentException', "Missing parameter 'missing'."); Assert::exception(function() { Helpers::expand('%key1%a', array('key1' => array('key2' => 123))); diff --git a/tests/Nette/DI/files/compiler.services.autowiring.neon b/tests/Nette/DI/files/compiler.services.autowiring.neon index cf2cccd41d..79eaf8b0d1 100644 --- a/tests/Nette/DI/files/compiler.services.autowiring.neon +++ b/tests/Nette/DI/files/compiler.services.autowiring.neon @@ -1,10 +1,6 @@ -parameters: - class: Lorem - factory: Factory - services: model: - create: %factory%::createModel + create: Factory::createModel setup: # local methods - test(...) @@ -18,10 +14,9 @@ services: - @lorem::test lorem: - class: %class% + class: Lorem alias: @lorem - authenticator: - class: Nette\Security\SimpleAuthenticator - arguments: [['username': '*****']] + ipsum: + class: Ipsum diff --git a/tests/Nette/Database/Table/Selection.insert().multi.phpt b/tests/Nette/Database/Table/Selection.insert().multi.phpt index 1081dcc2ec..106ec00b87 100644 --- a/tests/Nette/Database/Table/Selection.insert().multi.phpt +++ b/tests/Nette/Database/Table/Selection.insert().multi.phpt @@ -16,6 +16,7 @@ Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/../files/{$driverN test(function() use ($context) { + Assert::same(3, $context->table('author')->count()); $context->table('author')->insert(array( array( 'name' => 'Catelyn Stark', @@ -28,12 +29,15 @@ test(function() use ($context) { 'born' => new DateTime('2021-11-11'), ), )); // INSERT INTO `author` (`name`, `web`, `born`) VALUES ('Catelyn Stark', 'http://example.com', '2011-11-11 00:00:00'), ('Sansa Stark', 'http://example.com', '2021-11-11 00:00:00') - + Assert::same(5, $context->table('author')->count()); $context->table('book_tag')->where('book_id', 1)->delete(); // DELETE FROM `book_tag` WHERE (`book_id` = ?) + + Assert::same(4, $context->table('book_tag')->count()); $context->table('book')->get(1)->related('book_tag')->insert(array( // SELECT * FROM `book` WHERE (`id` = ?) array('tag_id' => 21), array('tag_id' => 22), array('tag_id' => 23), )); // INSERT INTO `book_tag` (`tag_id`, `book_id`) VALUES (21, 1), (22, 1), (23, 1) + Assert::same(7, $context->table('book_tag')->count()); }); diff --git a/tests/Nette/Database/Table/Selection.page().phpt b/tests/Nette/Database/Table/Selection.page().phpt index d17942ab1e..5258f60bcf 100644 --- a/tests/Nette/Database/Table/Selection.page().phpt +++ b/tests/Nette/Database/Table/Selection.page().phpt @@ -15,47 +15,47 @@ Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/../files/{$driverN //public function page($page, $itemsPerPage, & $numOfPages = NULL) test(function() use ($context) { //first page, one item per page - $numberOfPages = 0; + $numberOfPages = 0; - $tags = $context->table('tag')->page(1, 1, $numOfPages); - Assert::equal(1, count($tags)); //one item on first page - Assert::equal(4, $numOfPages); //four pages total + $tags = $context->table('tag')->page(1, 1, $numOfPages); + Assert::equal(1, count($tags)); //one item on first page + Assert::equal(4, $numOfPages); //four pages total - //calling the same without the $numOfPages reference - unset($tags); - $tags = $context->table('tag')->page(1, 1); - Assert::equal(1, count($tags)); //one item on first page + //calling the same without the $numOfPages reference + unset($tags); + $tags = $context->table('tag')->page(1, 1); + Assert::equal(1, count($tags)); //one item on first page }); test(function() use ($context) { //second page, three items per page - $numberOfPages = 0; + $numberOfPages = 0; - $tags = $context->table('tag')->page(2, 3, $numOfPages); - Assert::equal(1, count($tags)); //one item on second page - Assert::equal(2, $numOfPages); //two pages total + $tags = $context->table('tag')->page(2, 3, $numOfPages); + Assert::equal(1, count($tags)); //one item on second page + Assert::equal(2, $numOfPages); //two pages total - //calling the same without the $numOfPages reference - unset($tags); - $tags = $context->table('tag')->page(2, 3); - Assert::equal(1, count($tags)); //one item on second page + //calling the same without the $numOfPages reference + unset($tags); + $tags = $context->table('tag')->page(2, 3); + Assert::equal(1, count($tags)); //one item on second page }); test(function() use ($context) { //page with no items - $tags = $context->table('tag')->page(10, 4); - Assert::equal(0, count($tags)); //one item on second page + $tags = $context->table('tag')->page(10, 4); + Assert::equal(0, count($tags)); //one item on second page }); test(function() use ($context) { //page with no items (page not in range) - $tags = $context->table('tag')->page(100, 4); - Assert::equal(0, count($tags)); //one item on second page + $tags = $context->table('tag')->page(100, 4); + Assert::equal(0, count($tags)); //one item on second page }); test(function() use ($context) { //less items than $itemsPerPage - $tags = $context->table('tag')->page(1, 100); - Assert::equal(4, count($tags)); //all four items from db + $tags = $context->table('tag')->page(1, 100); + Assert::equal(4, count($tags)); //all four items from db }); test(function() use ($context) { //invalid params - $tags = $context->table('tag')->page('foo', 'bar'); - Assert::equal(0, count($tags)); //no items + $tags = $context->table('tag')->page('foo', 'bar'); + Assert::equal(0, count($tags)); //no items }); diff --git a/tests/Nette/Database/Table/SqlBuilder.addWhere().phpt b/tests/Nette/Database/Table/SqlBuilder.addWhere().phpt index 6572fed848..6327dd6de9 100644 --- a/tests/Nette/Database/Table/SqlBuilder.addWhere().phpt +++ b/tests/Nette/Database/Table/SqlBuilder.addWhere().phpt @@ -64,7 +64,7 @@ test(function() use ($connection, $reflection) { // test SqlLiteral test(function() use ($connection, $reflection) { // test auto type detection $sqlBuilder = new SqlBuilder('book', $connection, $reflection); - $sqlBuilder->addWhere('id ? OR id ? OR id ?', 1, "test", array(1, 2)); + $sqlBuilder->addWhere('id ? OR id ? OR id ?', 1, 'test', array(1, 2)); Assert::same(reformat('SELECT * FROM [book] WHERE ([id] = ? OR [id] = ? OR [id] IN (?))'), $sqlBuilder->buildSelectQuery()); }); @@ -89,8 +89,8 @@ test(function() use ($connection, $reflection) { // test empty array test(function() use ($connection, $reflection) { // backward compatibility $sqlBuilder = new SqlBuilder('book', $connection, $reflection); - $sqlBuilder->addWhere('id = ? OR id ? OR id IN ? OR id LIKE ? OR id > ?', 1, 2, array(1, 2), "%test", 3); - $sqlBuilder->addWhere('name', "var"); + $sqlBuilder->addWhere('id = ? OR id ? OR id IN ? OR id LIKE ? OR id > ?', 1, 2, array(1, 2), '%test', 3); + $sqlBuilder->addWhere('name', 'var'); $sqlBuilder->addWhere('MAIN', 0); // "IN" is not considered as the operator $sqlBuilder->addWhere('id IN (?)', array(1, 2)); Assert::same(reformat('SELECT * FROM [book] WHERE ([id] = ? OR [id] = ? OR [id] IN (?) OR [id] LIKE ? OR [id] > ?) AND ([name] = ?) AND (MAIN = ?) AND ([id] IN (?))'), $sqlBuilder->buildSelectQuery()); @@ -220,5 +220,5 @@ test(function() use ($driverName, $context, $connection, $reflection) { Assert::exception(function() use ($e) { throw $e->getPrevious(); - }, 'LogicException', 'Table "book_tag" does not have a primary key.'); + }, 'LogicException', "Table 'book_tag' does not have a primary key."); }); diff --git a/tests/Nette/Database/Table/Table.basic.phpt b/tests/Nette/Database/Table/Table.basic.phpt index f43c1971f3..7e5f9f65fa 100644 --- a/tests/Nette/Database/Table/Table.basic.phpt +++ b/tests/Nette/Database/Table/Table.basic.phpt @@ -37,7 +37,7 @@ test(function() use ($context) { $book = $context->table('book')->get(1); Assert::exception(function() use ($book) { $book->unknown_column; - }, 'Nette\MemberAccessException', 'Cannot read an undeclared column "unknown_column".'); + }, 'Nette\MemberAccessException', "Cannot read an undeclared column 'unknown_column'."); }); @@ -84,7 +84,7 @@ test(function() use ($connection) { $book = $context->table('book')->get(1); Assert::exception(function() use ($book) { $book->test; - }, 'Nette\MemberAccessException', 'Cannot read an undeclared column "test".'); + }, 'Nette\MemberAccessException', "Cannot read an undeclared column 'test'."); Assert::exception(function() use ($book) { $book->ref('test'); diff --git a/tests/Nette/Database/Table/Table.cache2.phpt b/tests/Nette/Database/Table/Table.cache2.phpt index 3dff5622ad..c80630e1e3 100644 --- a/tests/Nette/Database/Table/Table.cache2.phpt +++ b/tests/Nette/Database/Table/Table.cache2.phpt @@ -13,21 +13,41 @@ require __DIR__ . '/../connect.inc.php'; // create $connection Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/../files/{$driverName}-nette_test1.sql"); +$res = array(); for ($i = 1; $i <= 2; ++$i) { foreach ($context->table('author') as $author) { - $author->name; + $res[] = (string) $author->name; foreach ($author->related('book', 'author_id') as $book) { - $book->title; + $res[] = (string) $book->title; } } foreach ($context->table('author')->where('id', 13) as $author) { - $author->name; + $res[] = (string) $author->name; foreach ($author->related('book', 'author_id') as $book) { - $book->title; + $res[] = (string) $book->title; } } } + +Assert::same(array( + 'Jakub Vrana', + '1001 tipu a triku pro PHP', + 'JUSH', + 'David Grudl', + 'Nette', + 'Dibi', + 'Geek', + 'Geek', + 'Jakub Vrana', + '1001 tipu a triku pro PHP', + 'JUSH', + 'David Grudl', + 'Nette', + 'Dibi', + 'Geek', + 'Geek', +), $res); diff --git a/tests/Nette/Database/Table/Table.columnRefetch.phpt b/tests/Nette/Database/Table/Table.columnRefetch.phpt index 4e752abc4d..63630144b7 100644 --- a/tests/Nette/Database/Table/Table.columnRefetch.phpt +++ b/tests/Nette/Database/Table/Table.columnRefetch.phpt @@ -20,11 +20,12 @@ foreach ($books as $book) { } $books->__destruct(); - +$res = array(); $books = $context->table('book')->order('id DESC')->limit(2); foreach ($books as $book) { - $book->title; + $res[] = (string) $book->title; } +Assert::same(array('Dibi', 'Nette'), $res); $context->table('book')->insert(array( 'title' => 'New book #1', @@ -35,7 +36,9 @@ $context->table('book')->insert(array( 'author_id' => 11, )); +$res = array(); foreach ($books as $book) { - $book->title; - $book->author->name; + $res[] = (string) $book->title; + $res[] = (string) $book->author->name; } +Assert::same(array('Dibi', 'David Grudl', 'Nette', 'David Grudl'), $res); diff --git a/tests/Nette/Database/connect.inc.php b/tests/Nette/Database/connect.inc.php index d105876a70..40140103ba 100644 --- a/tests/Nette/Database/connect.inc.php +++ b/tests/Nette/Database/connect.inc.php @@ -15,7 +15,7 @@ } try { - $options = Tester\DataProvider::loadCurrent() + array('user' => NULL, 'password' => NULL); + $options = Tester\Environment::loadData() + array('user' => NULL, 'password' => NULL); } catch (Exception $e) { Tester\Environment::skip($e->getMessage()); } diff --git a/tests/Nette/Diagnostics/Debugger.E_ERROR.html.expect b/tests/Nette/Diagnostics/Debugger.E_ERROR.html.expect index 6d6b9b07fe..63f082b458 100644 --- a/tests/Nette/Diagnostics/Debugger.E_ERROR.html.expect +++ b/tests/Nette/Diagnostics/Debugger.E_ERROR.html.expect @@ -20,7 +20,7 @@ Fatal error: Call to undefined function missing_function() in %a% on line %d%

Fatal Error

-

Call to undefined function missing_function() search►

+

Call to undefined function missing_function() search►

diff --git a/tests/Nette/Diagnostics/Debugger.E_ERROR.html.xdebug.expect b/tests/Nette/Diagnostics/Debugger.E_ERROR.html.xdebug.expect index 04343a8423..b7ff7e65ac 100644 --- a/tests/Nette/Diagnostics/Debugger.E_ERROR.html.xdebug.expect +++ b/tests/Nette/Diagnostics/Debugger.E_ERROR.html.xdebug.expect @@ -20,7 +20,7 @@ Fatal error: Call to undefined function missing_function() in %a% on line %d%

Fatal Error

-

Call to undefined function missing_function() search►

+

Call to undefined function missing_function() search►

diff --git a/tests/Nette/Diagnostics/Debugger.error-in-eval.expect b/tests/Nette/Diagnostics/Debugger.error-in-eval.expect index 947086e8fa..386a441eca 100644 --- a/tests/Nette/Diagnostics/Debugger.error-in-eval.expect +++ b/tests/Nette/Diagnostics/Debugger.error-in-eval.expect @@ -18,7 +18,7 @@

User Error

-

The my error search►

+

The my error search►

diff --git a/tests/Nette/Diagnostics/Debugger.exception.html.expect b/tests/Nette/Diagnostics/Debugger.exception.html.expect index 5c65cc7b22..a3e13411d7 100644 --- a/tests/Nette/Diagnostics/Debugger.exception.html.expect +++ b/tests/Nette/Diagnostics/Debugger.exception.html.expect @@ -18,7 +18,7 @@

Exception #123

-

The my exception search►

+

The my exception search►

diff --git a/tests/Nette/Diagnostics/Debugger.strict.html.expect b/tests/Nette/Diagnostics/Debugger.strict.html.expect index e9f2f56fca..9c3718171d 100644 --- a/tests/Nette/Diagnostics/Debugger.strict.html.expect +++ b/tests/Nette/Diagnostics/Debugger.strict.html.expect @@ -18,7 +18,7 @@

Notice

-

Undefined variable: x search►

+

Undefined variable: x search►

diff --git a/tests/Nette/Forms/Controls.CheckboxList.loadData.phpt b/tests/Nette/Forms/Controls.CheckboxList.loadData.phpt index 261a1f54f6..ea48845da7 100644 --- a/tests/Nette/Forms/Controls.CheckboxList.loadData.phpt +++ b/tests/Nette/Forms/Controls.CheckboxList.loadData.phpt @@ -137,7 +137,7 @@ test(function() use ($series) { // setValue() and invalid argument Assert::exception(function() use ($input) { $input->setValue('unknown'); - }, 'Nette\InvalidArgumentException', "Value 'unknown' are out of allowed range ['Red Dwarf', 'The Simpsons', 'South Park', 'Family Guy'] in field 'list'."); + }, 'Nette\InvalidArgumentException', "Value 'unknown' are out of allowed range ['red-dwarf', 'the-simpsons', 0, ''] in field 'list'."); }); diff --git a/tests/Nette/Forms/Controls.ChoiceControl.loadData.phpt b/tests/Nette/Forms/Controls.ChoiceControl.loadData.phpt index 27c7bb1160..de69bb9096 100644 --- a/tests/Nette/Forms/Controls.ChoiceControl.loadData.phpt +++ b/tests/Nette/Forms/Controls.ChoiceControl.loadData.phpt @@ -149,7 +149,7 @@ test(function() use ($series) { // setValue() and invalid argument Assert::exception(function() use ($input) { $input->setValue('unknown'); - }, 'Nette\InvalidArgumentException', "Value 'unknown' is out of allowed range ['Red Dwarf', 'The Simpsons', 'South Park', 'Family Guy'] in field 'select'."); + }, 'Nette\InvalidArgumentException', "Value 'unknown' is out of allowed range ['red-dwarf', 'the-simpsons', 0, ''] in field 'select'."); }); @@ -188,3 +188,16 @@ test(function() use ($series) { // disabled one Assert::null( $input->getValue() ); }); + +test(function() { + $_POST = array('select' => 1); + + $form = new Form; + $input = $form['select'] = new ChoiceControl(NULL); + $input->setItems(array( + 1 => NULL, + 2 => 'Red dwarf' + )); + + Assert::same( 1, $input->getValue() ); +}); diff --git a/tests/Nette/Forms/Controls.MultiChoiceControl.loadData.phpt b/tests/Nette/Forms/Controls.MultiChoiceControl.loadData.phpt index 06f5c305d9..ee0286402c 100644 --- a/tests/Nette/Forms/Controls.MultiChoiceControl.loadData.phpt +++ b/tests/Nette/Forms/Controls.MultiChoiceControl.loadData.phpt @@ -161,7 +161,7 @@ test(function() use ($series) { // setValue() and invalid argument Assert::exception(function() use ($input) { $input->setValue('unknown'); - }, 'Nette\InvalidArgumentException', "Value 'unknown' are out of allowed range ['Red Dwarf', 'The Simpsons', 'South Park', 'Family Guy'] in field 'select'."); + }, 'Nette\InvalidArgumentException', "Value 'unknown' are out of allowed range ['red-dwarf', 'the-simpsons', 0, ''] in field 'select'."); Assert::exception(function() use ($input) { $input->setValue(new stdClass); diff --git a/tests/Nette/Forms/Controls.MultiSelectBox.loadData.phpt b/tests/Nette/Forms/Controls.MultiSelectBox.loadData.phpt index c5184ff38d..456f13d99b 100644 --- a/tests/Nette/Forms/Controls.MultiSelectBox.loadData.phpt +++ b/tests/Nette/Forms/Controls.MultiSelectBox.loadData.phpt @@ -200,7 +200,7 @@ test(function() use ($series) { // setValue() and invalid argument Assert::exception(function() use ($input) { $input->setValue('unknown'); - }, 'Nette\InvalidArgumentException', "Value 'unknown' are out of allowed range ['Red Dwarf', 'The Simpsons', 'South Park', 'Family Guy'] in field 'select'."); + }, 'Nette\InvalidArgumentException', "Value 'unknown' are out of allowed range ['red-dwarf', 'the-simpsons', 0, ''] in field 'select'."); }); diff --git a/tests/Nette/Forms/Controls.RadioList.loadData.phpt b/tests/Nette/Forms/Controls.RadioList.loadData.phpt index 5f2e4a4f4b..ce37fad659 100644 --- a/tests/Nette/Forms/Controls.RadioList.loadData.phpt +++ b/tests/Nette/Forms/Controls.RadioList.loadData.phpt @@ -138,7 +138,7 @@ test(function() use ($series) { // setValue() and invalid argument Assert::exception(function() use ($input) { $input->setValue('unknown'); - }, 'Nette\InvalidArgumentException', "Value 'unknown' is out of allowed range ['Red Dwarf', 'The Simpsons', 'South Park', 'Family Guy'] in field 'radio'."); + }, 'Nette\InvalidArgumentException', "Value 'unknown' is out of allowed range ['red-dwarf', 'the-simpsons', 0, ''] in field 'radio'."); }); diff --git a/tests/Nette/Forms/Controls.SelectBox.loadData.phpt b/tests/Nette/Forms/Controls.SelectBox.loadData.phpt index 0a58aabf69..f46738b978 100644 --- a/tests/Nette/Forms/Controls.SelectBox.loadData.phpt +++ b/tests/Nette/Forms/Controls.SelectBox.loadData.phpt @@ -41,6 +41,19 @@ test(function() use ($series) { // Select }); +test(function() use ($series) { // Empty select + $_POST = array('select' => 'red-dwarf'); + + $form = new Form; + $input = $form->addSelect('select'); + + Assert::true( $form->isValid() ); + Assert::same( NULL, $input->getValue() ); + Assert::same( NULL, $input->getSelectedItem() ); + Assert::false( $input->isFilled() ); +}); + + test(function() use ($series) { // Select with prompt $_POST = array('select' => 'red-dwarf'); @@ -211,7 +224,7 @@ test(function() use ($series) { // setValue() and invalid argument Assert::exception(function() use ($input) { $input->setValue('unknown'); - }, 'Nette\InvalidArgumentException', "Value 'unknown' is out of allowed range ['Red Dwarf', 'The Simpsons', 'South Park', 'Family Guy'] in field 'select'."); + }, 'Nette\InvalidArgumentException', "Value 'unknown' is out of allowed range ['red-dwarf', 'the-simpsons', 0, ''] in field 'select'."); }); @@ -253,3 +266,15 @@ test(function() use ($series) { // disabled one Assert::null( $input->getValue() ); }); + +test(function() { + $_POST = array('select' => 1); + + $form = new Form; + $input = $form->addSelect('select', NULL, array( + 1 => NULL, + 2 => 'Red dwarf' + )); + + Assert::same( 1, $input->getValue() ); +}); diff --git a/tests/Nette/Http/Session.handler.phpt b/tests/Nette/Http/Session.handler.phpt index 8384d4a75c..7c9acfd28c 100644 --- a/tests/Nette/Http/Session.handler.phpt +++ b/tests/Nette/Http/Session.handler.phpt @@ -55,8 +55,18 @@ class MySessionStorage extends Object implements SessionHandlerInterface } -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$factory = new Nette\Http\RequestFactory; +$session = new Nette\Http\Session($factory->createHttpRequest(), new Nette\Http\Response); $session->setHandler(new MySessionStorage); $session->start(); +$_COOKIE['PHPSESSID'] = $session->getId(); + +$namespace = $session->getSection('one'); +$namespace->a = 'apple'; +$session->close(); +unset($_SESSION); + +$session->start(); +$namespace = $session->getSection('one'); +Assert::same('apple', $namespace->a); diff --git a/tests/Nette/Http/Session.invalidId.phpt b/tests/Nette/Http/Session.invalidId.phpt index 154dc7eb20..84348af36f 100644 --- a/tests/Nette/Http/Session.invalidId.phpt +++ b/tests/Nette/Http/Session.invalidId.phpt @@ -17,7 +17,8 @@ require __DIR__ . '/../bootstrap.php'; $_COOKIE['PHPSESSID'] = '#'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); -$session = $session->start(); +$session->start(); + +Assert::match('%[\w]+%', $session->getId()); diff --git a/tests/Nette/Http/Session.regenerateId().phpt b/tests/Nette/Http/Session.regenerateId().phpt index 8bce4b4d9c..a95b2070a3 100644 --- a/tests/Nette/Http/Session.regenerateId().phpt +++ b/tests/Nette/Http/Session.regenerateId().phpt @@ -13,8 +13,7 @@ use Nette\Http\Session, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $path = rtrim(ini_get('session.save_path'), '/\\') . '/sess_'; diff --git a/tests/Nette/Http/Session.sections.phpt b/tests/Nette/Http/Session.sections.phpt index 8b1f579b8b..e6b4550a3c 100644 --- a/tests/Nette/Http/Session.sections.phpt +++ b/tests/Nette/Http/Session.sections.phpt @@ -16,8 +16,7 @@ require __DIR__ . '/../bootstrap.php'; ob_start(); -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); Assert::false( $session->hasSection('trees') ); // hasSection() should have returned FALSE for a section with no keys set diff --git a/tests/Nette/Http/Session.start.error.phpt b/tests/Nette/Http/Session.start.error.phpt index 70a5fc8745..8f83f7451f 100644 --- a/tests/Nette/Http/Session.start.error.phpt +++ b/tests/Nette/Http/Session.start.error.phpt @@ -17,8 +17,7 @@ require __DIR__ . '/../bootstrap.php'; ini_set('session.save_path', ';;;'); -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); Assert::exception(function() use ($session) { $session->start(); diff --git a/tests/Nette/Http/Session.storage.phpt b/tests/Nette/Http/Session.storage.phpt index 3899907cd6..c1ea557847 100644 --- a/tests/Nette/Http/Session.storage.phpt +++ b/tests/Nette/Http/Session.storage.phpt @@ -55,8 +55,17 @@ class MySessionStorage extends Object implements ISessionStorage } -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $session->setStorage(new MySessionStorage); $session->start(); +$_COOKIE['PHPSESSID'] = $session->getId(); + +$namespace = $session->getSection('one'); +$namespace->a = 'apple'; +$session->close(); +unset($_SESSION); + +$session->start(); +$namespace = $session->getSection('one'); +Assert::same('apple', $namespace->a); diff --git a/tests/Nette/Http/SessionSection.basic.phpt b/tests/Nette/Http/SessionSection.basic.phpt index fb3031a633..175d1a1466 100644 --- a/tests/Nette/Http/SessionSection.basic.phpt +++ b/tests/Nette/Http/SessionSection.basic.phpt @@ -13,8 +13,7 @@ use Nette\Http\Session, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $namespace = $session->getSection('one'); $namespace->a = 'apple'; diff --git a/tests/Nette/Http/SessionSection.remove.phpt b/tests/Nette/Http/SessionSection.remove.phpt index 4dc07b357e..766807a222 100644 --- a/tests/Nette/Http/SessionSection.remove.phpt +++ b/tests/Nette/Http/SessionSection.remove.phpt @@ -13,8 +13,7 @@ use Nette\Http\Session, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $namespace = $session->getSection('three'); $namespace->a = 'apple'; diff --git a/tests/Nette/Http/SessionSection.separated.phpt b/tests/Nette/Http/SessionSection.separated.phpt index 8fe951bc41..e28f333ea8 100644 --- a/tests/Nette/Http/SessionSection.separated.phpt +++ b/tests/Nette/Http/SessionSection.separated.phpt @@ -13,8 +13,7 @@ use Nette\Http\Session, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $namespace1 = $session->getSection('namespace1'); $namespace1b = $session->getSection('namespace1'); diff --git a/tests/Nette/Http/SessionSection.setExpiration().phpt b/tests/Nette/Http/SessionSection.setExpiration().phpt index 78eed42f32..436e427205 100644 --- a/tests/Nette/Http/SessionSection.setExpiration().phpt +++ b/tests/Nette/Http/SessionSection.setExpiration().phpt @@ -13,8 +13,7 @@ use Nette\Http\Session, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $session->setExpiration('+10 seconds'); diff --git a/tests/Nette/Http/SessionSection.undefined.phpt b/tests/Nette/Http/SessionSection.undefined.phpt index f1ff51dd62..170ea3de1c 100644 --- a/tests/Nette/Http/SessionSection.undefined.phpt +++ b/tests/Nette/Http/SessionSection.undefined.phpt @@ -13,8 +13,7 @@ use Nette\Http\Session, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $namespace = $session->getSection('one'); Assert::false( isset($namespace->undefined) ); diff --git a/tests/Nette/Latte/FormMacros.foreach.phpt b/tests/Nette/Latte/FormMacros.foreach.phpt index 70d259f93e..d85df79e98 100644 --- a/tests/Nette/Latte/FormMacros.foreach.phpt +++ b/tests/Nette/Latte/FormMacros.foreach.phpt @@ -7,7 +7,7 @@ */ use Nette\Latte\Macros\FormMacros; -use Nette\Application\UI\Form; +use Nette\Forms\Form; use Tester\Assert; diff --git a/tests/Nette/Latte/Parser.shortNoEscape.phpt b/tests/Nette/Latte/Parser.shortNoEscape.phpt index 90e9b86af2..12aa3028b4 100644 --- a/tests/Nette/Latte/Parser.shortNoEscape.phpt +++ b/tests/Nette/Latte/Parser.shortNoEscape.phpt @@ -29,6 +29,5 @@ $template->setSource('{="<>"}'); Assert::match('<>', (string) $template); Assert::error(function() use ($template) { - $template->setSource('{!="<>"}'); - Assert::match('<>', (string) $template); + $template->setSource('{!="<>"}')->compile(); }, E_USER_DEPRECATED, 'The noescape shortcut {!...} is deprecated, use {...|noescape} modifier on line 1.'); diff --git a/tests/Nette/Latte/Template.inc b/tests/Nette/Latte/Template.inc index 77384dcf30..64298f3f6a 100644 --- a/tests/Nette/Latte/Template.inc +++ b/tests/Nette/Latte/Template.inc @@ -23,15 +23,7 @@ class MockCacheStorage extends PhpFileStorage public function write($key, $data, array $dp) { - $this->phtml[basename($this->hint)] = codefix($data); + $this->phtml[basename($this->hint)] = $data; } } - - -function codefix($s) -{ - $s = preg_replace("#(?<=['_])[a-z0-9]{10,}(?=['_])#", 'xxx', $s); - $s = preg_replace('#source file:.*#', '', $s); - return $s; -} diff --git a/tests/Nette/Latte/UIMacros.link.phpt b/tests/Nette/Latte/UIMacros.link.phpt index bece2ab269..d33d9d7509 100644 --- a/tests/Nette/Latte/UIMacros.link.phpt +++ b/tests/Nette/Latte/UIMacros.link.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; $compiler = new Nette\Latte\Compiler; -$compiler->setContentType(Nette\Latte\Compiler::CONTENT_TEXT); +$compiler->setContentType($compiler::CONTENT_TEXT); UIMacros::install($compiler); // {link ...} diff --git a/tests/Nette/Latte/expected/macros.cache.inc.phtml b/tests/Nette/Latte/expected/macros.cache.inc.phtml index 7fa297d971..2eaf2aae38 100644 --- a/tests/Nette/Latte/expected/macros.cache.inc.phtml +++ b/tests/Nette/Latte/expected/macros.cache.inc.phtml @@ -1,10 +1,10 @@

Included file ()

-caches)) { ?> +caches)) { ?> lower($title), ENT_NOQUOTES) ?> tmp = array_pop($_g->caches); if (!$_l->tmp instanceof stdClass) $_l->tmp->end(); } diff --git a/tests/Nette/Latte/expected/macros.cache.phtml b/tests/Nette/Latte/expected/macros.cache.phtml index 405b2ab0ee..67dc68a6e1 100644 --- a/tests/Nette/Latte/expected/macros.cache.phtml +++ b/tests/Nette/Latte/expected/macros.cache.phtml @@ -1,6 +1,6 @@ Noncached content -caches, array($id, 'tags' => 'mytag'))) { ?> +caches, array($id, 'tags' => 'mytag'))) { ?>

upper($title), ENT_NOQUOTES) ?>

- 11) + $template->getParameters(), $_l->templates['xxx'])->render() ?> + 11) + $template->getParameters(), $_l->templates['%[a-z0-9]+%'])->render() ?> tmp = array_pop($_g->caches); if (!$_l->tmp instanceof stdClass) $_l->tmp->end(); } diff --git a/tests/Nette/Latte/expected/macros.defineblock.phtml b/tests/Nette/Latte/expected/macros.defineblock.phtml index 29410dc2b7..5198091529 100644 --- a/tests/Nette/Latte/expected/macros.defineblock.phtml +++ b/tests/Nette/Latte/expected/macros.defineblock.phtml @@ -1,12 +1,12 @@ blocks['test'][] = '_xxx_test')) { function _xxx_test($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v +if (!function_exists($_l->blocks['test'][] = '_%[a-z0-9]+%_test')) { function _%[a-z0-9]+%_test($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?> This is definition # blocks['static'][] = '_xxx_static')) { function _xxx_static($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v +if (!function_exists($_l->blocks['static'][] = '_%[a-z0-9]+%_static')) { function _%[a-z0-9]+%_static($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?> Static block # blocks['static']), $_l, get_defined_vars()) ?> // // block $name // -if (!function_exists($_l->blocks[$name]['xxx'] = '_xxx__name')) { function _xxx__name($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?> +if (!function_exists($_l->blocks[$name]['%[a-z0-9]+%'] = '_%[a-z0-9]+%__name')) { function _%[a-z0-9]+%__name($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?> Dynamic block # blocks[$name]), $_l, get_defined_vars()) ;$iterations++; } array_pop($_l->its); $iterator = end($_l->its) ?> @@ -54,11 +54,11 @@ if (!function_exists($_l->blocks[$name]['xxx'] = '_xxx__name')) { function _xxx_ // // block word$name // -if (!function_exists($_l->blocks["word$name"]['xxx'] = '_xxx_word_name')) { function _xxx_word_name($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ;}} call_user_func(reset($_l->blocks["word$name"]), $_l, get_defined_vars()) ?> +if (!function_exists($_l->blocks["word$name"]['%[a-z0-9]+%'] = '_%[a-z0-9]+%_word_name')) { function _%[a-z0-9]+%_word_name($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ;}} call_user_func(reset($_l->blocks["word$name"]), $_l, get_defined_vars()) ?> blocks["word$name"]['xxx'] = '_xxx__word_name_')) { function _xxx__word_name_($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ;}} call_user_func(reset($_l->blocks["word$name"]), $_l, get_defined_vars()) ?> +if (!function_exists($_l->blocks["word$name"]['%[a-z0-9]+%'] = '_%[a-z0-9]+%__word_name_')) { function _%[a-z0-9]+%__word_name_($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ;}} call_user_func(reset($_l->blocks["word$name"]), $_l, get_defined_vars()) ?> diff --git a/tests/Nette/Latte/expected/macros.dynamicsnippets.alt.phtml b/tests/Nette/Latte/expected/macros.dynamicsnippets.alt.phtml index f14db75a9c..03a500b184 100644 --- a/tests/Nette/Latte/expected/macros.dynamicsnippets.alt.phtml +++ b/tests/Nette/Latte/expected/macros.dynamicsnippets.alt.phtml @@ -1,12 +1,12 @@ blocks['_outer1'][] = '_xxx__outer1')) { function _xxx__outer1($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v; $_control->redrawControl('outer1', FALSE) +if (!function_exists($_l->blocks['_outer1'][] = '_%[a-z0-9]+%__outer1')) { function _%[a-z0-9]+%__outer1($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v; $_control->redrawControl('outer1', FALSE) ;$iterations = 0; foreach (array(1,2,3) as $id) { ?> > # @@ -19,7 +19,7 @@ if (!function_exists($_l->blocks['_outer1'][] = '_xxx__outer1')) { function _xxx // // block _outer2 // -if (!function_exists($_l->blocks['_outer2'][] = '_xxx__outer2')) { function _xxx__outer2($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v; $_control->redrawControl('outer2', FALSE) +if (!function_exists($_l->blocks['_outer2'][] = '_%[a-z0-9]+%__outer2')) { function _%[a-z0-9]+%__outer2($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v; $_control->redrawControl('outer2', FALSE) ;$iterations = 0; foreach (array(1,2,3) as $id) { ?> > # diff --git a/tests/Nette/Latte/expected/macros.dynamicsnippets.phtml b/tests/Nette/Latte/expected/macros.dynamicsnippets.phtml index 0937e20ebf..545bf5637d 100644 --- a/tests/Nette/Latte/expected/macros.dynamicsnippets.phtml +++ b/tests/Nette/Latte/expected/macros.dynamicsnippets.phtml @@ -1,12 +1,12 @@ blocks['_outer'][] = '_xxx__outer')) { function _xxx__outer($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v; $_control->redrawControl('outer', FALSE) +if (!function_exists($_l->blocks['_outer'][] = '_%[a-z0-9]+%__outer')) { function _%[a-z0-9]+%__outer($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v; $_control->redrawControl('outer', FALSE) ;$iterations = 0; foreach (array(1,2,3) as $id) { ?>
"> # diff --git a/tests/Nette/Latte/expected/macros.first-sep-last.phtml b/tests/Nette/Latte/expected/macros.first-sep-last.phtml index 4928c9df5c..cc51138da7 100644 --- a/tests/Nette/Latte/expected/macros.first-sep-last.phtml +++ b/tests/Nette/Latte/expected/macros.first-sep-last.phtml @@ -1,6 +1,6 @@ blocks['menu'][] = '_xxx_menu')) { function _xxx_menu($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v +if (!function_exists($_l->blocks['menu'][] = '_%[a-z0-9]+%_menu')) { function _%[a-z0-9]+%_menu($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?>
    its[] = new Nette\Iterators\CachingIterator($menu) as $item) { ?>
  • @@ -20,7 +20,7 @@ if (!function_exists($_l->blocks['menu'][] = '_xxx_menu')) { function _xxx_menu( // // block bl // -if (!function_exists($_l->blocks['bl'][] = '_xxx_bl')) { function _xxx_bl($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v +if (!function_exists($_l->blocks['bl'][] = '_%[a-z0-9]+%_bl')) { function _%[a-z0-9]+%_bl($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?>
    • diff --git a/tests/Nette/Latte/expected/macros.general.xhtml.inc1.phtml b/tests/Nette/Latte/expected/macros.general.xhtml.inc1.phtml index d1ba33a419..612329684e 100644 --- a/tests/Nette/Latte/expected/macros.general.xhtml.inc1.phtml +++ b/tests/Nette/Latte/expected/macros.general.xhtml.inc1.phtml @@ -2,7 +2,7 @@ // -?>

      Included file #1

      - 20) + $template->getParameters(), $_l->templates['xxx'])->render() ?> + 20) + $template->getParameters(), $_l->templates['%[a-z0-9]+%'])->render() ?> -getParameters(), $_l->templates['xxx'])->render() ?> +getParameters(), $_l->templates['%[a-z0-9]+%'])->render() ?>