mirror of
https://github.com/flarum/core.git
synced 2025-08-07 00:47:00 +02:00
refactor: JSON:API (#3971)
* refactor: json:api refactor iteration 1 * chore: delete dead code * fix: regressions * chore: move additions/changes to package * feat: AccessTokenResource * feat: allow dependency injection in resources * feat: `ApiResource` extender * feat: improve * feat: refactor tags extension * feat: refactor flags extension * fix: regressions * fix: drop bc layer * feat: refactor suspend extension * feat: refactor subscriptions extension * feat: refactor approval extension * feat: refactor sticky extension * feat: refactor nicknames extension * feat: refactor mentions extension * feat: refactor lock extension * feat: refactor likes extension * chore: merge conflicts * feat: refactor extension-manager extension * feat: context current endpoint helpers * chore: minor * feat: cleaner sortmap implementation * chore: drop old package * chore: not needed (auto scoping) * fix: actor only fields * refactor: simplify index endpoint * feat: eager loading * test: adapt * test: phpstan * test: adapt * fix: typing * fix: approving content * tet: adapt frontend tests * chore: typings * chore: review * fix: breaking change
This commit is contained in:
@@ -16,6 +16,9 @@ parameters:
|
||||
- stubs/Illuminate/Contracts/Filesystem/Cloud.stub
|
||||
- stubs/Illuminate/Contracts/Filesystem/Filesystem.stub
|
||||
|
||||
# We know for a fact the JsonApi object used internally is always the Flarum one.
|
||||
- stubs/Tobyz/JsonApiServer/JsonApi.stub
|
||||
|
||||
services:
|
||||
-
|
||||
class: Flarum\PHPStan\Relations\ModelRelationsExtension
|
||||
|
@@ -12,6 +12,7 @@ parameters:
|
||||
bootstrapFiles:
|
||||
- bootstrap.php
|
||||
checkOctaneCompatibility: false
|
||||
noEnvCallsOutsideOfConfig: false
|
||||
noModelMake: true
|
||||
noUnnecessaryCollectionCall: true
|
||||
noUnnecessaryCollectionCallOnly: []
|
||||
@@ -24,9 +25,11 @@ parameters:
|
||||
checkModelProperties: false
|
||||
checkPhpDocMissingReturn: false
|
||||
checkUnusedViews: false
|
||||
checkModelAppends: false
|
||||
|
||||
parametersSchema:
|
||||
checkOctaneCompatibility: bool()
|
||||
noEnvCallsOutsideOfConfig: bool()
|
||||
noModelMake: bool()
|
||||
noUnnecessaryCollectionCall: bool()
|
||||
noUnnecessaryCollectionCallOnly: listOf(string())
|
||||
@@ -38,8 +41,11 @@ parametersSchema:
|
||||
disableSchemaScan: bool()
|
||||
checkModelProperties: bool()
|
||||
checkUnusedViews: bool()
|
||||
checkModelAppends: bool()
|
||||
|
||||
conditionalTags:
|
||||
Larastan\Larastan\Rules\NoEnvCallsOutsideOfConfigRule:
|
||||
phpstan.rules.rule: %noEnvCallsOutsideOfConfig%
|
||||
Larastan\Larastan\Rules\NoModelMakeRule:
|
||||
phpstan.rules.rule: %noModelMake%
|
||||
Larastan\Larastan\Rules\NoUnnecessaryCollectionCallRule:
|
||||
@@ -52,6 +58,8 @@ conditionalTags:
|
||||
phpstan.rules.rule: %checkModelProperties%
|
||||
Larastan\Larastan\Rules\UnusedViewsRule:
|
||||
phpstan.rules.rule: %checkUnusedViews%
|
||||
Larastan\Larastan\Rules\ModelAppendsRule:
|
||||
phpstan.rules.rule: %checkModelAppends%
|
||||
|
||||
services:
|
||||
-
|
||||
@@ -163,6 +171,10 @@ services:
|
||||
class: Larastan\Larastan\Properties\ModelRelationsExtension
|
||||
tags:
|
||||
- phpstan.broker.propertiesClassReflectionExtension
|
||||
-
|
||||
class: Larastan\Larastan\ReturnTypes\ModelOnlyDynamicMethodReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\ReturnTypes\ModelFactoryDynamicStaticMethodReturnTypeExtension
|
||||
@@ -287,7 +299,7 @@ services:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\ReturnTypes\CollectionGenericStaticMethodDynamicMethodReturnTypeExtension
|
||||
class: Larastan\Larastan\ReturnTypes\EnumerableGenericStaticMethodDynamicMethodReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
@@ -302,7 +314,7 @@ services:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\ReturnTypes\CollectionGenericStaticMethodDynamicStaticMethodReturnTypeExtension
|
||||
class: Larastan\Larastan\ReturnTypes\EnumerableGenericStaticMethodDynamicStaticMethodReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
|
||||
|
||||
@@ -348,6 +360,11 @@ services:
|
||||
tags:
|
||||
- phpstan.broker.dynamicFunctionReturnTypeExtension
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\ReturnTypes\Helpers\StrExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicFunctionReturnTypeExtension
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\ReturnTypes\Helpers\TapExtension
|
||||
tags:
|
||||
@@ -371,6 +388,9 @@ services:
|
||||
-
|
||||
class: Larastan\Larastan\Rules\OctaneCompatibilityRule
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\Rules\NoEnvCallsOutsideOfConfigRule
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\Rules\NoModelMakeRule
|
||||
|
||||
@@ -383,6 +403,9 @@ services:
|
||||
-
|
||||
class: Larastan\Larastan\Rules\ModelProperties\ModelPropertyRule
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\Rules\ModelAppendsRule
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\Rules\ModelProperties\ModelPropertyStaticCallRule
|
||||
|
||||
@@ -413,6 +436,7 @@ services:
|
||||
databaseMigrationPath: %databaseMigrationsPath%
|
||||
disableMigrationScan: %disableMigrationScan%
|
||||
parser: @currentPhpVersionSimpleDirectParser
|
||||
reflectionProvider: @reflectionProvider
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\Properties\SquashedMigrationHelper
|
||||
@@ -423,6 +447,9 @@ services:
|
||||
-
|
||||
class: Larastan\Larastan\Properties\ModelCastHelper
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\Properties\ModelPropertyHelper
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\Rules\ModelProperties\ModelPropertiesRuleHelper
|
||||
|
||||
@@ -451,11 +478,14 @@ services:
|
||||
dispatchableClass: Illuminate\Foundation\Events\Dispatchable
|
||||
tags:
|
||||
- phpstan.rules.rule
|
||||
- Larastan\Larastan\Properties\Schema\PhpMyAdminDataTypeToPhpTypeConverter
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\Properties\Schema\PhpMyAdminDataTypeToPhpTypeConverter
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\LarastanStubFilesExtension
|
||||
tags: [phpstan.stubFilesExtension]
|
||||
tags:
|
||||
- phpstan.stubFilesExtension
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\Rules\UnusedViewsRule
|
||||
@@ -507,35 +537,48 @@ services:
|
||||
class: Larastan\Larastan\ReturnTypes\ConsoleCommand\ArgumentDynamicReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\ReturnTypes\ConsoleCommand\HasArgumentDynamicReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\ReturnTypes\ConsoleCommand\OptionDynamicReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\ReturnTypes\ConsoleCommand\HasOptionDynamicReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\ReturnTypes\TranslatorGetReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\ReturnTypes\TransHelperReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicFunctionReturnTypeExtension
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\ReturnTypes\DoubleUnderscoreHelperReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicFunctionReturnTypeExtension
|
||||
|
||||
- Larastan\Larastan\ReturnTypes\AppMakeHelper
|
||||
- Larastan\Larastan\Internal\ConsoleApplicationResolver
|
||||
- Larastan\Larastan\Internal\ConsoleApplicationHelper
|
||||
- Larastan\Larastan\Support\HigherOrderCollectionProxyHelper
|
||||
-
|
||||
class: Larastan\Larastan\ReturnTypes\AppMakeHelper
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\Internal\ConsoleApplicationResolver
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\Internal\ConsoleApplicationHelper
|
||||
|
||||
-
|
||||
class: Larastan\Larastan\Support\HigherOrderCollectionProxyHelper
|
||||
|
||||
rules:
|
||||
- Larastan\Larastan\Rules\UselessConstructs\NoUselessWithFunctionCallsRule
|
||||
|
@@ -30,3 +30,13 @@ parameters:
|
||||
# ignore this error, so we have to ignore it globally.
|
||||
- message: '#^Parameter \#[0-9]+ \$[A-z0-9_]+ of method Flarum\Extend\[A-z0-9_:\\()]+ expects \(?callable\([A-z0-9_,|\\: ()-]+\)\)?, (callable|Closure)\([A-z0-9_,|\\: ()-]+\) given\.$#'
|
||||
reportUnmatched: false
|
||||
|
||||
# PHPStan suddenly doesn't recognize callables can be function names?
|
||||
- message: '#^Parameter \#[0-9]+ \$[A-z0-9_]+ of function [A-z0-9_:\\()]+ expects \(?callable\([A-z0-9_,|\\: ()-]+, ''[A-z0-9_:\\()]+'' given\.$#'
|
||||
reportUnmatched: false
|
||||
|
||||
# Not if we're using our own static make method.
|
||||
- message: '#^Called ''Model\:\:make\(\)'' which performs unnecessary work, use ''new Model\(\)''\.$#'
|
||||
|
||||
# This assumes that the phpdoc telling it it's not nullable is correct, that's not the case for internal Laravel typings.
|
||||
- message: '#^Property [A-z0-9-_:$,\\]+ \([A-z]+\) on left side of \?\? is not nullable\.$#'
|
||||
|
11
php-packages/phpstan/stubs/Tobyz/JsonApiServer/JsonApi.stub
Normal file
11
php-packages/phpstan/stubs/Tobyz/JsonApiServer/JsonApi.stub
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Tobyz\JsonApiServer;
|
||||
|
||||
/**
|
||||
* @mixin \Flarum\Api\JsonApi
|
||||
*/
|
||||
class JsonApi
|
||||
{
|
||||
|
||||
}
|
@@ -213,6 +213,10 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
|
||||
'unique' => $instance->uniqueKeys ?? null,
|
||||
];
|
||||
} else {
|
||||
if (class_exists($tableOrModelClass) && is_subclass_of($tableOrModelClass, Model::class)) {
|
||||
$tableOrModelClass = (new $tableOrModelClass)->getTable();
|
||||
}
|
||||
|
||||
$databaseContent[$tableOrModelClass] = [
|
||||
'rows' => $_rows,
|
||||
'unique' => null,
|
||||
|
Reference in New Issue
Block a user