Skip to content

Commit

Permalink
chore: enable phpstan, apply fixes (#4)
Browse files Browse the repository at this point in the history
* chore: enable phpstan

* fix: phpstan errors

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
imorland and StyleCIBot authored Nov 14, 2023
1 parent 0e78111 commit 946527c
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 44 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: HTML Head Items PHP

on: [workflow_dispatch, push, pull_request]

jobs:
run:
uses: flarum/framework/.github/workflows/REUSABLE_backend.yml@main
with:
enable_backend_testing: false
enable_phpstan: true

backend_directory: .
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: HTML-Head JS
name: HTML Head Items JS

on: [workflow_dispatch, push, pull_request]

Expand All @@ -8,11 +8,12 @@ jobs:
with:
enable_bundlewatch: false
enable_prettier: true
enable_typescript: false
enable_typescript: true

frontend_directory: ./js
backend_directory: .
js_package_manager: npm
main_git_branch: master

secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
95 changes: 57 additions & 38 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,61 @@
{
"name": "ianm/html-head",
"description": "Add custom items to the HTML <head> attributes",
"keywords": [
"flarum", "headers", "html", "head", "custom"
],
"type": "flarum-extension",
"license": "MIT",
"support": {
"issues": "https://github.com/imorland/html-head/issues",
"source": "https://github.com/imorland/html-head",
"forum": "https://discuss.flarum.org/d/25907"
},
"require": {
"flarum/core": "^1.2.0"
},
"authors": [
{
"name": "IanM",
"homepage": "https://discuss.flarum.org/u/ianm"
}
],
"autoload": {
"psr-4": {
"IanM\\HtmlHead\\": "src/"
}
},
"extra": {
"flarum-extension": {
"title": "HTML Head Items",
"category": "feature",
"icon": {
"name": "fas fa-heading",
"backgroundColor": "#0072e3",
"color": "#fff"
}
"name": "ianm/html-head",
"description": "Add custom items to the HTML <head> attributes",
"keywords": [
"flarum",
"headers",
"html",
"head",
"custom"
],
"type": "flarum-extension",
"license": "MIT",
"support": {
"issues": "https://github.com/imorland/html-head/issues",
"source": "https://github.com/imorland/html-head",
"forum": "https://discuss.flarum.org/d/25907"
},
"require": {
"flarum/core": "^1.2.0"
},
"authors": [
{
"name": "IanM",
"homepage": "https://discuss.flarum.org/u/ianm"
}
],
"autoload": {
"psr-4": {
"IanM\\HtmlHead\\": "src/"
}
},
"extra": {
"flarum-extension": {
"title": "HTML Head Items",
"category": "feature",
"icon": {
"name": "fas fa-heading",
"backgroundColor": "#0072e3",
"color": "#fff"
}
},
"flagrow": {
"discuss": "https://discuss.flarum.org/d/25907"
},
"flarum-cli": {
"modules": {
"githubActions": true
}
}
},
"require-dev": {
"flarum/phpstan": "*"
},
"scripts": {
"analyse:phpstan": "phpstan analyse",
"clear-cache:phpstan": "phpstan clear-result-cache"
},
"flagrow": {
"discuss": "https://discuss.flarum.org/d/25907"
"scripts-descriptions": {
"analyse:phpstan": "Run static analysis"
}
}
}
13 changes: 13 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
includes:
- vendor/flarum/phpstan/extension.neon

parameters:
# The level will be increased in Flarum 2.0
level: 5
paths:
- extend.php
- src
excludePaths:
- *.blade.php
checkMissingIterableValueType: false
databaseMigrationsPath: ['migrations']
2 changes: 1 addition & 1 deletion src/Api/Serializers/HeaderSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class HeaderSerializer extends AbstractSerializer
protected $type = 'html-headers';

/**
* {@inheritdoc}
* @param \IanM\HtmlHead\Header $header
*/
protected function getDefaultAttributes($header)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Command/DeleteHeaderItemHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public function __construct(Dispatcher $events)
}

/**
* @param DeleteHeader $command
* @param DeleteHeaderItem $command
*
* @return mixed
* @return Header
*/
public function handle(DeleteHeaderItem $command)
public function handle(DeleteHeaderItem $command): Header
{
$command->actor->assertAdmin();

Expand Down
6 changes: 6 additions & 0 deletions src/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

use Flarum\Database\AbstractModel;

/**
* @property int $id
* @property string|null $description
* @property string|null $header
* @property bool $active
*/
class Header extends AbstractModel
{
public const CACHE_KEY = 'active_html_headers';
Expand Down

0 comments on commit 946527c

Please sign in to comment.