Page MenuHomePhorge

D1225.1775295976.diff
No OneTemporary

Authored By
Unknown
Size
24 KB
Referenced Files
None
Subscribers
None

D1225.1775295976.diff

diff --git a/src/app/Auth/SecondFactor.php b/src/app/Auth/SecondFactor.php
--- a/src/app/Auth/SecondFactor.php
+++ b/src/app/Auth/SecondFactor.php
@@ -119,11 +119,8 @@
*/
protected function verify($factor, $code): bool
{
- if ($driver = $this->getDriver($factor)) {
- return $driver->verify($code, time());
- }
-
- return false;
+ $driver = $this->getDriver($factor);
+ return $driver->verify($code, time());
}
/**
diff --git a/src/app/Handlers/Activesync.php b/src/app/Handlers/Activesync.php
--- a/src/app/Handlers/Activesync.php
+++ b/src/app/Handlers/Activesync.php
@@ -4,12 +4,12 @@
class Activesync extends \App\Handlers\Base
{
- public static function entitleableClass()
+ public static function entitleableClass(): string
{
return \App\User::class;
}
- public static function preReq($entitlement, $object)
+ public static function preReq($entitlement, $object): bool
{
if (!$entitlement->sku->active) {
\Log::error("Sku not active");
diff --git a/src/app/Handlers/Auth2F.php b/src/app/Handlers/Auth2F.php
--- a/src/app/Handlers/Auth2F.php
+++ b/src/app/Handlers/Auth2F.php
@@ -4,12 +4,12 @@
class Auth2F extends \App\Handlers\Base
{
- public static function entitleableClass()
+ public static function entitleableClass(): string
{
return \App\User::class;
}
- public static function preReq($entitlement, $object)
+ public static function preReq($entitlement, $object): bool
{
if (!$entitlement->sku->active) {
\Log::error("Sku not active");
diff --git a/src/app/Handlers/Base.php b/src/app/Handlers/Base.php
--- a/src/app/Handlers/Base.php
+++ b/src/app/Handlers/Base.php
@@ -7,11 +7,11 @@
/**
* The entitleable class for this handler.
*
- * @return mixed
+ * @return string
*/
- public static function entitleableClass()
+ public static function entitleableClass(): string
{
- //
+ return '';
}
/**
@@ -22,9 +22,9 @@
*
* @return bool
*/
- public static function preReq($entitlement, $object)
+ public static function preReq($entitlement, $object): bool
{
- //
+ return true;
}
/**
diff --git a/src/app/Handlers/Domain.php b/src/app/Handlers/Domain.php
--- a/src/app/Handlers/Domain.php
+++ b/src/app/Handlers/Domain.php
@@ -4,12 +4,12 @@
class Domain extends \App\Handlers\Base
{
- public static function entitleableClass()
+ public static function entitleableClass(): string
{
return \App\Domain::class;
}
- public static function preReq($entitlement, $domain)
+ public static function preReq($entitlement, $domain): bool
{
if (!$entitlement->sku->active) {
\Log::error("Sku not active");
diff --git a/src/app/Handlers/DomainHosting.php b/src/app/Handlers/DomainHosting.php
--- a/src/app/Handlers/DomainHosting.php
+++ b/src/app/Handlers/DomainHosting.php
@@ -4,12 +4,12 @@
class DomainHosting extends \App\Handlers\Base
{
- public static function entitleableClass()
+ public static function entitleableClass(): string
{
return \App\Domain::class;
}
- public static function preReq($entitlement, $domain)
+ public static function preReq($entitlement, $domain): bool
{
if (!$entitlement->sku->active) {
\Log::error("Sku not active");
diff --git a/src/app/Handlers/DomainRegistration.php b/src/app/Handlers/DomainRegistration.php
--- a/src/app/Handlers/DomainRegistration.php
+++ b/src/app/Handlers/DomainRegistration.php
@@ -4,12 +4,12 @@
class DomainRegistration extends \App\Handlers\Base
{
- public static function entitleableClass()
+ public static function entitleableClass(): string
{
return \App\Domain::class;
}
- public static function preReq($entitlement, $domain)
+ public static function preReq($entitlement, $domain): bool
{
if (!$entitlement->sku->active) {
\Log::error("Sku not active");
diff --git a/src/app/Handlers/DomainRelay.php b/src/app/Handlers/DomainRelay.php
--- a/src/app/Handlers/DomainRelay.php
+++ b/src/app/Handlers/DomainRelay.php
@@ -4,12 +4,12 @@
class DomainRelay extends \App\Handlers\Base
{
- public static function entitleableClass()
+ public static function entitleableClass(): string
{
return \App\Domain::class;
}
- public static function preReq($entitlement, $domain)
+ public static function preReq($entitlement, $domain): bool
{
if (!$entitlement->sku->active) {
\Log::error("Sku not active");
diff --git a/src/app/Handlers/Groupware.php b/src/app/Handlers/Groupware.php
--- a/src/app/Handlers/Groupware.php
+++ b/src/app/Handlers/Groupware.php
@@ -4,12 +4,12 @@
class Groupware extends \App\Handlers\Base
{
- public static function entitleableClass()
+ public static function entitleableClass(): string
{
return \App\User::class;
}
- public static function preReq($entitlement, $user)
+ public static function preReq($entitlement, $user): bool
{
if (!$entitlement->sku->active) {
\Log::error("Sku not active");
diff --git a/src/app/Handlers/Mailbox.php b/src/app/Handlers/Mailbox.php
--- a/src/app/Handlers/Mailbox.php
+++ b/src/app/Handlers/Mailbox.php
@@ -4,12 +4,12 @@
class Mailbox extends \App\Handlers\Base
{
- public static function entitleableClass()
+ public static function entitleableClass(): string
{
return \App\User::class;
}
- public static function preReq($entitlement, $user)
+ public static function preReq($entitlement, $user): bool
{
if (!$entitlement->sku->active) {
\Log::error("Sku not active");
diff --git a/src/app/Handlers/Resource.php b/src/app/Handlers/Resource.php
--- a/src/app/Handlers/Resource.php
+++ b/src/app/Handlers/Resource.php
@@ -4,12 +4,13 @@
class Resource extends \App\Handlers\Base
{
- public static function entitleableClass()
+ public static function entitleableClass(): string
{
// TODO
+ return '';
}
- public static function preReq($entitlement, $owner)
+ public static function preReq($entitlement, $owner): bool
{
if (!$entitlement->sku->active) {
\Log::error("Sku not active");
diff --git a/src/app/Handlers/SharedFolder.php b/src/app/Handlers/SharedFolder.php
--- a/src/app/Handlers/SharedFolder.php
+++ b/src/app/Handlers/SharedFolder.php
@@ -4,12 +4,13 @@
class SharedFolder extends \App\Handlers\Base
{
- public static function entitleableClass()
+ public static function entitleableClass(): string
{
// TODO
+ return '';
}
- public static function preReq($entitlement, $owner)
+ public static function preReq($entitlement, $owner): bool
{
if (!$entitlement->sku->active) {
\Log::error("Sku not active");
diff --git a/src/app/Handlers/Storage.php b/src/app/Handlers/Storage.php
--- a/src/app/Handlers/Storage.php
+++ b/src/app/Handlers/Storage.php
@@ -7,12 +7,12 @@
public const MAX_ITEMS = 100;
public const ITEM_UNIT = 'GB';
- public static function entitleableClass()
+ public static function entitleableClass(): string
{
return \App\User::class;
}
- public static function preReq($entitlement, $object)
+ public static function preReq($entitlement, $object): bool
{
if (!$entitlement->sku->active) {
\Log::error("Sku not active");
diff --git a/src/app/Http/Controllers/API/AuthController.php b/src/app/Http/Controllers/API/AuthController.php
--- a/src/app/Http/Controllers/API/AuthController.php
+++ b/src/app/Http/Controllers/API/AuthController.php
@@ -17,7 +17,7 @@
*/
public function info()
{
- $user = $this->guard()->user();
+ $user = Auth::guard()->user();
$response = V4\UsersController::userResponse($user);
return response()->json($response);
@@ -31,12 +31,13 @@
*/
public static function logonResponse(User $user)
{
- $token = auth()->login($user);
+ $token = Auth::guard()->login($user);
return response()->json([
'status' => 'success',
'access_token' => $token,
'token_type' => 'bearer',
+ // @phpstan-ignore-next-line
'expires_in' => Auth::guard()->factory()->getTTL() * 60,
]);
}
@@ -65,8 +66,8 @@
$credentials = $request->only('email', 'password');
- if ($token = $this->guard()->attempt($credentials)) {
- $sf = new \App\Auth\SecondFactor($this->guard()->user());
+ if ($token = Auth::guard()->attempt($credentials)) {
+ $sf = new \App\Auth\SecondFactor(Auth::guard()->user());
if ($response = $sf->requestHandler($request)) {
return $response;
@@ -85,7 +86,7 @@
*/
public function logout()
{
- $this->guard()->logout();
+ Auth::guard()->logout();
return response()->json([
'status' => 'success',
@@ -100,7 +101,7 @@
*/
public function refresh()
{
- return $this->respondWithToken($this->guard()->refresh());
+ return $this->respondWithToken(Auth::guard()->refresh());
}
/**
@@ -116,18 +117,9 @@
[
'access_token' => $token,
'token_type' => 'bearer',
- 'expires_in' => $this->guard()->factory()->getTTL() * 60
+ // @phpstan-ignore-next-line
+ 'expires_in' => Auth::guard()->factory()->getTTL() * 60
]
);
}
-
- /**
- * Get the guard to be used during authentication.
- *
- * @return \Illuminate\Contracts\Auth\Guard
- */
- public function guard()
- {
- return Auth::guard();
- }
}
diff --git a/src/app/Http/Controllers/API/SignupController.php b/src/app/Http/Controllers/API/SignupController.php
--- a/src/app/Http/Controllers/API/SignupController.php
+++ b/src/app/Http/Controllers/API/SignupController.php
@@ -23,10 +23,10 @@
*/
class SignupController extends Controller
{
- /** @var \App\SignupCode A verification code object */
+ /** @var ?\App\SignupCode A verification code object */
protected $code;
- /** @var \App\Plan Signup plan object */
+ /** @var ?\App\Plan Signup plan object */
protected $plan;
diff --git a/src/app/Http/Controllers/API/V4/DomainsController.php b/src/app/Http/Controllers/API/V4/DomainsController.php
--- a/src/app/Http/Controllers/API/V4/DomainsController.php
+++ b/src/app/Http/Controllers/API/V4/DomainsController.php
@@ -39,7 +39,7 @@
*/
public function create()
{
- //
+ return $this->errorResponse(404);
}
/**
@@ -81,7 +81,7 @@
*/
public function destroy($id)
{
- //
+ return $this->errorResponse(404);
}
/**
@@ -89,11 +89,11 @@
*
* @param int $id
*
- * @return \Illuminate\Http\Response
+ * @return \Illuminate\Http\JsonResponse
*/
public function edit($id)
{
- //
+ return $this->errorResponse(404);
}
/**
@@ -101,11 +101,11 @@
*
* @param \Illuminate\Http\Request $request
*
- * @return \Illuminate\Http\Response
+ * @return \Illuminate\Http\JsonResponse
*/
public function store(Request $request)
{
- //
+ return $this->errorResponse(404);
}
/**
@@ -199,11 +199,11 @@
* @param \Illuminate\Http\Request $request
* @param int $id
*
- * @return \Illuminate\Http\Response
+ * @return \Illuminate\Http\JsonResponse
*/
public function update(Request $request, $id)
{
- //
+ return $this->errorResponse(404);
}
/**
diff --git a/src/app/Http/Controllers/API/V4/UsersController.php b/src/app/Http/Controllers/API/V4/UsersController.php
--- a/src/app/Http/Controllers/API/V4/UsersController.php
+++ b/src/app/Http/Controllers/API/V4/UsersController.php
@@ -383,7 +383,7 @@
if ($skus[$sku_id] < 0) {
$ent->delete();
}
- } elseif ($all_skus[$sku_id]->handler_class != \App\Handlers\Mailbox::class) {
+ } elseif ($all_skus->get($sku_id)->handler_class != \App\Handlers\Mailbox::class) {
// An existing entitlement does not exists on the requested list
// Never delete 'mailbox' SKU
$ent->delete();
@@ -475,7 +475,7 @@
* @param \App\User|null $user User identifier
* @param array $settings User settings (from the request)
*
- * @return \Illuminate\Http\JsonResponse The response on error
+ * @return \Illuminate\Http\JsonResponse|null The error response on error
*/
protected function validateUserRequest(Request $request, $user, &$settings = [])
{
@@ -555,6 +555,8 @@
// Update user settings
$settings = $request->only(array_keys($rules));
unset($settings['password'], $settings['aliases'], $settings['email']);
+
+ return null;
}
/**
diff --git a/src/app/Http/Controllers/API/V4/WalletsController.php b/src/app/Http/Controllers/API/V4/WalletsController.php
--- a/src/app/Http/Controllers/API/V4/WalletsController.php
+++ b/src/app/Http/Controllers/API/V4/WalletsController.php
@@ -17,7 +17,7 @@
*/
public function index()
{
- //
+ return $this->errorResponse(404);
}
/**
@@ -27,7 +27,7 @@
*/
public function create()
{
- //
+ return $this->errorResponse(404);
}
/**
@@ -39,7 +39,7 @@
*/
public function store(Request $request)
{
- //
+ return $this->errorResponse(404);
}
/**
@@ -51,7 +51,7 @@
*/
public function show($id)
{
- //
+ return $this->errorResponse(404);
}
/**
@@ -63,7 +63,7 @@
*/
public function edit($id)
{
- //
+ return $this->errorResponse(404);
}
/**
@@ -76,7 +76,7 @@
*/
public function update(Request $request, $id)
{
- //
+ return $this->errorResponse(404);
}
/**
@@ -88,6 +88,6 @@
*/
public function destroy($id)
{
- //
+ return $this->errorResponse(404);
}
}
diff --git a/src/app/Http/Middleware/Authenticate.php b/src/app/Http/Middleware/Authenticate.php
--- a/src/app/Http/Middleware/Authenticate.php
+++ b/src/app/Http/Middleware/Authenticate.php
@@ -11,9 +11,9 @@
*
* @param \Illuminate\Http\Request $request
*
- * @return string
+ * @return string|null
*/
- protected function redirectTo($request)
+ protected function redirectTo($request): ?string
{
// We might want to redirect the user to the login route,
// however, I think we should not, as we're using API routes only.
@@ -22,5 +22,7 @@
// if (! $request->expectsJson()) {
// return route('login');
// }
+
+ return null;
}
}
diff --git a/src/app/Jobs/WalletPayment.php b/src/app/Jobs/WalletPayment.php
--- a/src/app/Jobs/WalletPayment.php
+++ b/src/app/Jobs/WalletPayment.php
@@ -44,7 +44,7 @@
*/
public function handle()
{
- if (!$this->wallet->balance < 0) {
+ if ($this->wallet->balance < 0) {
PaymentsController::directCharge($this->wallet, $this->wallet->balance * -1);
}
}
diff --git a/src/app/Observers/DiscountObserver.php b/src/app/Observers/DiscountObserver.php
--- a/src/app/Observers/DiscountObserver.php
+++ b/src/app/Observers/DiscountObserver.php
@@ -16,7 +16,7 @@
*
* @return void
*/
- public function creating(Discount $discount)
+ public function creating(Discount $discount): void
{
while (true) {
$allegedly_unique = \App\Utils::uuidStr();
diff --git a/src/app/Observers/DomainObserver.php b/src/app/Observers/DomainObserver.php
--- a/src/app/Observers/DomainObserver.php
+++ b/src/app/Observers/DomainObserver.php
@@ -14,7 +14,7 @@
*
* @return void
*/
- public function creating(Domain $domain)
+ public function creating(Domain $domain): void
{
while (true) {
$allegedly_unique = \App\Utils::uuidInt();
diff --git a/src/app/Observers/EntitlementObserver.php b/src/app/Observers/EntitlementObserver.php
--- a/src/app/Observers/EntitlementObserver.php
+++ b/src/app/Observers/EntitlementObserver.php
@@ -20,9 +20,9 @@
*
* @param Entitlement $entitlement The entitlement being created.
*
- * @return bool|null
+ * @return bool
*/
- public function creating(Entitlement $entitlement)
+ public function creating(Entitlement $entitlement): bool
{
while (true) {
$allegedly_unique = \App\Utils::uuidStr();
@@ -52,8 +52,17 @@
if (!$result) {
return false;
}
+
+ return true;
}
+ /**
+ * Handle the entitlement "created" event.
+ *
+ * @param \App\Entitlement $entitlement The entitlement.
+ *
+ * @return void
+ */
public function created(Entitlement $entitlement)
{
$entitlement->entitleable->updated_at = Carbon::now();
diff --git a/src/app/Observers/PackageSkuObserver.php b/src/app/Observers/PackageSkuObserver.php
--- a/src/app/Observers/PackageSkuObserver.php
+++ b/src/app/Observers/PackageSkuObserver.php
@@ -2,9 +2,18 @@
namespace App\Observers;
+use App\PackageSku;
+
class PackageSkuObserver
{
- public function created(\App\PackageSku $packageSku)
+ /**
+ * Handle the "created" event on an PackageSku relation
+ *
+ * @param \App\PackageSku $packageSku The package-sku relation
+ *
+ * @return void
+ */
+ public function created(PackageSku $packageSku)
{
// TODO: free units...
$package = $packageSku->package;
diff --git a/src/app/Observers/SkuObserver.php b/src/app/Observers/SkuObserver.php
--- a/src/app/Observers/SkuObserver.php
+++ b/src/app/Observers/SkuObserver.php
@@ -9,7 +9,7 @@
/**
* Ensure the SKU ID is a custom ID (uuid).
*
- * @param Sku $sku
+ * @param Sku $sku The SKU object
*
* @return void
*/
@@ -23,9 +23,4 @@
}
}
}
-
- public function created(Sku $sku)
- {
- \Log::info(var_export(get_class_methods($sku->handler_class), true));
- }
}
diff --git a/src/app/Observers/UserAliasObserver.php b/src/app/Observers/UserAliasObserver.php
--- a/src/app/Observers/UserAliasObserver.php
+++ b/src/app/Observers/UserAliasObserver.php
@@ -14,9 +14,9 @@
*
* @param \App\UserAlias $alias The user email alias
*
- * @return bool|null
+ * @return bool
*/
- public function creating(UserAlias $alias)
+ public function creating(UserAlias $alias): bool
{
$alias->alias = \strtolower($alias->alias);
@@ -24,6 +24,8 @@
\Log::error("Failed creating alias {$alias->alias}. User exists.");
return false;
}
+
+ return true;
}
/**
diff --git a/src/app/Observers/UserObserver.php b/src/app/Observers/UserObserver.php
--- a/src/app/Observers/UserObserver.php
+++ b/src/app/Observers/UserObserver.php
@@ -81,6 +81,13 @@
\App\Jobs\UserCreate::withChain($chain)->dispatch($user);
}
+ /**
+ * Handle the "deleted" event.
+ *
+ * @param \App\User $user The user deleted.
+ *
+ * @return void
+ */
public function deleted(User $user)
{
//
diff --git a/src/app/Observers/WalletObserver.php b/src/app/Observers/WalletObserver.php
--- a/src/app/Observers/WalletObserver.php
+++ b/src/app/Observers/WalletObserver.php
@@ -38,9 +38,9 @@
*
* @param Wallet $wallet The wallet being deleted.
*
- * @return boolean|null
+ * @return bool
*/
- public function deleting(Wallet $wallet)
+ public function deleting(Wallet $wallet): bool
{
// can't delete a wallet that has any balance on it (positive and negative).
if ($wallet->balance != 0.00) {
@@ -66,5 +66,7 @@
return false;
}
*/
+
+ return true;
}
}
diff --git a/src/app/PackageSku.php b/src/app/PackageSku.php
--- a/src/app/PackageSku.php
+++ b/src/app/PackageSku.php
@@ -6,6 +6,13 @@
/**
* Link SKUs to Packages.
+ *
+ * @property int $cost
+ * @property string $package_id
+ * @property \App\Package $package
+ * @property int $qty
+ * @property \App\Sku $sku
+ * @property string $sku_id
*/
class PackageSku extends Pivot
{
diff --git a/src/app/Payment.php b/src/app/Payment.php
--- a/src/app/Payment.php
+++ b/src/app/Payment.php
@@ -7,10 +7,11 @@
/**
* A payment operation on a wallet.
*
- * @property int $amount Amount of money in cents
- * @property string $description Payment description
- * @property string $id Mollie's Payment ID
- * @property int $wallet_id The ID of the wallet
+ * @property int $amount Amount of money in cents
+ * @property string $description Payment description
+ * @property string $id Mollie's Payment ID
+ * @property \App\Wallet $wallet The wallet
+ * @property string $wallet_id The ID of the wallet
*/
class Payment extends Model
{
diff --git a/src/app/PlanPackage.php b/src/app/PlanPackage.php
--- a/src/app/PlanPackage.php
+++ b/src/app/PlanPackage.php
@@ -7,7 +7,13 @@
/**
* Link Packages to Plans.
*
- * @property integer $qty_min
+ * @property int $discount_qty
+ * @property int $discount_rate
+ * @property string $plan_id
+ * @property string $package_id
+ * @property int $qty
+ * @property int $qty_max
+ * @property int $qty_min
* @property \App\Package $package
*/
class PlanPackage extends Pivot
diff --git a/src/app/SignupCode.php b/src/app/SignupCode.php
--- a/src/app/SignupCode.php
+++ b/src/app/SignupCode.php
@@ -8,7 +8,10 @@
/**
* The eloquent definition of a SignupCode.
*
- * @property datetime $expires_at
+ * @property string $code
+ * @property array $data
+ * @property \Carbon\Carbon $expires_at
+ * @property string $short_code
*/
class SignupCode extends Model
{
@@ -77,6 +80,7 @@
*/
public function isExpired()
{
+ // @phpstan-ignore-next-line
return $this->expires_at ? Carbon::now()->gte($this->expires_at) : false;
}
diff --git a/src/app/VerificationCode.php b/src/app/VerificationCode.php
--- a/src/app/VerificationCode.php
+++ b/src/app/VerificationCode.php
@@ -8,6 +8,9 @@
/**
* The eloquent definition of a VerificationCode
+ *
+ * @property string $mode
+ * @property \App\User $user
*/
class VerificationCode extends SignupCode
{
diff --git a/src/composer.json b/src/composer.json
--- a/src/composer.json
+++ b/src/composer.json
@@ -39,9 +39,8 @@
"fzaninotto/faker": "^1.4",
"laravel/dusk": "~5.11.0",
"mockery/mockery": "^1.0",
- "nunomaduro/collision": "^3.0",
- "nunomaduro/larastan": "^0.4",
- "phpstan/phpstan": "0.11.19",
+ "nunomaduro/larastan": "^0.5",
+ "phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^8"
},
"config": {
diff --git a/src/phpstan.neon b/src/phpstan.neon
--- a/src/phpstan.neon
+++ b/src/phpstan.neon
@@ -5,8 +5,9 @@
- tests/Browser
inferPrivatePropertyTypeFromConstructor: true
ignoreErrors:
- - '#Call to an undefined method Illuminate\\Contracts\\Auth\\Guard::factory#'
- level: 3
+ - '#Access to an undefined property Illuminate\\Contracts\\Auth\\Authenticatable#'
+ - '#Access to an undefined property App\\Package::\$pivot#'
+ level: 4
paths:
- app/
- tests/
diff --git a/src/tests/Unit/Mail/PasswordResetTest.php b/src/tests/Unit/Mail/PasswordResetTest.php
--- a/src/tests/Unit/Mail/PasswordResetTest.php
+++ b/src/tests/Unit/Mail/PasswordResetTest.php
@@ -22,6 +22,8 @@
'code' => 'code',
'short_code' => 'short-code',
]);
+
+ // @phpstan-ignore-next-line
$code->user = new User([
'name' => 'User Name',
]);

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 4, 9:46 AM (10 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18827536
Default Alt Text
D1225.1775295976.diff (24 KB)

Event Timeline