Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
* text=auto eol=lf

*.php text eol=lf
*.json text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.md text eol=lf
*.sh text eol=lf
*.js text eol=lf
*.css text eol=lf

# Export ignore - exclude development and test files
tests/ export-ignore
.git/ export-ignore
.github/ export-ignore
.idea/ export-ignore
nbproject/ export-ignore
vendor/ export-ignore
.php-cs-fixer.cache export-ignore
.php-cs-fixer.php export-ignore
.phpunit.result.cache export-ignore
coverage.xml export-ignore
phpstan.neon.dist export-ignore
phpunit.xml export-ignore
rector.php export-ignore
composer.lock export-ignore
3 changes: 3 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
- name: Run PHP-CS-Fixer
run: composer cs:check

- name: Run PHPStan
run: composer phpstan

- name: Create env
run: php qt core:env

Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"phpunit/phpunit": "^9.0",
"mockery/mockery": "^1.2",
"friendsofphp/php-cs-fixer": "^3.94",
"rector/rector": "^2.3"
"rector/rector": "^2.3",
"phpstan/phpstan": "^2.1"
},
"autoload": {
"psr-4": {
Expand All @@ -42,6 +43,7 @@
"cs:fix": "vendor/bin/php-cs-fixer fix",
"rector:check": "vendor/bin/rector process --dry-run",
"rector:fix": "vendor/bin/rector process",
"phpstan": "vendor/bin/phpstan analyse --memory-limit=-1 --error-format=github",
"test": "vendor/bin/phpunit --stderr --coverage-clover coverage.xml"
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion helpers/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function url_with_lang(string $lang): string
return base_url(true) . '/' . $lang;
}

if (preg_match('/' . preg_quote(current_lang()) . '/', route_uri())) {
if (preg_match('/' . preg_quote(current_lang(), '/') . '/', route_uri())) {
return base_url() . preg_replace('/' . preg_quote(current_lang(), '/') . '/', $lang, route_uri(), 1);
}

Expand Down
21 changes: 21 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
parameters:
phpVersion: 70400
level: 5
paths:
- shared
- helpers
- hooks
- libraries
- migrations
- public/index.php
excludePaths:
- modules (?)
- shared/config
- shared/views
scanDirectories:
- vendor/quantum/framework/src
ignoreErrors:
- identifier: property.notFound
path: shared/Services/PostService.php
- identifier: method.notFound
path: shared/Commands/DemoCommand.php
24 changes: 12 additions & 12 deletions public/assets/shared/css/materialize.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion shared/Commands/CommentCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CommentCreateCommand extends QtCommand

/**
* Command arguments
* @var array[]
* @var array<int, array<int|string, mixed>>
*/
protected array $args = [
['post_uuid', 'required', 'The post uuid the comment belongs to'],
Expand Down
4 changes: 2 additions & 2 deletions shared/Commands/CommentDeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ class CommentDeleteCommand extends QtCommand

/**
* Command arguments
* @var array[]
* @var array<int, array<int|string, mixed>>
*/
protected array $args = [
['uuid', 'optional', 'Comment uuid'],
];

/**
* Command options
* @var array[]
* @var array<int, array<int|string, mixed>>
*/
protected array $options = [
['yes', 'y', 'none', 'Skip confirmation and delete all comments'],
Expand Down
2 changes: 1 addition & 1 deletion shared/Commands/DemoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class DemoCommand extends QtCommand

/**
* The default action for all confirmations
* @var array
* @var array<int, array<int|string, mixed>>
*/
protected array $options = [
['yes', 'y', 'none', 'Acceptance of the confirmations'],
Expand Down
2 changes: 1 addition & 1 deletion shared/Commands/PostCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PostCreateCommand extends QtCommand

/**
* Command arguments
* @var array[]
* @var array<int, array<int|string, mixed>>
*/
protected array $args = [
['title', 'required', 'Post title'],
Expand Down
4 changes: 2 additions & 2 deletions shared/Commands/PostDeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ class PostDeleteCommand extends QtCommand

/**
* Command arguments
* @var array[]
* @var array<int, array<int|string, mixed>>
*/
protected array $args = [
['uuid', 'optional', 'Post uuid'],
];

/**
* Command options
* @var array[]
* @var array<int, array<int|string, mixed>>
*/
protected array $options = [
['yes', 'y', 'none', 'Skip confirmation and delete all posts'],
Expand Down
2 changes: 1 addition & 1 deletion shared/Commands/PostShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class PostShowCommand extends QtCommand

/**
* Command arguments
* @var array
* @var array<int, array<int|string, mixed>>
*/
protected array $args = [
['uuid', 'optional', 'Post uuid'],
Expand Down
4 changes: 2 additions & 2 deletions shared/Commands/PostUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ class PostUpdateCommand extends QtCommand

/**
* Command arguments
* @var array
* @var array<int, array<int|string, mixed>>
*/
protected array $args = [
['uuid', 'required', 'Post uuid'],
];

/**
* Command options
* @var array
* @var array<int, array<int|string, mixed>>
*/
protected array $options = [
['title', 't', 'optional', 'Post title'],
Expand Down
2 changes: 1 addition & 1 deletion shared/Commands/UserCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class UserCreateCommand extends QtCommand

/**
* Command arguments
* @var array[]
* @var array<int, array<int|string, mixed>>
*/
protected array $args = [
['email', 'required', 'User email'],
Expand Down
5 changes: 2 additions & 3 deletions shared/Commands/UserDeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,15 @@ class UserDeleteCommand extends QtCommand
HELP;
/**
* Command arguments
* @var array[]
* @var array<int, array<int|string, mixed>>
*/

protected array $args = [
['uuid', 'optional', 'User uuid'],
];

/**
* Command options
* @var array[]
* @var array<int, array<int|string, mixed>>
*/
protected array $options = [
['yes', 'y', 'none', 'Skip confirmation and delete all users'],
Expand Down
2 changes: 1 addition & 1 deletion shared/Commands/UserShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class UserShowCommand extends QtCommand

/**
* Command arguments
* @var array
* @var array<int, array<int|string, mixed>>
*/
protected array $args = [
['uuid', 'optional', 'User uuid'],
Expand Down
2 changes: 1 addition & 1 deletion shared/Models/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Comment extends DbModel

/**
* Fillable properties
* @var array
* @var array<string>
*/
public array $fillable = [
'uuid',
Expand Down
9 changes: 8 additions & 1 deletion shared/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
/**
* Class Post
* @package Shared\Models
*
* @property string $uuid
* @property string $title
* @property string $content
* @property string|null $image
* @property string|null $user_directory
* @property string|null $updated_at
*/
class Post extends DbModel
{
Expand All @@ -44,7 +51,7 @@ class Post extends DbModel

/**
* Fillable properties
* @var array
* @var array<string>
*/
public array $fillable = [
'uuid',
Expand Down
2 changes: 1 addition & 1 deletion shared/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class User extends DbModel

/**
* Fillable properties
* @var array
* @var array<string>
*/
public array $fillable = [
'uuid',
Expand Down
4 changes: 3 additions & 1 deletion shared/Services/AuthService.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public function getAll(): ModelCollection
*/
public function getUserByUuid(string $uuid): User
{
return$this->model->findOneBy('uuid', $uuid);
/** @var User $user */
$user = $this->model->findOneBy('uuid', $uuid);
return $user;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions shared/Services/CommentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(CommentTransformer $transformer)
/**
* Get comments by post
* @param string $postUuid
* @return mixed
* @return ModelCollection
* @throws BaseException
* @throws ModelException
*/
Expand Down Expand Up @@ -80,7 +80,9 @@ public function getCommentsByPost(string $postUuid): ModelCollection
*/
public function getComment(string $uuid): Comment
{
return $this->model->criteria('uuid', '=', $uuid)->first();
/** @var Comment $comment */
$comment = $this->model->criteria('uuid', '=', $uuid)->first();
return $comment;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion shared/Services/PostService.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public function getPosts(?int $perPage = null, ?int $currentPage = null, ?string
*/
public function getPost(string $uuid): Post
{
return $this->model
/** @var Post $post */
$post = $this->model
->joinTo(model(User::class))
->criteria('uuid', '=', $uuid)
->select(
Expand All @@ -125,6 +126,7 @@ public function getPost(string $uuid): Post
['users.uuid' => 'user_directory']
)
->first();
return $post;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions shared/Transformers/PostTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ class PostTransformer implements TransformerInterface
/**
* Transforms the post data
* @param $item
* @return mixed
* @return array
*/
public function transform($item): array
{
return [
'uuid' => $item->uuid,
'title' => $item->title,
'content' => markdown_to_html($item->content, true),
'image' => $item->image ? $item->user_directory . '/' . $item->image : null,
'image' => $item->image && $item->user_directory ? $item->user_directory . '/' . $item->image : null,
'date' => date('Y/m/d H:i', strtotime($item->updated_at)),
'author' => $item->firstname . ' ' . $item->lastname,
];
Expand Down
Loading