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

Regenerate validator specs and update SpecGenerator and Dumper classes #384

Merged
merged 1 commit into from
Oct 18, 2021
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
2 changes: 1 addition & 1 deletion bin/generate-validator-spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
if (! class_exists('Nette\PhpGenerator\ClassType')) {
echo "ERROR: The optional package nette/php-generator is needed for code generation.\n";
echo "Install the package via the following Composer command:\n";
echo "composer require --dev nette/php-generator:^3.5\n";
echo "composer require --dev nette/php-generator:3.6.1\n";
exit -1;
}

Expand Down
2 changes: 1 addition & 1 deletion bin/src/Validator/SpecGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private function gatherExtensionsMeta($bundlesConfig)
if (!isset($extensions[$bundleConfig['name']])) {
$extensions[$bundleConfig['name']] = [
'versions' => [],
'latestVersion' => null,
'latestVersion' => '',
];
}

Expand Down
10 changes: 10 additions & 0 deletions bin/src/Validator/SpecGenerator/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,16 @@ public function dumpWithKey($key, $value, $level, $parentKeys = [])
return "{$this->getValueString($key)} => {$this->dump($value, $level, $parentKeys)}";
}

/**
* Get the NetteDumper instance.
*
* @return NetteDumper
*/
public function getDumper()
{
return $this->dumper;
}

/**
* Get the string representation of a value.
*
Expand Down
13 changes: 6 additions & 7 deletions bin/src/Validator/SpecGenerator/SpecPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace AmpProject\Tooling\Validator\SpecGenerator;

use Nette\PhpGenerator\ClassType;
use Nette\PhpGenerator\GlobalFunction;
use Nette\PhpGenerator\Helpers;
use Nette\PhpGenerator\Method;
use Nette\PhpGenerator\PhpNamespace;
Expand Down Expand Up @@ -64,7 +63,7 @@ public function printClass(ClassType $class, PhpNamespace $namespace = null): st
$consts = [];
foreach ($class->getConstants() as $const) {
$consts[] = Helpers::formatDocComment((string) $const->getComment())
. self::printAttributes($const->getAttributes(), $namespace)
. $this->printAttributes($const->getAttributes(), $namespace)
. "const {$const->getName()} = "
. $this->dumper->dump($const->getValue(), 0) . ";\n";
}
Expand All @@ -77,7 +76,7 @@ public function printClass(ClassType $class, PhpNamespace $namespace = null): st
. '$' . $property->getName());

$properties[] = Helpers::formatDocComment((string) $property->getComment())
. self::printAttributes($property->getAttributes(), $namespace)
. $this->printAttributes($property->getAttributes(), $namespace)
. $def
. ($property->getValue() === null && !$property->isInitialized()
? ''
Expand All @@ -102,7 +101,7 @@ public function printClass(ClassType $class, PhpNamespace $namespace = null): st

return Strings::normalize(
Helpers::formatDocComment($class->getComment() . "\n")
. self::printAttributes($class->getAttributes(), $namespace)
. $this->printAttributes($class->getAttributes(), $namespace)
. ($class->isAbstract() ? 'abstract ' : '')
. ($class->isFinal() ? 'final ' : '')
. ($class->getName() ? $class->getType() . ' ' . $class->getName() . ' ' : '')
Expand Down Expand Up @@ -131,7 +130,7 @@ private function printResolvedMethod(Method $method, callable $resolver, PhpName
. $method->getName();

return Helpers::formatDocComment($method->getComment() . "\n")
. self::printAttributes($method->getAttributes(), $namespace)
. $this->printAttributes($method->getAttributes(), $namespace)
. $line
. ($params = $this->printParameters($method, $namespace, strlen($line) + strlen($this->indentation) + 2))
. ($method->isAbstract() || $method->getBody() === null
Expand Down Expand Up @@ -162,8 +161,8 @@ private function printAttributes(array $attrs, ?PhpNamespace $namespace, bool $i
}
$items = [];
foreach ($attrs as $attr) {
$args = (new Dumper())->format('...?:', $attr->getArguments());
$items[] = $this->printType($attr->getName(), false, $namespace) . ($args ? "($args)" : '');
$args = $this->dumper->getDumper()->format('...?:', $attr->getArguments());
$items[] = "\\" . $this->printType($attr->getName(), false, $namespace) . ($args ? "($args)" : '');
}
return $inline
? '#[' . implode(', ', $items) . '] '
Expand Down
4 changes: 4 additions & 0 deletions src/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ interface Attribute
const LOAD_MORE_FAILED = 'load-more-failed';
const LOAD_MORE_LOADING = 'load-more-loading';
const LOCALE = 'locale';
const LOCK_BOUNDS = 'lock-bounds';
const LONGDESC = 'longdesc';
const LOOP = 'loop';
const LOW = 'low';
Expand Down Expand Up @@ -1134,6 +1135,9 @@ interface Attribute
const DATA_WEBCARE_ID = 'data-webcare-id';
const DATA_WIDGET_ID = 'data-widget-id';
const DATA_WIDGET_TYPE = 'data-widget-type';
const DATA_X = 'data-x';
const DATA_Y = 'data-y';
const DATA_ZOOM = 'data-zoom';

const CROSSORIGIN_ANONYMOUS = 'anonymous';
const CROSSORIGIN_USE_CREDENTIALS = 'use-credentials';
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions src/Validator/Spec/Section/Tags.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Validator/Spec/Tag/AmpAdWithTypeCustom.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions src/Validator/Spec/Tag/AmpStoryPanningMedia.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Validator/Spec/Tag/ScriptAmpEmbedlyCard.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading