Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVIF image support and MimeType chaining #307

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b36e122
fixed phpDoc
dg Mar 11, 2023
1a51373
UploadControl: changed %i to %d [Closes #300]
dg Mar 12, 2023
8a23250
Container: const Array changed to public [Closes #301]
dg Mar 12, 2023
3281154
opened 4.0-dev
dg Mar 1, 2021
b369ca9
removed community health files
dg Mar 11, 2021
ac849b0
requires PHP 8.0
dg Mar 1, 2021
d8f11cd
composer: updated dependencies
dg Oct 9, 2021
7c93965
uses newer nette utils
dg Jan 19, 2023
94fb570
coding style
dg Mar 8, 2023
ff110a2
removed support for PHP 7
dg Oct 6, 2021
2610054
added property typehints
dg Mar 1, 2021
6aaf0c6
added PHP 8 typehints
dg Oct 12, 2022
5b6f1af
used 'string|Stringable' for labels and messages
dg Mar 8, 2023
5ceb3f9
used native PHP 8 features
dg Mar 8, 2023
6c22115
added deprecated notices
dg Jan 9, 2023
fa3ea63
uses PascalCase constants
dg Nov 27, 2022
e788db8
used Tester 2.5 [WIP - new nette/http]
dg Feb 5, 2023
d44b399
Container: getValues(true) is deprecated (BC break)
dg Sep 12, 2021
913bdb2
Container: only Control/Container can be added to form (BC break)
dg Sep 12, 2021
a912ffb
some classes marked as final (BC break)
dg Nov 9, 2021
94f6ccd
phpdoc generics for Control
dg Nov 9, 2021
d25e590
added type inference tests
dg Nov 9, 2021
e837ad4
Validator: added support for enums (#282)
drobek94 Jan 18, 2022
34acd8f
BaseControl, ControlGroup::getOption() parameter $default is deprecated
dg Jun 21, 2022
c14529d
netteForms: showModal uses <dialog> by default
dg Oct 3, 2022
b932488
added HTML attribute data-nette-error
dg Nov 27, 2022
568b4ad
CsrfProtection: used new sessionSection API
dg Dec 4, 2022
365a6ad
removed compatibility for old class names
dg Dec 19, 2022
7d19c3b
Latte: {inputError} must have argument
dg Dec 27, 2022
d4de286
Latte: Runtime for v2 renamed to Runtime2
dg Dec 27, 2022
e410aef
Latte: rewritten Runtime as non-static class
dg Dec 27, 2022
6cacbc4
added: avif support
jhabaj May 22, 2023
3bcf1c3
added: Mime validator chaining
jhabaj May 22, 2023
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
19 changes: 0 additions & 19 deletions .github/ISSUE_TEMPLATE/Bug_report.md

This file was deleted.

9 changes: 0 additions & 9 deletions .github/ISSUE_TEMPLATE/Feature_request.md

This file was deleted.

12 changes: 0 additions & 12 deletions .github/ISSUE_TEMPLATE/Support_question.md

This file was deleted.

21 changes: 0 additions & 21 deletions .github/ISSUE_TEMPLATE/Support_us.md

This file was deleted.

2 changes: 0 additions & 2 deletions .github/funding.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/pull_request_template.md

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.0
coverage: none

- run: composer install --no-progress --prefer-dist
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
php: ['8.0', '8.1', '8.2']

fail-fast: false

Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 7.2
php-version: 8.0
coverage: none

- run: composer update --no-progress --prefer-dist --prefer-lowest --prefer-stable
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
}
],
"require": {
"php": ">=7.2 <8.3",
"nette/component-model": "^3.0",
"nette/http": "^3.1",
"nette/utils": "^3.2.5 || ~4.0.0"
"php": ">=8.0 <8.3",
"nette/component-model": "^4.0",
"nette/http": "^4.0",
"nette/utils": "^4.0"
},
"require-dev": {
"nette/application": "^3.0",
"nette/di": "^3.0",
"nette/tester": "^2.4",
"nette/application": "^4.0",
"nette/di": "^3.1 || ^4.0",
"nette/tester": "^2.5",
"latte/latte": "^2.10.2 || ^3.0.3",
"tracy/tracy": "^2.9",
"phpstan/phpstan-nette": "^1"
Expand All @@ -41,7 +41,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
"dev-master": "4.0-dev"
}
}
}
33 changes: 0 additions & 33 deletions contributing.md

This file was deleted.

9 changes: 4 additions & 5 deletions examples/custom-control.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@

class DateInput extends Nette\Forms\Controls\BaseControl
{
/** @var string */
private $day = '';
private string $day = '';

private $month = '';
private string $month = '';

private $year = '';
private string $year = '';


public function __construct($label = null)
Expand Down Expand Up @@ -88,7 +87,7 @@ public function getControl()
. Helpers::createSelectBox(
[1 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
[],
$this->month
$this->month,
)->name($name . '[month]')

. Html::el('input', [
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The recommended way to install is via Composer:
composer require nette/forms
```

It requires PHP version 7.2 and supports PHP up to 8.2.
It requires PHP version 8.0 and supports PHP up to 8.2.


Client-side support can be installed with npm or yarn:
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/FormsDI/FormsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct()
{
$this->config = new class {
/** @var string[] */
public $messages = [];
public array $messages = [];
};
}

Expand Down
34 changes: 16 additions & 18 deletions src/Bridges/FormsLatte/FormMacros.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class FormMacros extends MacroSet
public static function install(Latte\Compiler $compiler): void
{
$me = new static($compiler);
$me->addMacro('form', [$me, 'macroForm'], 'echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack));');
$me->addMacro('form', [$me, 'macroForm'], 'echo Nette\Bridges\FormsLatte\Runtime2::renderFormEnd(array_pop($this->global->formsStack));');
$me->addMacro('formContext', [$me, 'macroFormContext'], 'array_pop($this->global->formsStack);');
$me->addMacro('formContainer', [$me, 'macroFormContainer'], 'array_pop($this->global->formsStack); $formContainer = end($this->global->formsStack)');
$me->addMacro('label', [$me, 'macroLabel'], [$me, 'macroLabelEnd'], null, self::AUTO_EMPTY);
Expand Down Expand Up @@ -67,12 +67,12 @@ public function macroForm(MacroNode $node, PhpWriter $writer)
$node->replaced = true;
$node->tokenizer->reset();
return $writer->write(
'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $this->global->formsStack[] = '
'echo Nette\Bridges\FormsLatte\Runtime2::renderFormBegin($form = $this->global->formsStack[] = '
. ($name[0] === '$'
? 'is_object($ʟ_tmp = %node.word) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp]'
: '$this->global->uiControl[%node.word]')
. ', %node.array)'
. " /* line $node->startLine */;"
. " /* line $node->startLine */;",
);
}

Expand Down Expand Up @@ -101,7 +101,7 @@ public function macroFormContext(MacroNode $node, PhpWriter $writer)
. ($name[0] === '$'
? 'is_object($ʟ_tmp = %node.word) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp]'
: '$this->global->uiControl[%node.word]')
. " /* line $node->startLine */;"
. " /* line $node->startLine */;",
);
}

Expand All @@ -126,7 +126,7 @@ public function macroFormContainer(MacroNode $node, PhpWriter $writer)
. ($name[0] === '$'
? 'is_object($ʟ_tmp = %node.word) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]'
: 'end($this->global->formsStack)[%node.word]')
. " /* line $node->startLine */;"
. " /* line $node->startLine */;",
);
}

Expand Down Expand Up @@ -155,7 +155,7 @@ public function macroLabel(MacroNode $node, PhpWriter $writer)
. '->%1.raw) echo $ʟ_label'
. ($node->tokenizer->isNext() ? '->addAttributes(%node.array)' : ''),
$name,
$words ? ('getLabelPart(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')') : 'getLabel()'
$words ? ('getLabelPart(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')') : 'getLabel()',
);
}

Expand Down Expand Up @@ -196,7 +196,7 @@ public function macroInput(MacroNode $node, PhpWriter $writer)
. ($node->tokenizer->isNext() ? '->addAttributes(%node.array)' : '')
. " /* line $node->startLine */;",
$name,
$words ? 'getControlPart(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')' : 'getControl()'
$words ? 'getControlPart(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')' : 'getControl()',
);
}

Expand Down Expand Up @@ -227,11 +227,11 @@ public function macroNameAttr(MacroNode $node, PhpWriter $writer)
? 'is_object($ʟ_tmp = %0.word) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp]'
: '$this->global->uiControl[%0.word]')
. " /* line $node->startLine */; ?>",
$name
$name,
);
return $writer->write(
'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), %0.var, false)',
array_fill_keys($definedHtmlAttributes, null)
'echo Nette\Bridges\FormsLatte\Runtime2::renderFormBegin(end($this->global->formsStack), %0.var, false)',
array_fill_keys($definedHtmlAttributes, null),
);
} else {
$method = $tagName === 'label' ? 'getLabel' : 'getControl';
Expand All @@ -245,7 +245,7 @@ public function macroNameAttr(MacroNode $node, PhpWriter $writer)
. " /* line $node->startLine */;",
$name,
$method . 'Part(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')',
array_fill_keys($definedHtmlAttributes, null)
array_fill_keys($definedHtmlAttributes, null),
);
}
}
Expand All @@ -265,7 +265,7 @@ public function macroNameEnd(MacroNode $node, PhpWriter $writer)
{
$tagName = strtolower($node->htmlNode->name);
if ($tagName === 'form') {
$node->innerContent .= '<?php echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false)'
$node->innerContent .= '<?php echo Nette\Bridges\FormsLatte\Runtime2::renderFormEnd(array_pop($this->global->formsStack), false)'
. " /* line $node->startLine */; ?>";
} elseif ($tagName === 'label') {
if ($node->htmlNode->empty) {
Expand Down Expand Up @@ -298,7 +298,7 @@ public function macroInputError(MacroNode $node, PhpWriter $writer)
return $writer->write(
'$ʟ_input = is_object($ʟ_tmp = %0.word) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp];'
. "echo %escape(\$ʟ_input->getError()) /* line $node->startLine */;",
$name
$name,
);
} else {
return $writer->write("echo %escape(end(\$this->global->formsStack)[%0.word]->getError()) /* line $node->startLine */;", $name);
Expand All @@ -319,11 +319,9 @@ public function macroFormPrint(MacroNode $node, PhpWriter $writer)

$node->tokenizer->reset();
return $writer->write(
'Nette\Bridges\FormsLatte\Runtime::render' . $node->name . '('
. ($name[0] === '$'
? 'is_object($ʟ_tmp = %node.word) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp]'
: '$this->global->uiControl[%node.word]')
. '); exit;'
'Nette\Bridges\FormsLatte\Runtime2::render' . $node->name . '('
. ($name[0] === '$' ? 'is_object(%node.word) ? %node.word : ' : '')
. '$this->global->uiControl[%node.word]); exit;',
);
}
}
8 changes: 7 additions & 1 deletion src/Bridges/FormsLatte/FormsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ public function getTags(): array
public function getProviders(): array
{
return [
'formsStack' => [],
'forms' => new Runtime,
];
}


public function getCacheKey(Latte\Engine $engine): array
{
return ['version' => 2];
}
}
2 changes: 1 addition & 1 deletion src/Bridges/FormsLatte/Nodes/FieldNNameNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private function init(Tag $tag)
$elName = strtolower($el->name);

$tag->replaceNAttribute(new AuxiliaryNode(fn(PrintContext $context) => $context->format(
'echo ($ʟ_input = Nette\Bridges\FormsLatte\Runtime::item(%node, $this->global))'
'echo ($ʟ_input = $this->global->forms->item(%node))'
. ($elName === 'label' ? '->getLabelPart(%node)' : '->getControlPart(%node)')
. ($usedAttributes ? '->addAttributes(%dump)' : '')
. '->attributes() %3.line;',
Expand Down
4 changes: 2 additions & 2 deletions src/Bridges/FormsLatte/Nodes/FormContainerNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public static function create(Tag $tag): \Generator
public function print(PrintContext $context): string
{
return $context->format(
'$this->global->formsStack[] = $formContainer = Nette\Bridges\FormsLatte\Runtime::item(%node, $this->global) %line; '
'$this->global->forms->begin($formContainer = $this->global->forms->item(%node)) %line; '
. '%node '
. 'array_pop($this->global->formsStack); $formContainer = end($this->global->formsStack);'
. '$this->global->forms->end(); $formContainer = $this->global->forms->current();'
. "\n\n",
$this->name,
$this->position,
Expand Down
Loading