Skip to content

Commit

Permalink
Exakat cobbler for Functions/SetTypehints
Browse files Browse the repository at this point in the history
  • Loading branch information
The Exakat cobbler committed Feb 24, 2022
1 parent 4a9557d commit c60a05d
Show file tree
Hide file tree
Showing 65 changed files with 149 additions and 149 deletions.
Expand Up @@ -210,7 +210,7 @@ private function getOutputMessage(string $type, string $singularType, array $tax
}

private function getIndexTemplate(string $plural, string $singular)
{
: string {
$title = ucfirst($plural);

return <<<EOT
Expand Down
Expand Up @@ -45,7 +45,7 @@ public function getConfigTreeBuilder(): TreeBuilder
// Default case is we want the user to specify just one
// path but we can allow for multiple if they want to.
->ifString()
->then(function ($v) {
->then(function ($v) : array {
return [$v];
})
->end()
Expand All @@ -61,14 +61,14 @@ public function getConfigTreeBuilder(): TreeBuilder
// Default case is we want the user to specify just one
// taxonomy but we can allow for multiple if they want to.
->ifString()
->then(function ($v) {
->then(function ($v) : array {
return [['name' => $v]];
})
->end()
->prototype('array')
->beforeNormalization()
->ifString()
->then(function ($v) {
->then(function ($v) : array {
return ['name' => $v];
})
->end()
Expand Down
4 changes: 2 additions & 2 deletions src/Sculpin/Bundle/MarkdownBundle/MarkdownConverter.php
Expand Up @@ -32,14 +32,14 @@ final class MarkdownConverter implements ConverterInterface, EventSubscriberInte
/**
* @var ParserInterface
*/
private $markdown;
private ParserInterface $markdown;

/**
* File name extensions that are handled as markdown.
*
* @var string[]
*/
private $extensions = [];
private array $extensions = [];

/**
* Constructor.
Expand Down
Expand Up @@ -31,7 +31,7 @@ final class ConvertListener implements EventSubscriberInterface
*
* @var array
*/
private static $addPlaceholderRe = [
private static array $addPlaceholderRe = [
'/^({%\s+block\s+(\w+).+?%})$/m', // {% %} style code
'/^({%\s+endblock\s+%})$/m', // {% %} style code
'/^({{.+?}})$/m', // {{ }} style code
Expand All @@ -42,14 +42,14 @@ final class ConvertListener implements EventSubscriberInterface
*
* @var string
*/
private static $placeholder = "\n<div><!-- sculpin-hidden -->$1<!-- /sculpin-hidden --></div>\n";
private static string $placeholder = "\n<div><!-- sculpin-hidden -->$1<!-- /sculpin-hidden --></div>\n";

/**
* Regex used to remove placeholder
*
* @var string
*/
private static $removePlaceholderRe = "/(\n?<div><!-- sculpin-hidden -->|<!-- \/sculpin-hidden --><\/div>\n|\n?&lt;div&gt;&lt;!-- sculpin-hidden --&gt;|&lt;!-- \/sculpin-hidden --&gt;&lt;\/div&gt;\n)/m"; // @codingStandardsIgnoreLine
private static string $removePlaceholderRe = "/(\n?<div><!-- sculpin-hidden -->|<!-- \/sculpin-hidden --><\/div>\n|\n?&lt;div&gt;&lt;!-- sculpin-hidden --&gt;|&lt;!-- \/sculpin-hidden --&gt;&lt;\/div&gt;\n)/m"; // @codingStandardsIgnoreLine

/**
* {@inheritdoc}
Expand Down
6 changes: 3 additions & 3 deletions src/Sculpin/Bundle/PaginationBundle/PaginationGenerator.php
Expand Up @@ -28,19 +28,19 @@ final class PaginationGenerator implements GeneratorInterface
/**
* @var DataProviderManager
*/
private $dataProviderManager;
private DataProviderManager $dataProviderManager;

/**
* @var SourcePermalinkFactory
*/
private $permalinkFactory;
private SourcePermalinkFactory $permalinkFactory;

/**
* Max per page (default)
*
* @var int
*/
private $maxPerPage;
private int $maxPerPage;

public function __construct(
DataProviderManager $dataProviderManager,
Expand Down
Expand Up @@ -191,7 +191,7 @@ private function validateInput(InputInterface $input)
private function outputServices(
OutputInterface $output,
$serviceIds,
$showPrivate = false,
bool $showPrivate = false,
$showTagAttributes = null
): void {
// set the label to specify public or public+private
Expand Down Expand Up @@ -239,14 +239,14 @@ private function outputServices(
}
}
$format = '%-'.$maxName.'s ';
$format .= implode("", array_map(function ($length) {
$format .= implode("", array_map(function (string $length) : string {
return "%-{$length}s ";
}, $maxTags));
$format .= '%s';

// the title field needs extra space to make up for comment tags
$format1 = '%-'.($maxName + 19).'s ';
$format1 .= implode("", array_map(function ($length) {
$format1 .= implode("", array_map(function (int $length) : string {
return '%-'.($length + 19).'s ';
}, $maxTags));
$format1 .= '%s';
Expand Down Expand Up @@ -308,7 +308,7 @@ private function outputServices(
}
}

private function buildArgumentsArray($serviceId, $className, array $tagAttributes = []): array
private function buildArgumentsArray(string $serviceId, string $className, array $tagAttributes = []): array
{
$arguments = [$serviceId];
foreach ($tagAttributes as $tagAttribute) {
Expand Down
Expand Up @@ -191,7 +191,7 @@ protected function runSculpin(
IoInterface $io
) {
$messages = [];
$errPrint = function (\Throwable $e) {
$errPrint = function (\Throwable $e) : string {
return $e->getMessage().PHP_EOL.' at '.str_replace(getcwd().DIRECTORY_SEPARATOR, '', $e->getFile());
};

Expand Down
4 changes: 2 additions & 2 deletions src/Sculpin/Bundle/SculpinBundle/Console/Application.php
Expand Up @@ -35,12 +35,12 @@ final class Application extends BaseApplication
/**
* @var KernelInterface
*/
private $kernel;
private KernelInterface $kernel;

/**
* @var \Throwable[]
*/
private $registrationErrors = [];
private array $registrationErrors = [];

public function __construct(KernelInterface $kernel)
{
Expand Down
Expand Up @@ -52,7 +52,7 @@ public function process(ContainerBuilder $container)
}

foreach ($data as $type => $extensions) {
$data[$type] = array_filter($extensions, function ($var) {
$data[$type] = array_filter($extensions, function ($var) : bool {
return strlen($var) > 0;
});
}
Expand Down
Expand Up @@ -29,7 +29,7 @@ class PathConfiguratorPass implements CompilerPassInterface
*
* @var AntPathMatcher
*/
protected $matcher;
protected AntPathMatcher $matcher;

/**
* Constructor.
Expand Down Expand Up @@ -73,7 +73,7 @@ protected function antify($paths)
$matcher = $this->matcher;

return array_map(
function ($path) use ($matcher) {
function (string $path) use ($matcher) : string {
if ($matcher->isPattern($path)) {
return $path;
}
Expand Down
Expand Up @@ -24,7 +24,7 @@
*/
abstract class AbstractKernel extends Kernel
{
protected $missingSculpinBundles = [];
protected array $missingSculpinBundles = [];
protected $outputDir;
protected $projectDir;
protected $sourceDir;
Expand Down
8 changes: 4 additions & 4 deletions src/Sculpin/Bundle/SculpinBundle/HttpServer/HttpServer.php
Expand Up @@ -29,22 +29,22 @@ final class HttpServer
/**
* @var bool
*/
private $debug;
private bool $debug;

/**
* @var string
*/
private $env;
private string $env;

/**
* @var StreamSelectLoop
*/
private $loop;
private StreamSelectLoop $loop;

/**
* @var OutputInterface
*/
private $output;
private OutputInterface $output;

/**
* @var int
Expand Down
4 changes: 2 additions & 2 deletions src/Sculpin/Bundle/TextileBundle/TextileConverter.php
Expand Up @@ -29,14 +29,14 @@ final class TextileConverter implements ConverterInterface, EventSubscriberInter
/**
* @var Parser
*/
private $textileParser;
private Parser $textileParser;

/**
* File name extensions that are handled as textile.
*
* @var string[]
*/
private $extensions = [];
private array $extensions = [];

/**
* @param string[] $extensions file name extensions that are handled as markdown
Expand Down
2 changes: 1 addition & 1 deletion src/Sculpin/Bundle/ThemeBundle/ThemeRegistry.php
Expand Up @@ -19,7 +19,7 @@
class ThemeRegistry
{
private $finderFactory;
private $directory;
private string $directory;
private $activeTheme;

public function __construct($finderFactory, string $directory, ?string $activeTheme = null)
Expand Down
4 changes: 2 additions & 2 deletions src/Sculpin/Bundle/ThemeBundle/ThemeTwigExtension.php
Expand Up @@ -17,12 +17,12 @@ class ThemeTwigExtension extends AbstractExtension
/**
* @var string
*/
private $sourceDirectory;
private string $sourceDirectory;

/**
* @var string
*/
private $themeDirectory;
private string $themeDirectory;

public function __construct(ThemeRegistry $themeRegistry, string $sourceDirectory, string $themeDirectory)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Sculpin/Bundle/ThemeBundle/ThemeTwigLoader.php
Expand Up @@ -22,7 +22,7 @@ class ThemeTwigLoader implements LoaderInterface
/**
* @var ChainLoader
*/
private $chainLoader;
private ChainLoader $chainLoader;

public function __construct(ThemeRegistry $themeRegistry, array $extensions)
{
Expand Down
Expand Up @@ -28,26 +28,26 @@ final class FlexibleExtensionFilesystemLoader implements LoaderInterface, EventS
/**
* @var FilesystemLoader
*/
private $filesystemLoader;
private FilesystemLoader $filesystemLoader;

/**
* @var string[]
*/
private $cachedCacheKey = [];
private array $cachedCacheKey = [];

/**
* @var string[]
*/
private $cachedCacheKeyExtension = [];
private array $cachedCacheKeyExtension = [];

/**
* @var \Throwable[]
*/
private $cachedCacheKeyException = [];
private array $cachedCacheKeyException = [];
/**
* @var string[]
*/
private $extensions = [];
private array $extensions = [];

/**
* @param string[] $sourcePaths
Expand All @@ -56,7 +56,7 @@ final class FlexibleExtensionFilesystemLoader implements LoaderInterface, EventS
*/
public function __construct(string $sourceDir, array $sourcePaths, array $paths, array $extensions)
{
$mappedSourcePaths = array_map(function ($path) use ($sourceDir) {
$mappedSourcePaths = array_map(function (string $path) use ($sourceDir) : string {
return $sourceDir.'/'.$path;
}, $sourcePaths);

Expand All @@ -66,7 +66,7 @@ public function __construct(string $sourceDir, array $sourcePaths, array $paths,
);

$this->filesystemLoader = new FilesystemLoader($allPaths);
$this->extensions = array_map(function ($ext) {
$this->extensions = array_map(function (string $ext) : string {
return $ext?'.'.$ext:$ext;
}, $extensions);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sculpin/Bundle/TwigBundle/TemplateResetter.php
Expand Up @@ -22,7 +22,7 @@
*/
final class TemplateResetter implements EventSubscriberInterface
{
private $twig;
private Environment $twig;

public function __construct(Environment $twig)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Sculpin/Bundle/TwigBundle/TwigFormatter.php
Expand Up @@ -27,12 +27,12 @@ final class TwigFormatter implements FormatterInterface
/**
* @var Environment
*/
private $twig;
private Environment $twig;

/**
* @var ArrayLoader
*/
private $arrayLoader;
private ArrayLoader $arrayLoader;

public function __construct(Environment $twig, ArrayLoader $arrayLoader)
{
Expand Down Expand Up @@ -101,7 +101,7 @@ public function reset()
}

private function massageTemplate(FormatContext $formatContext)
{
: string {
$template = $formatContext->template();
if ($layout = $formatContext->data()->get('layout')) {
// Completely remove anything in verbatim sections so that any blocks defined in there will
Expand Down
2 changes: 1 addition & 1 deletion src/Sculpin/Bundle/TwigBundle/WebpackEncoreHelper.php
Expand Up @@ -9,7 +9,7 @@

class WebpackEncoreHelper extends AbstractExtension implements GlobalsInterface
{
protected $sourceDir;
protected string $sourceDir;
protected $manifest;

public function __construct(string $sourceDir, ?string $manifest)
Expand Down
Expand Up @@ -22,7 +22,7 @@ class ProxySourceCollection implements \ArrayAccess, \Iterator, \Countable
/**
* @var $items ProxySourceItem[]
*/
protected $items = [];
protected array $items = [];
protected $sorter;

public function __construct(array $items = [], SorterInterface $sorter = null)
Expand Down Expand Up @@ -76,7 +76,7 @@ public function next()
}

public function valid()
{
: bool {
return $this->current() !== false;
}

Expand Down Expand Up @@ -130,7 +130,7 @@ public function sort()
}
unset($item);

uasort($this->items, function ($a, $b) use ($comparator) {
uasort($this->items, function ($a, $b) use ($comparator) : int {
$result = $comparator($a[1], $b[1]);

// use the index to prevent undefined behaviour when comparator reports items are "equal"
Expand Down

0 comments on commit c60a05d

Please sign in to comment.