This commit is contained in:
Sami Mazouz 2024-05-10 18:03:01 +01:00
parent bf5b522818
commit 00d4a295e8
No known key found for this signature in database
4 changed files with 62 additions and 11 deletions

View File

@ -4,12 +4,12 @@ import Button from 'flarum/common/components/Button';
import LoadingIndicator from 'flarum/common/components/LoadingIndicator'; import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
import tagsLabel from '../../common/helpers/tagsLabel'; import tagsLabel from '../../common/helpers/tagsLabel';
import type { CommonSettingsItemOptions } from 'flarum/admin/components/AdminPage'; import type { CommonFieldOptions } from 'flarum/common/components/FormGroup';
import type Stream from 'flarum/common/utils/Stream'; import type Stream from 'flarum/common/utils/Stream';
import type { ITagSelectionModalAttrs } from '../../common/components/TagSelectionModal'; import type { ITagSelectionModalAttrs } from '../../common/components/TagSelectionModal';
import type Tag from '../../common/models/Tag'; import type Tag from '../../common/models/Tag';
export interface SelectTagsSettingComponentOptions extends CommonSettingsItemOptions { export interface SelectTagsSettingComponentOptions extends CommonFieldOptions {
type: 'flarum-tags.select-tags'; type: 'flarum-tags.select-tags';
options?: ITagSelectionModalAttrs; options?: ITagSelectionModalAttrs;
} }

View File

@ -12,6 +12,9 @@ namespace Flarum\Frontend\Compiler\Concerns;
use Flarum\Frontend\Compiler\Source\SourceCollector; use Flarum\Frontend\Compiler\Source\SourceCollector;
use Flarum\Frontend\Compiler\Source\SourceInterface; use Flarum\Frontend\Compiler\Source\SourceInterface;
/**
* @template T of SourceInterface
*/
trait HasSources trait HasSources
{ {
/** /**
@ -25,7 +28,7 @@ trait HasSources
} }
/** /**
* @return SourceInterface[] * @return T[]
*/ */
protected function getSources(): array protected function getSources(): array
{ {

View File

@ -18,6 +18,8 @@ use Illuminate\Filesystem\FilesystemAdapter;
/** /**
* Used to copy JS files from a package directory to the assets' directory. * Used to copy JS files from a package directory to the assets' directory.
* Without concatenating them. Primarily used for lazy loading JS modules. * Without concatenating them. Primarily used for lazy loading JS modules.
*
* @uses HasSources<DirectorySource>
*/ */
class JsDirectoryCompiler implements CompilerInterface class JsDirectoryCompiler implements CompilerInterface
{ {
@ -44,6 +46,7 @@ class JsDirectoryCompiler implements CompilerInterface
public function commit(bool $force = false): void public function commit(bool $force = false): void
{ {
/** @var DirectorySource $source */
foreach ($this->getSources() as $source) { foreach ($this->getSources() as $source) {
$this->compileSource($source, $force); $this->compileSource($source, $force);
} }
@ -51,6 +54,7 @@ class JsDirectoryCompiler implements CompilerInterface
public function getUrl(): ?string public function getUrl(): ?string
{ {
/** @var DirectorySource $source */
foreach ($this->getSources() as $source) { foreach ($this->getSources() as $source) {
$this->eachFile($source, fn (JsCompiler $compiler) => $compiler->getUrl()); $this->eachFile($source, fn (JsCompiler $compiler) => $compiler->getUrl());
} }
@ -60,6 +64,7 @@ class JsDirectoryCompiler implements CompilerInterface
public function flush(): void public function flush(): void
{ {
/** @var DirectorySource $source */
foreach ($this->getSources() as $source) { foreach ($this->getSources() as $source) {
$this->flushSource($source); $this->flushSource($source);
} }

View File

@ -12,6 +12,7 @@ parameters:
bootstrapFiles: bootstrapFiles:
- bootstrap.php - bootstrap.php
checkOctaneCompatibility: false checkOctaneCompatibility: false
noEnvCallsOutsideOfConfig: false
noModelMake: true noModelMake: true
noUnnecessaryCollectionCall: true noUnnecessaryCollectionCall: true
noUnnecessaryCollectionCallOnly: [] noUnnecessaryCollectionCallOnly: []
@ -24,9 +25,11 @@ parameters:
checkModelProperties: false checkModelProperties: false
checkPhpDocMissingReturn: false checkPhpDocMissingReturn: false
checkUnusedViews: false checkUnusedViews: false
checkModelAppends: false
parametersSchema: parametersSchema:
checkOctaneCompatibility: bool() checkOctaneCompatibility: bool()
noEnvCallsOutsideOfConfig: bool()
noModelMake: bool() noModelMake: bool()
noUnnecessaryCollectionCall: bool() noUnnecessaryCollectionCall: bool()
noUnnecessaryCollectionCallOnly: listOf(string()) noUnnecessaryCollectionCallOnly: listOf(string())
@ -38,8 +41,11 @@ parametersSchema:
disableSchemaScan: bool() disableSchemaScan: bool()
checkModelProperties: bool() checkModelProperties: bool()
checkUnusedViews: bool() checkUnusedViews: bool()
checkModelAppends: bool()
conditionalTags: conditionalTags:
Larastan\Larastan\Rules\NoEnvCallsOutsideOfConfigRule:
phpstan.rules.rule: %noEnvCallsOutsideOfConfig%
Larastan\Larastan\Rules\NoModelMakeRule: Larastan\Larastan\Rules\NoModelMakeRule:
phpstan.rules.rule: %noModelMake% phpstan.rules.rule: %noModelMake%
Larastan\Larastan\Rules\NoUnnecessaryCollectionCallRule: Larastan\Larastan\Rules\NoUnnecessaryCollectionCallRule:
@ -52,6 +58,8 @@ conditionalTags:
phpstan.rules.rule: %checkModelProperties% phpstan.rules.rule: %checkModelProperties%
Larastan\Larastan\Rules\UnusedViewsRule: Larastan\Larastan\Rules\UnusedViewsRule:
phpstan.rules.rule: %checkUnusedViews% phpstan.rules.rule: %checkUnusedViews%
Larastan\Larastan\Rules\ModelAppendsRule:
phpstan.rules.rule: %checkModelAppends%
services: services:
- -
@ -163,6 +171,10 @@ services:
class: Larastan\Larastan\Properties\ModelRelationsExtension class: Larastan\Larastan\Properties\ModelRelationsExtension
tags: tags:
- phpstan.broker.propertiesClassReflectionExtension - phpstan.broker.propertiesClassReflectionExtension
-
class: Larastan\Larastan\ReturnTypes\ModelOnlyDynamicMethodReturnTypeExtension
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension
- -
class: Larastan\Larastan\ReturnTypes\ModelFactoryDynamicStaticMethodReturnTypeExtension class: Larastan\Larastan\ReturnTypes\ModelFactoryDynamicStaticMethodReturnTypeExtension
@ -287,7 +299,7 @@ services:
- phpstan.broker.dynamicMethodReturnTypeExtension - phpstan.broker.dynamicMethodReturnTypeExtension
- -
class: Larastan\Larastan\ReturnTypes\CollectionGenericStaticMethodDynamicMethodReturnTypeExtension class: Larastan\Larastan\ReturnTypes\EnumerableGenericStaticMethodDynamicMethodReturnTypeExtension
tags: tags:
- phpstan.broker.dynamicMethodReturnTypeExtension - phpstan.broker.dynamicMethodReturnTypeExtension
@ -302,7 +314,7 @@ services:
- phpstan.broker.dynamicMethodReturnTypeExtension - phpstan.broker.dynamicMethodReturnTypeExtension
- -
class: Larastan\Larastan\ReturnTypes\CollectionGenericStaticMethodDynamicStaticMethodReturnTypeExtension class: Larastan\Larastan\ReturnTypes\EnumerableGenericStaticMethodDynamicStaticMethodReturnTypeExtension
tags: tags:
- phpstan.broker.dynamicStaticMethodReturnTypeExtension - phpstan.broker.dynamicStaticMethodReturnTypeExtension
@ -348,6 +360,11 @@ services:
tags: tags:
- phpstan.broker.dynamicFunctionReturnTypeExtension - phpstan.broker.dynamicFunctionReturnTypeExtension
-
class: Larastan\Larastan\ReturnTypes\Helpers\StrExtension
tags:
- phpstan.broker.dynamicFunctionReturnTypeExtension
- -
class: Larastan\Larastan\ReturnTypes\Helpers\TapExtension class: Larastan\Larastan\ReturnTypes\Helpers\TapExtension
tags: tags:
@ -371,6 +388,9 @@ services:
- -
class: Larastan\Larastan\Rules\OctaneCompatibilityRule class: Larastan\Larastan\Rules\OctaneCompatibilityRule
-
class: Larastan\Larastan\Rules\NoEnvCallsOutsideOfConfigRule
- -
class: Larastan\Larastan\Rules\NoModelMakeRule class: Larastan\Larastan\Rules\NoModelMakeRule
@ -383,6 +403,9 @@ services:
- -
class: Larastan\Larastan\Rules\ModelProperties\ModelPropertyRule class: Larastan\Larastan\Rules\ModelProperties\ModelPropertyRule
-
class: Larastan\Larastan\Rules\ModelAppendsRule
- -
class: Larastan\Larastan\Rules\ModelProperties\ModelPropertyStaticCallRule class: Larastan\Larastan\Rules\ModelProperties\ModelPropertyStaticCallRule
@ -413,6 +436,7 @@ services:
databaseMigrationPath: %databaseMigrationsPath% databaseMigrationPath: %databaseMigrationsPath%
disableMigrationScan: %disableMigrationScan% disableMigrationScan: %disableMigrationScan%
parser: @currentPhpVersionSimpleDirectParser parser: @currentPhpVersionSimpleDirectParser
reflectionProvider: @reflectionProvider
- -
class: Larastan\Larastan\Properties\SquashedMigrationHelper class: Larastan\Larastan\Properties\SquashedMigrationHelper
@ -423,6 +447,9 @@ services:
- -
class: Larastan\Larastan\Properties\ModelCastHelper class: Larastan\Larastan\Properties\ModelCastHelper
-
class: Larastan\Larastan\Properties\ModelPropertyHelper
- -
class: Larastan\Larastan\Rules\ModelProperties\ModelPropertiesRuleHelper class: Larastan\Larastan\Rules\ModelProperties\ModelPropertiesRuleHelper
@ -451,11 +478,14 @@ services:
dispatchableClass: Illuminate\Foundation\Events\Dispatchable dispatchableClass: Illuminate\Foundation\Events\Dispatchable
tags: tags:
- phpstan.rules.rule - phpstan.rules.rule
- Larastan\Larastan\Properties\Schema\PhpMyAdminDataTypeToPhpTypeConverter
-
class: Larastan\Larastan\Properties\Schema\PhpMyAdminDataTypeToPhpTypeConverter
- -
class: Larastan\Larastan\LarastanStubFilesExtension class: Larastan\Larastan\LarastanStubFilesExtension
tags: [phpstan.stubFilesExtension] tags:
- phpstan.stubFilesExtension
- -
class: Larastan\Larastan\Rules\UnusedViewsRule class: Larastan\Larastan\Rules\UnusedViewsRule
@ -507,35 +537,48 @@ services:
class: Larastan\Larastan\ReturnTypes\ConsoleCommand\ArgumentDynamicReturnTypeExtension class: Larastan\Larastan\ReturnTypes\ConsoleCommand\ArgumentDynamicReturnTypeExtension
tags: tags:
- phpstan.broker.dynamicMethodReturnTypeExtension - phpstan.broker.dynamicMethodReturnTypeExtension
- -
class: Larastan\Larastan\ReturnTypes\ConsoleCommand\HasArgumentDynamicReturnTypeExtension class: Larastan\Larastan\ReturnTypes\ConsoleCommand\HasArgumentDynamicReturnTypeExtension
tags: tags:
- phpstan.broker.dynamicMethodReturnTypeExtension - phpstan.broker.dynamicMethodReturnTypeExtension
- -
class: Larastan\Larastan\ReturnTypes\ConsoleCommand\OptionDynamicReturnTypeExtension class: Larastan\Larastan\ReturnTypes\ConsoleCommand\OptionDynamicReturnTypeExtension
tags: tags:
- phpstan.broker.dynamicMethodReturnTypeExtension - phpstan.broker.dynamicMethodReturnTypeExtension
- -
class: Larastan\Larastan\ReturnTypes\ConsoleCommand\HasOptionDynamicReturnTypeExtension class: Larastan\Larastan\ReturnTypes\ConsoleCommand\HasOptionDynamicReturnTypeExtension
tags: tags:
- phpstan.broker.dynamicMethodReturnTypeExtension - phpstan.broker.dynamicMethodReturnTypeExtension
- -
class: Larastan\Larastan\ReturnTypes\TranslatorGetReturnTypeExtension class: Larastan\Larastan\ReturnTypes\TranslatorGetReturnTypeExtension
tags: tags:
- phpstan.broker.dynamicMethodReturnTypeExtension - phpstan.broker.dynamicMethodReturnTypeExtension
- -
class: Larastan\Larastan\ReturnTypes\TransHelperReturnTypeExtension class: Larastan\Larastan\ReturnTypes\TransHelperReturnTypeExtension
tags: tags:
- phpstan.broker.dynamicFunctionReturnTypeExtension - phpstan.broker.dynamicFunctionReturnTypeExtension
- -
class: Larastan\Larastan\ReturnTypes\DoubleUnderscoreHelperReturnTypeExtension class: Larastan\Larastan\ReturnTypes\DoubleUnderscoreHelperReturnTypeExtension
tags: tags:
- phpstan.broker.dynamicFunctionReturnTypeExtension - phpstan.broker.dynamicFunctionReturnTypeExtension
- Larastan\Larastan\ReturnTypes\AppMakeHelper -
- Larastan\Larastan\Internal\ConsoleApplicationResolver class: Larastan\Larastan\ReturnTypes\AppMakeHelper
- Larastan\Larastan\Internal\ConsoleApplicationHelper
- Larastan\Larastan\Support\HigherOrderCollectionProxyHelper -
class: Larastan\Larastan\Internal\ConsoleApplicationResolver
-
class: Larastan\Larastan\Internal\ConsoleApplicationHelper
-
class: Larastan\Larastan\Support\HigherOrderCollectionProxyHelper
rules: rules:
- Larastan\Larastan\Rules\UselessConstructs\NoUselessWithFunctionCallsRule - Larastan\Larastan\Rules\UselessConstructs\NoUselessWithFunctionCallsRule