Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
language: php
php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
Expand All @@ -20,7 +18,7 @@ matrix:
env: PHP_BIN=php-cgi

include:
- php: 5.5
- php: 5.6
env: dependencies="--prefer-lowest --prefer-stable" PHP_BIN=php

script:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
],
"require": {
"php": ">=5.4.4",
"php": ">=5.6.0",
"nette/component-model": "~2.2",
"nette/http": "~2.2",
"nette/reflection": "~2.2",
Expand Down
4 changes: 2 additions & 2 deletions src/Application/LinkGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(IRouter $router, Nette\Http\Url $refUrl, IPresenterF
* Generates URL to presenter.
* @param string destination in format "[[[module:]presenter:]action] [#fragment]"
* @return string
* @throws InvalidLinkException
* @throws UI\InvalidLinkException
*/
public function link($dest, array $params = [])
{
Expand All @@ -52,7 +52,7 @@ public function link($dest, array $params = [])
throw new UI\InvalidLinkException($e->getMessage(), NULL, $e);
}

if (is_subclass_of($class, 'Nette\Application\UI\Presenter')) {
if (is_subclass_of($class, UI\Presenter::class)) {
if ($action === '') {
$action = UI\Presenter::DEFAULT_ACTION;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Application/MicroPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Micro presenter.
*
* @property-read Nette\Application\IRequest $request
* @property-read Nette\Application\Request $request
*/
class MicroPresenter extends Nette\Object implements Application\IPresenter
{
Expand Down Expand Up @@ -115,7 +115,7 @@ public function run(Application\Request $request)
*/
public function createTemplate($class = NULL, callable $latteFactory = NULL)
{
$latte = $latteFactory ? $latteFactory() : $this->getContext()->getByType('Nette\Bridges\ApplicationLatte\ILatteFactory')->create();
$latte = $latteFactory ? $latteFactory() : $this->getContext()->getByType(Nette\Bridges\ApplicationLatte\ILatteFactory::class)->create();
$template = $class ? new $class : new Nette\Bridges\ApplicationLatte\Template($latte);

$template->setParameters($this->request->getParameters());
Expand Down Expand Up @@ -156,7 +156,7 @@ public function error($message = NULL, $code = Http\IResponse::S404_NOT_FOUND)


/**
* @return Nette\Application\IRequest
* @return Nette\Application\Request
*/
public function getRequest()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Application/PresenterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function getPresenterClass(& $name)
$reflection = new \ReflectionClass($class);
$class = $reflection->getName();

if (!$reflection->implementsInterface('Nette\Application\IPresenter')) {
if (!$reflection->implementsInterface(IPresenter::class)) {
throw new InvalidPresenterException("Cannot load presenter '$name', class '$class' is not Nette\\Application\\IPresenter implementor.");
} elseif ($reflection->isAbstract()) {
throw new InvalidPresenterException("Cannot load presenter '$name', class '$class' is abstract.");
Expand Down
4 changes: 1 addition & 3 deletions src/Application/Routers/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,7 @@ private function setMask($mask, array $metadata)
// name=<parameter-name [pattern]>
$matches = Strings::matchAll($parts[$i - 1], '/(?:([a-zA-Z0-9_.-]+)=)?<([^> ]+) *([^>]*)>/');

foreach ($matches as $match) {
list(, $param, $name, $pattern) = $match; // $pattern is not used

foreach ($matches as list(, $param, $name, $pattern)) { // $pattern is not used
if (isset(static::$styles['?' . $name])) {
$meta = static::$styles['?' . $name];
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/Application/UI/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(Nette\ComponentModel\IContainer $parent = NULL, $nam
protected function validateParent(Nette\ComponentModel\IContainer $parent)
{
parent::validateParent($parent);
$this->monitor('Nette\Application\UI\Presenter');
$this->monitor(Presenter::class);
}


Expand All @@ -47,7 +47,7 @@ protected function validateParent(Nette\ComponentModel\IContainer $parent)
*/
public function getPresenter($need = TRUE)
{
return $this->lookup('Nette\Application\UI\Presenter', $need);
return $this->lookup(Presenter::class, $need);
}


Expand All @@ -60,7 +60,7 @@ public function getPresenter($need = TRUE)
protected function attached($presenter)
{
if ($presenter instanceof Presenter) {
$name = $this->lookupPath('Nette\Application\UI\Presenter');
$name = $this->lookupPath(Presenter::class);

if (!isset($this->getElementPrototype()->id)) {
$this->getElementPrototype()->id = 'frm-' . $name;
Expand Down
4 changes: 2 additions & 2 deletions src/Application/UI/Presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ public function canonicalize()

/**
* Attempts to cache the sent entity by its last modification date.
* @param string|int|DateTime last modified time
* @param string|int|\DateTimeInterface last modified time
* @param string strong entity tag validator
* @param mixed optional expiration time
* @return void
Expand Down Expand Up @@ -1156,7 +1156,7 @@ protected function getGlobalState($forClass = NULL)
}

$components = $this->getReflection()->getPersistentComponents();
$iterator = $this->getComponents(TRUE, 'Nette\Application\UI\IStatePersistent');
$iterator = $this->getComponents(TRUE, IStatePersistent::class);

foreach ($iterator as $name => $component) {
if ($iterator->getDepth() === 0) {
Expand Down
6 changes: 3 additions & 3 deletions src/Application/UI/PresenterComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class PresenterComponent extends Nette\ComponentModel\Container impleme
*/
public function getPresenter($need = TRUE)
{
return $this->lookup('Nette\Application\UI\Presenter', $need);
return $this->lookup(Presenter::class, $need);
}


Expand All @@ -44,7 +44,7 @@ public function getPresenter($need = TRUE)
*/
public function getUniqueId()
{
return $this->lookupPath('Nette\Application\UI\Presenter', TRUE);
return $this->lookupPath(Presenter::class, TRUE);
}


Expand All @@ -68,7 +68,7 @@ protected function attached($presenter)
protected function validateParent(Nette\ComponentModel\IContainer $parent)
{
parent::validateParent($parent);
$this->monitor('Nette\Application\UI\Presenter');
$this->monitor(Presenter::class);
}


Expand Down
4 changes: 2 additions & 2 deletions src/Application/UI/PresenterComponentReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getPersistentParams($class = NULL)
return $params;
}
$params = [];
if (is_subclass_of($class, 'Nette\Application\UI\PresenterComponent')) {
if (is_subclass_of($class, PresenterComponent::class)) {
$defaults = get_class_vars($class);
foreach ($class::getPersistentParams() as $name => $default) {
if (is_int($name)) {
Expand Down Expand Up @@ -76,7 +76,7 @@ public function getPersistentComponents($class = NULL)
return $components;
}
$components = [];
if (is_subclass_of($class, 'Nette\Application\UI\Presenter')) {
if (is_subclass_of($class, Presenter::class)) {
foreach ($class::getPersistentComponents() as $name => $meta) {
if (is_string($meta)) {
$name = $meta;
Expand Down
20 changes: 10 additions & 10 deletions src/Bridges/ApplicationDI/ApplicationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public function loadConfiguration()
{
$config = $this->validateConfig($this->defaults);
$container = $this->getContainerBuilder();
$container->addExcludedClasses(['Nette\Application\UI\Control']);
$container->addExcludedClasses([UI\Control::class]);

$this->invalidLinkMode = $this->debugMode
? UI\Presenter::INVALID_LINK_TEXTUAL | ($config['silentLinks'] ? 0 : UI\Presenter::INVALID_LINK_WARNING)
: UI\Presenter::INVALID_LINK_WARNING;

$application = $container->addDefinition($this->prefix('application'))
->setClass('Nette\Application\Application')
->setClass(Nette\Application\Application::class)
->addSetup('$catchExceptions', [$config['catchExceptions']])
->addSetup('$errorPresenter', [$config['errorPresenter']]);

Expand All @@ -68,17 +68,17 @@ public function loadConfiguration()

$touch = $this->debugMode && $config['scanDirs'] ? $this->tempFile : NULL;
$presenterFactory = $container->addDefinition($this->prefix('presenterFactory'))
->setClass('Nette\Application\IPresenterFactory')
->setFactory('Nette\Application\PresenterFactory', [new Nette\DI\Statement(
'Nette\Bridges\ApplicationDI\PresenterFactoryCallback', [1 => $this->invalidLinkMode, $touch]
->setClass(Nette\Application\IPresenterFactory::class)
->setFactory(Nette\Application\PresenterFactory::class, [new Nette\DI\Statement(
Nette\Bridges\ApplicationDI\PresenterFactoryCallback::class, [1 => $this->invalidLinkMode, $touch]
)]);

if ($config['mapping']) {
$presenterFactory->addSetup('setMapping', [$config['mapping']]);
}

$container->addDefinition($this->prefix('linkGenerator'))
->setFactory('Nette\Application\LinkGenerator', [
->setFactory(Nette\Application\LinkGenerator::class, [
1 => new Nette\DI\Statement('@Nette\Http\IRequest::getUrl'),
]);

Expand All @@ -94,7 +94,7 @@ public function beforeCompile()
$container = $this->getContainerBuilder();
$all = [];

foreach ($container->findByType('Nette\Application\IPresenter') as $def) {
foreach ($container->findByType(Nette\Application\IPresenter::class) as $def) {
$all[$def->getClass()] = $def;
}

Expand All @@ -107,7 +107,7 @@ public function beforeCompile()

foreach ($all as $def) {
$def->setInject(TRUE)->setAutowired(FALSE)->addTag('nette.presenter', $def->getClass());
if (is_subclass_of($def->getClass(), 'Nette\Application\UI\Presenter')) {
if (is_subclass_of($def->getClass(), UI\Presenter::class)) {
$def->addSetup('$invalidLinkMode', [$this->invalidLinkMode]);
}
}
Expand All @@ -121,7 +121,7 @@ private function findPresenters()
$classes = [];

if ($config['scanDirs']) {
if (!class_exists('Nette\Loaders\RobotLoader')) {
if (!class_exists(Nette\Loaders\RobotLoader::class)) {
throw new Nette\NotSupportedException("RobotLoader is required to find presenters, install package `nette/robot-loader` or disable option {$this->prefix('scanDirs')}: false");
}
$robot = new Nette\Loaders\RobotLoader;
Expand All @@ -147,7 +147,7 @@ private function findPresenters()
$presenters = [];
foreach (array_unique($classes) as $class) {
if (strpos($class, $config['scanFilter']) !== FALSE && class_exists($class)
&& ($rc = new \ReflectionClass($class)) && $rc->implementsInterface('Nette\Application\IPresenter')
&& ($rc = new \ReflectionClass($class)) && $rc->implementsInterface(Nette\Application\IPresenter::class)
&& !$rc->isAbstract()
) {
$presenters[] = $rc->getName();
Expand Down
10 changes: 5 additions & 5 deletions src/Bridges/ApplicationDI/LatteExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ public function __construct($tempDir, $debugMode = FALSE)

public function loadConfiguration()
{
if (!class_exists('Latte\Engine')) {
if (!class_exists(Latte\Engine::class)) {
return;
}

$config = $this->validateConfig($this->defaults);
$container = $this->getContainerBuilder();

$container->addDefinition($this->prefix('latteFactory'))
->setClass('Latte\Engine')
->setClass(Latte\Engine::class)
->addSetup('setTempDirectory', [$this->tempDir])
->addSetup('setAutoRefresh', [$this->debugMode])
->addSetup('setContentType', [$config['xhtml'] ? Latte\Compiler::CONTENT_XHTML : Latte\Compiler::CONTENT_HTML])
->addSetup('Nette\Utils\Html::$xhtml = ?', [(bool) $config['xhtml']])
->setImplement('Nette\Bridges\ApplicationLatte\ILatteFactory');
->setImplement(Nette\Bridges\ApplicationLatte\ILatteFactory::class);

$container->addDefinition($this->prefix('templateFactory'))
->setClass('Nette\Application\UI\ITemplateFactory')
->setFactory('Nette\Bridges\ApplicationLatte\TemplateFactory');
->setClass(Nette\Application\UI\ITemplateFactory::class)
->setFactory(Nette\Bridges\ApplicationLatte\TemplateFactory::class);

foreach ($config['macros'] as $macro) {
if (strpos($macro, '::') === FALSE && class_exists($macro)) {
Expand Down
8 changes: 4 additions & 4 deletions src/Bridges/ApplicationDI/RoutingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public function loadConfiguration()
$container = $this->getContainerBuilder();

$router = $container->addDefinition($this->prefix('router'))
->setClass('Nette\Application\IRouter')
->setFactory('Nette\Application\Routers\RouteList');
->setClass(Nette\Application\IRouter::class)
->setFactory(Nette\Application\Routers\RouteList::class);

foreach ($config['routes'] as $mask => $action) {
$router->addSetup('$service[] = new Nette\Application\Routers\Route(?, ?);', [$mask, $action]);
Expand All @@ -54,9 +54,9 @@ public function beforeCompile()
{
$container = $this->getContainerBuilder();

if ($this->debugMode && $this->config['debugger'] && $application = $container->getByType('Nette\Application\Application')) {
if ($this->debugMode && $this->config['debugger'] && $application = $container->getByType(Nette\Application\Application::class)) {
$container->getDefinition($application)->addSetup('@Tracy\Bar::addPanel', [
new Nette\DI\Statement('Nette\Bridges\ApplicationTracy\RoutingPanel'),
new Nette\DI\Statement(Nette\Bridges\ApplicationTracy\RoutingPanel::class),
]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/ApplicationLatte/TemplateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function createTemplate(UI\Control $control = NULL)
$latte->getParser()->shortNoEscape = TRUE;
$latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler()));
UIMacros::install($latte->getCompiler());
if (class_exists('Nette\Bridges\FormsLatte\FormMacros')) {
if (class_exists(Nette\Bridges\FormsLatte\FormMacros::class)) {
Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
}
if ($control) {
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/ApplicationTracy/RoutingPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private function findSource()
}
$rc = new \ReflectionClass($class);

if ($rc->isSubclassOf('Nette\Application\UI\Presenter')) {
if ($rc->isSubclassOf(Nette\Application\UI\Presenter::class)) {
if (isset($request->parameters[Presenter::SIGNAL_KEY])) {
$method = $class::formatSignalMethod($request->parameters[Presenter::SIGNAL_KEY]);

Expand Down
12 changes: 6 additions & 6 deletions tests/Application.DI/ApplicationExtension.basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ test(function () {
$compiler->addExtension('application', new ApplicationExtension(FALSE));

$builder = $compiler->getContainerBuilder();
$builder->addDefinition('myRouter')->setClass('Nette\Application\Routers\SimpleRouter');
$builder->addDefinition('myHttpRequest')->setFactory('Nette\Http\Request', [new DI\Statement('Nette\Http\UrlScript')]);
$builder->addDefinition('myHttpResponse')->setClass('Nette\Http\Response');
$builder->addDefinition('myRouter')->setClass(Nette\Application\Routers\SimpleRouter::class);
$builder->addDefinition('myHttpRequest')->setFactory(Nette\Http\Request::class, [new DI\Statement(Nette\Http\UrlScript::class)]);
$builder->addDefinition('myHttpResponse')->setClass(Nette\Http\Response::class);

$code = $compiler->compile([
'application' => ['debugger' => FALSE],
], 'Container1');
eval($code);

$container = new Container1;
Assert::type('Nette\Application\Application', $container->getService('application'));
Assert::type('Nette\Application\PresenterFactory', $container->getService('nette.presenterFactory'));
Assert::type('Nette\Application\LinkGenerator', $container->getService('application.linkGenerator'));
Assert::type(Nette\Application\Application::class, $container->getService('application'));
Assert::type(Nette\Application\PresenterFactory::class, $container->getService('nette.presenterFactory'));
Assert::type(Nette\Application\LinkGenerator::class, $container->getService('application.linkGenerator'));
});
6 changes: 3 additions & 3 deletions tests/Application.DI/ApplicationExtension.invalidLink.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ function createCompiler($config)
$compiler = new DI\Compiler;
$compiler->loadConfig(Tester\FileMock::create($config, 'neon'));
$builder = $compiler->getContainerBuilder();
$builder->addDefinition('myRouter')->setClass('Nette\Application\Routers\SimpleRouter');
$builder->addDefinition('myHttpRequest')->setFactory('Nette\Http\Request', [new DI\Statement('Nette\Http\UrlScript')]);
$builder->addDefinition('myHttpResponse')->setClass('Nette\Http\Response');
$builder->addDefinition('myRouter')->setClass(Nette\Application\Routers\SimpleRouter::class);
$builder->addDefinition('myHttpRequest')->setFactory(Nette\Http\Request::class, [new DI\Statement(Nette\Http\UrlScript::class)]);
$builder->addDefinition('myHttpResponse')->setClass(Nette\Http\Response::class);
return $compiler;
}

Expand Down
Loading