]> BookStack Code Mirror - bookstack/commitdiff
Added and ran PHPCS
authorDan Brown <redacted>
Sun, 18 Sep 2022 00:25:20 +0000 (01:25 +0100)
committerDan Brown <redacted>
Sun, 18 Sep 2022 00:25:20 +0000 (01:25 +0100)
22 files changed:
app/Actions/Webhook.php
app/Actions/WebhookTrackedEvent.php
app/Auth/Access/LdapService.php
app/Auth/Access/Oidc/OidcService.php
app/Config/dompdf.php
app/Config/snappy.php
app/Entities/Tools/PageEditActivity.php
app/Http/Controllers/Auth/ForgotPasswordController.php
app/Http/Controllers/Auth/LoginController.php
app/Http/Controllers/Auth/RegisterController.php
app/Http/Controllers/Auth/ResetPasswordController.php
app/Http/Controllers/BookController.php
app/Http/Controllers/BookSortController.php
app/Http/Controllers/PageRevisionController.php
app/Uploads/ImageService.php
composer.json
composer.lock
phpcs.xml [new file with mode: 0644]
routes/api.php
tests/Actions/AuditLogTest.php
tests/Uploads/AttachmentTest.php
tests/UrlTest.php

index 72a67ad9201f14ab38a359f0efe98d950fb19add..3ed5bb56f54b550650b0abf8e05159be85281419 100644 (file)
@@ -22,10 +22,10 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
  */
 class Webhook extends Model implements Loggable
 {
-    protected $fillable = ['name', 'endpoint', 'timeout'];
-
     use HasFactory;
 
+    protected $fillable = ['name', 'endpoint', 'timeout'];
+
     protected $casts = [
         'last_called_at'  => 'datetime',
         'last_errored_at' => 'datetime',
index 6289581a21a53bf2a3f8a43eadb6bd40a177c7c3..28b3a366d69b08e0b4c7ef81c83178d4bb1a881f 100644 (file)
@@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model;
  */
 class WebhookTrackedEvent extends Model
 {
-    protected $fillable = ['event'];
-
     use HasFactory;
+
+    protected $fillable = ['event'];
 }
index 2540fe2d821386e591a668f3b460836678d0f1fa..359eeca2f5e863ab229c102a15880cce00580823 100644 (file)
@@ -105,7 +105,7 @@ class LdapService
             'name'  => $this->getUserResponseProperty($user, $displayNameAttr, $userCn),
             'dn'    => $user['dn'],
             'email' => $this->getUserResponseProperty($user, $emailAttr, null),
-            'avatar'=> $thumbnailAttr ? $this->getUserResponseProperty($user, $thumbnailAttr, null) : null,
+            'avatar' => $thumbnailAttr ? $this->getUserResponseProperty($user, $thumbnailAttr, null) : null,
         ];
 
         if ($this->config['dump_user_details']) {
index 4f5a3e1acb6f267d2dc9aa5de36d08ed0cf1b187..c9c3cc51180277c754625eb0617b9663e23176d2 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace BookStack\Auth\Access\Oidc;
 
-use function auth;
 use BookStack\Auth\Access\GroupSyncService;
 use BookStack\Auth\Access\LoginService;
 use BookStack\Auth\Access\RegistrationService;
@@ -10,14 +9,11 @@ use BookStack\Auth\User;
 use BookStack\Exceptions\JsonDebugException;
 use BookStack\Exceptions\StoppedAuthenticationException;
 use BookStack\Exceptions\UserRegistrationException;
-use function config;
 use Illuminate\Support\Arr;
 use Illuminate\Support\Facades\Cache;
 use League\OAuth2\Client\OptionProvider\HttpBasicAuthOptionProvider;
 use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
 use Psr\Http\Client\ClientInterface as HttpClient;
-use function trans;
-use function url;
 
 /**
  * Class OpenIdConnectService
index 16a527b3cc9b77467de1c467560667f3dcbc04fe..09dd91bcc3ca762b3a340cefb579eaa8faa6c4a2 100644 (file)
@@ -7,6 +7,7 @@
  * Configuration should be altered via the `.env` file or environment variables.
  * Do not edit this file unless you're happy to maintain any changes yourself.
  */
+
 $dompdfPaperSizeMap = [
     'a4'     => 'a4',
     'letter' => 'letter',
index 8ab10a39c432baa0e6d880136a3584f4e168a021..a87ce805f929d5bf30cbc07ea96949c00cf6953a 100644 (file)
@@ -7,6 +7,7 @@
  * Configuration should be altered via the `.env` file or environment variables.
  * Do not edit this file unless you're happy to maintain any changes yourself.
  */
+
 $snappyPaperSizeMap = [
     'a4'     => 'A4',
     'letter' => 'Letter',
index 2672de94145d7c57a1543eb4271602ed7fb80972..646b200f1da2ed17a3e5fb803458dabd2330a27e 100644 (file)
@@ -42,7 +42,7 @@ class PageEditActivity
             $userMessage = trans('entities.pages_draft_edit_active.start_b', ['userName' => $firstDraft->createdBy->name ?? '']);
         }
 
-        $timeMessage = trans('entities.pages_draft_edit_active.time_b', ['minCount'=> 60]);
+        $timeMessage = trans('entities.pages_draft_edit_active.time_b', ['minCount' => 60]);
 
         return trans('entities.pages_draft_edit_active.message', ['start' => $userMessage, 'time' => $timeMessage]);
     }
index 5e73b232ca734f6a4a5126d1b059a067ee314569..b345fad1c1f6570bdc4c1db58435dd13881d6873 100644 (file)
@@ -20,7 +20,6 @@ class ForgotPasswordController extends Controller
     | your application to your users. Feel free to explore this trait.
     |
     */
-
     use SendsPasswordResetEmails;
 
     /**
index f1a1a8bd6930bbc2cbf5f6b1e0f268d9dfefcaa5..1d6a36c5bbb072097414224caaa717c162bc451c 100644 (file)
@@ -24,8 +24,9 @@ class LoginController extends Controller
     | to conveniently provide its functionality to your applications.
     |
     */
-
-    use AuthenticatesUsers { logout as traitLogout; }
+    use AuthenticatesUsers {
+        logout as traitLogout;
+    }
 
     /**
      * Redirection paths.
@@ -112,8 +113,10 @@ class LoginController extends Controller
         // If the class is using the ThrottlesLogins trait, we can automatically throttle
         // the login attempts for this application. We'll key this by the username and
         // the IP address of the client making these requests into this application.
-        if (method_exists($this, 'hasTooManyLoginAttempts') &&
-            $this->hasTooManyLoginAttempts($request)) {
+        if (
+            method_exists($this, 'hasTooManyLoginAttempts') &&
+            $this->hasTooManyLoginAttempts($request)
+        ) {
             $this->fireLockoutEvent($request);
 
             Activity::logFailedLogin($username);
index b0aec117791bc1a64fec7ceb713a898099b0353b..15ee78d506d7a34f3e8fae12e047b2dabfaad639 100644 (file)
@@ -27,7 +27,6 @@ class RegisterController extends Controller
     | provide this functionality without requiring any additional code.
     |
     */
-
     use RegistersUsers;
 
     protected SocialAuthService $socialAuthService;
index a31529b119b502b2fbddc0d3779b147e628ba043..9df010736d01a8283e13adee10f793d8bdfcda17 100644 (file)
@@ -20,7 +20,6 @@ class ResetPasswordController extends Controller
     | explore this trait and override any methods you wish to tweak.
     |
     */
-
     use ResetsPasswords;
 
     protected $redirectTo = '/';
index a041267bbdf87df17e4711a903200db2001ccb81..cc2f6f534b9f86264564601e896087a0e18e23e6 100644 (file)
@@ -147,7 +147,7 @@ class BookController extends Controller
     {
         $book = $this->bookRepo->getBySlug($slug);
         $this->checkOwnablePermission('book-update', $book);
-        $this->setPageTitle(trans('entities.books_edit_named', ['bookName'=>$book->getShortName()]));
+        $this->setPageTitle(trans('entities.books_edit_named', ['bookName' => $book->getShortName()]));
 
         return view('books.edit', ['book' => $book, 'current' => $book]);
     }
index 8aac2b76934cd9ca85c0e7b46cb5f5feac049e36..5d0577a74a0a67b04fb641c3002be4ee72932e2a 100644 (file)
@@ -28,7 +28,7 @@ class BookSortController extends Controller
 
         $bookChildren = (new BookContents($book))->getTree(false);
 
-        $this->setPageTitle(trans('entities.books_sort_named', ['bookName'=>$book->getShortName()]));
+        $this->setPageTitle(trans('entities.books_sort_named', ['bookName' => $book->getShortName()]));
 
         return view('books.sort', ['book' => $book, 'current' => $book, 'bookChildren' => $bookChildren]);
     }
index c4d5fbc7b37fc59ab6e946e37acb60e51bfb169c..89775a60213e0a4e8931be951061f89e6f1a7331 100644 (file)
@@ -91,7 +91,7 @@ class PageRevisionController extends Controller
         // TODO - Refactor PageContent so we don't need to juggle this
         $page->html = $revision->html;
         $page->html = (new PageContent($page))->render();
-        $this->setPageTitle(trans('entities.pages_revision_named', ['pageName'=>$page->getShortName()]));
+        $this->setPageTitle(trans('entities.pages_revision_named', ['pageName' => $page->getShortName()]));
 
         return view('pages.revision', [
             'page'     => $page,
index 7b8af3b84846e7d8abaf625c6f29fd0ccbbd5f65..0199c207ea18927a93d17ed5be5ff75a5f73e7a3 100644 (file)
@@ -315,7 +315,7 @@ class ImageService
     {
         try {
             $thumb = $this->imageTool->make($imageData);
-        } catch (ErrorException|NotSupportedException $e) {
+        } catch (ErrorException | NotSupportedException $e) {
             throw new ImageUploadException(trans('errors.cannot_create_thumbs'));
         }
 
index 6d4bb734d5f4f73828398468ea17d55a1b2609d9..615723be9c9fbe2e09486e53c6b878a3a427143c 100644 (file)
@@ -50,6 +50,7 @@
         "nunomaduro/collision": "^5.10",
         "nunomaduro/larastan": "^1.0",
         "phpunit/phpunit": "^9.5",
+        "squizlabs/php_codesniffer": "^3.7",
         "ssddanbrown/asserthtml": "^1.0"
     },
     "autoload": {
index 6f9ed25ccc3b09c0e1780511bf5df0b7600db6a7..b807fd57785f17961db47a7736de84e5a9fc96a1 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "4ab21f732b2380ed1c3dd1a4eca2ef1a",
+    "content-hash": "1d3bd88b99d07b5410ee4b245bece28e",
     "packages": [
         {
             "name": "aws/aws-crt-php",
             },
             "time": "2022-07-20T18:31:45+00:00"
         },
+        {
+            "name": "squizlabs/php_codesniffer",
+            "version": "3.7.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
+                "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619",
+                "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619",
+                "shasum": ""
+            },
+            "require": {
+                "ext-simplexml": "*",
+                "ext-tokenizer": "*",
+                "ext-xmlwriter": "*",
+                "php": ">=5.4.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
+            },
+            "bin": [
+                "bin/phpcs",
+                "bin/phpcbf"
+            ],
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "3.x-dev"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Greg Sherwood",
+                    "role": "lead"
+                }
+            ],
+            "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
+            "homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
+            "keywords": [
+                "phpcs",
+                "standards"
+            ],
+            "support": {
+                "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
+                "source": "https://github.com/squizlabs/PHP_CodeSniffer",
+                "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
+            },
+            "time": "2022-06-18T07:21:10+00:00"
+        },
         {
             "name": "ssddanbrown/asserthtml",
             "version": "v1.0.1",
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644 (file)
index 0000000..8d4c6b7
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd">
+    <description>The coding standard for BookStack</description>
+
+    <file>app</file>
+    <file>bootstrap/app.php</file>
+    <file>database</file>
+    <file>public/index.php</file>
+    <file>routes</file>
+    <file>tests</file>
+
+    <arg name="basepath" value="."/>
+    <arg name="colors"/>
+    <arg name="parallel" value="75"/>
+    <arg value="np"/>
+
+    <rule  ref="PSR12"/>
+
+    <rule ref="PSR1.Methods.CamelCapsMethodName">
+        <exclude-pattern>./tests/*</exclude-pattern>
+    </rule>
+
+    <rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
+        <exclude-pattern>./tests/*</exclude-pattern>
+    </rule>
+
+    <rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
+        <exclude-pattern>./database/*</exclude-pattern>
+    </rule>
+
+    <rule ref="PSR12.Files.FileHeader.IncorrectOrder">
+        <exclude-pattern>./app/Config/*</exclude-pattern>
+    </rule>
+
+</ruleset>
index 20e167d70934c0d35104014986780a4c2160a510..d350fd86b1fe23b99ec22bf95b4c2b66d38e101d 100644 (file)
@@ -1,5 +1,11 @@
 <?php
 
+/**
+ * Routes for the BookStack API.
+ * Routes have a uri prefix of /api/.
+ * Controllers are all within app/Http/Controllers/Api.
+ */
+
 use BookStack\Http\Controllers\Api\ApiDocsController;
 use BookStack\Http\Controllers\Api\AttachmentApiController;
 use BookStack\Http\Controllers\Api\BookApiController;
@@ -14,11 +20,6 @@ use BookStack\Http\Controllers\Api\SearchApiController;
 use BookStack\Http\Controllers\Api\UserApiController;
 use Illuminate\Support\Facades\Route;
 
-/**
- * Routes for the BookStack API.
- * Routes have a uri prefix of /api/.
- * Controllers are all within app/Http/Controllers/Api.
- */
 Route::get('docs.json', [ApiDocsController::class, 'json']);
 
 Route::get('attachments', [AttachmentApiController::class, 'list']);
index d699724f5129d1936e5f39f88fb1ff4f648eab17..8fbf66e760f925f09598d5e19683d2b3aff312ec 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace Tests\Actions;
 
-use function app;
 use BookStack\Actions\Activity;
 use BookStack\Actions\ActivityLogger;
 use BookStack\Actions\ActivityType;
@@ -12,7 +11,6 @@ use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\PageRepo;
 use BookStack\Entities\Tools\TrashCan;
 use Carbon\Carbon;
-use function config;
 use Tests\TestCase;
 
 class AuditLogTest extends TestCase
index e71adf70b59ca984288babd45ba7e6809f92d452..7280510f3e5bd9885d0cd6466b99dc7122cb0047 100644 (file)
@@ -80,7 +80,7 @@ class AttachmentTest extends TestCase
 
         $expectedResp = [
             'name'       => $fileName,
-            'uploaded_to'=> $page->id,
+            'uploaded_to' => $page->id,
             'extension'  => 'txt',
             'order'      => 1,
             'created_by' => $admin->id,
index 13f9d9e0c95fb97a3c690daf9115b89f36fa1374..dd278c2404e1562035dff16875e2dc5c86cfd8f9 100644 (file)
@@ -3,6 +3,7 @@
 namespace Tests;
 
 use BookStack\Http\Request;
+
 use function request;
 use function url;
 
Morty Proxy This is a proxified and sanitized view of the page, visit original site.