Skip to content

Commit

Permalink
Sync, blog, part 1 (#622)
Browse files Browse the repository at this point in the history
* Sync

* Apply fixes from StyleCI

* WIP

* WIP 2

* WIP 3

---------

Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
arogachev and StyleCIBot authored Sep 9, 2024
1 parent 6dbcb10 commit 96b9726
Show file tree
Hide file tree
Showing 26 changed files with 51 additions and 51 deletions.
24 changes: 12 additions & 12 deletions blog/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"yiisoft/di": "^1.2",
"yiisoft/error-handler": "^3.0",
"yiisoft/factory": "^1.0",
"yiisoft/form": "dev-master",
"yiisoft/form-model": "dev-master",
"yiisoft/form": "^1.0",
"yiisoft/form-model": "^1.0",
"yiisoft/html": "^3.0",
"yiisoft/http": "^1.2",
"yiisoft/injector": "^1.0",
Expand All @@ -74,24 +74,24 @@
"yiisoft/translator": "^3.0",
"yiisoft/translator-message-php": "^1.1.1",
"yiisoft/user": "^2.0",
"yiisoft/validator": "^1.0",
"yiisoft/validator": "^2.0",
"yiisoft/var-dumper": "^1.0",
"yiisoft/view": "^8.0",
"yiisoft/view": "^10.0",
"yiisoft/widget": "^2.1",
"yiisoft/yii-bootstrap5": "^3.0@dev",
"yiisoft/yii-console": "^2.0",
"yiisoft/yii-cycle": "^1.0",
"yiisoft/yii-dataview": "^3.0@dev",
"yiisoft/yii-debug": "^3.0@dev",
"yiisoft/yii-debug": "dev-master",
"yiisoft/yii-debug-api": "^3.0@dev",
"yiisoft/yii-event": "^2.0",
"yiisoft/yii-http": "^1.0",
"yiisoft/yii-middleware": "^1.0",
"yiisoft/yii-middleware": "^1.0.4",
"yiisoft/yii-runner-console": "^2.0",
"yiisoft/yii-runner-http": "^2.0",
"yiisoft/yii-sentry": "dev-master",
"yiisoft/yii-swagger": "^2.0",
"yiisoft/yii-view": "^6.0"
"yiisoft/yii-sentry": "^2.0.1",
"yiisoft/yii-swagger": "^2.1.1",
"yiisoft/yii-view-renderer": "^7.1"
},
"require-dev": {
"codeception/c3": "^2.6",
Expand All @@ -101,12 +101,12 @@
"codeception/module-phpbrowser": "^3.0",
"phpunit/phpunit": "^9.5",
"roave/infection-static-analysis-plugin": "^1.16",
"roave/security-advisories": "dev-master",
"roave/security-advisories": "dev-latest",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.18",
"yiisoft/translator-extractor": "^2.0",
"yiisoft/yii-debug-viewer": "^3.0@dev",
"yiisoft/yii-gii": "^3.0@dev",
"yiisoft/yii-debug-viewer": "dev-master",
"yiisoft/yii-gii": "dev-master",
"yiisoft/yii-testing": "dev-master"
},
"autoload": {
Expand Down
6 changes: 3 additions & 3 deletions blog/config/common/params.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\ViewInjection\MetaTagsViewInjection;
use Cycle\Database\Config\SQLite\FileConnectionConfig;
use Cycle\Database\Config\SQLiteDriverConfig;
use Cycle\Schema\Provider\PhpFileSchemaProvider;
use Yiisoft\Assets\AssetManager;
use Yiisoft\Definitions\Reference;
use Yiisoft\Form\Field\SubmitButton;
Expand All @@ -16,8 +17,7 @@
use Yiisoft\Translator\TranslatorInterface;
use Yiisoft\Yii\Cycle\Schema\Conveyor\AttributedSchemaConveyor;
use Yiisoft\Yii\Cycle\Schema\Provider\FromConveyorSchemaProvider;
use Cycle\Schema\Provider\PhpFileSchemaProvider;
use Yiisoft\Yii\View\CsrfViewInjection;
use Yiisoft\Yii\View\Renderer\CsrfViewInjection;

return [
'mailer' => [
Expand Down Expand Up @@ -92,7 +92,7 @@
'secretKey' => '53136271c432a1af377c3806c3112ddf',
],

'yiisoft/yii-view' => [
'yiisoft/yii-view-renderer' => [
'viewPath' => '@views',
'layout' => '@views/layout/main',
'injections' => [
Expand Down
4 changes: 3 additions & 1 deletion blog/resources/views/user/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
declare(strict_types=1);

/**
* @var User $item
* @var User $item
* @var WebView $this
* @var $translator TranslatorInterface
*/

use App\User\User;
use Yiisoft\Html\Html;
use Yiisoft\Html\Tag\H2;
use Yiisoft\Translator\TranslatorInterface;
use Yiisoft\View\WebView;
use Yiisoft\Yii\DataView\DetailView;
use Yiisoft\Yii\DataView\Field\DataField;
Expand Down
2 changes: 1 addition & 1 deletion blog/src/Auth/Controller/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Yiisoft\Translator\TranslatorInterface;
use Yiisoft\User\Login\Cookie\CookieLogin;
use Yiisoft\User\Login\Cookie\CookieLoginIdentityInterface;
use Yiisoft\Yii\View\ViewRenderer;
use Yiisoft\Yii\View\Renderer\ViewRenderer;

final class AuthController
{
Expand Down
2 changes: 1 addition & 1 deletion blog/src/Auth/Controller/SignupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Yiisoft\FormModel\FormHydrator;
use Yiisoft\Yii\View\ViewRenderer;
use Yiisoft\Yii\View\Renderer\ViewRenderer;

final class SignupController
{
Expand Down
2 changes: 1 addition & 1 deletion blog/src/Auth/Form/LoginForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(
) {
}

public function getAttributeLabels(): array
public function getPropertyLabels(): array
{
return [
'login' => $this->translator->translate('layout.login'),
Expand Down
2 changes: 1 addition & 1 deletion blog/src/Auth/Form/SignupForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
) {
}

public function getAttributeLabels(): array
public function getPropertyLabels(): array
{
return [
'login' => $this->translator->translate('layout.login'),
Expand Down
2 changes: 1 addition & 1 deletion blog/src/Backend/Controller/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace App\Backend\Controller;

use Psr\Http\Message\ResponseInterface;
use Yiisoft\Yii\View\ViewRenderer;
use Yiisoft\Yii\View\Renderer\ViewRenderer;

final class SiteController
{
Expand Down
2 changes: 1 addition & 1 deletion blog/src/Blog/Archive/ArchiveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Psr\Http\Message\ResponseInterface as Response;
use Yiisoft\Data\Paginator\OffsetPaginator;
use Yiisoft\Router\HydratorAttribute\RouteArgument;
use Yiisoft\Yii\View\ViewRenderer;
use Yiisoft\Yii\View\Renderer\ViewRenderer;

final class ArchiveController
{
Expand Down
4 changes: 2 additions & 2 deletions blog/src/Blog/Archive/ArchiveRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ private function extractFromDateColumn(string $attr): FragmentInterface
if ($driver instanceof SQLiteDriver) {
$str = ['year' => '%Y', 'month' => '%m', 'day' => '%d'][$attr];

return new Fragment("strftime('{$str}', post.published_at) {$wrappedField}");
return new Fragment("strftime('$str', post.published_at) $wrappedField");
}

return new Fragment("extract({$attr} from post.published_at) {$wrappedField}");
return new Fragment("extract($attr from post.published_at) $wrappedField");
}

private function getDriver(): DriverInterface
Expand Down
2 changes: 1 addition & 1 deletion blog/src/Blog/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Yiisoft\Data\Paginator\OffsetPaginator;
use Yiisoft\Router\HydratorAttribute\RouteArgument;
use Yiisoft\User\CurrentUser;
use Yiisoft\Yii\View\ViewRenderer;
use Yiisoft\Yii\View\Renderer\ViewRenderer;

final class BlogController
{
Expand Down
2 changes: 1 addition & 1 deletion blog/src/Blog/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Yiisoft\Input\Http\Attribute\Parameter\Body;
use Yiisoft\Input\Http\Attribute\Parameter\Query;
use Yiisoft\Router\HydratorAttribute\RouteArgument;
use Yiisoft\Yii\View\ViewRenderer;
use Yiisoft\Yii\View\Renderer\ViewRenderer;

final class CommentController
{
Expand Down
8 changes: 3 additions & 5 deletions blog/src/Blog/Post/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
use Yiisoft\FormModel\FormHydrator;
use Yiisoft\Http\Method;
use Yiisoft\Router\CurrentRoute;
use Yiisoft\Validator\ValidatorInterface;
use Yiisoft\Yii\View\ViewRenderer;
use Yiisoft\Yii\View\Renderer\ViewRenderer;

final class PostController
{
Expand Down Expand Up @@ -55,7 +54,7 @@ public function add(Request $request, FormHydrator $formHydrator): Response
return $this->webService->getRedirectResponse('blog/index');
}

$parameters['errors'] = $form->getValidationResult()->getErrorMessagesIndexedByAttribute();
$parameters['errors'] = $form->getValidationResult()->getErrorMessagesIndexedByProperty();
}

return $this->viewRenderer->render('__form', $parameters);
Expand All @@ -64,7 +63,6 @@ public function add(Request $request, FormHydrator $formHydrator): Response
public function edit(
Request $request,
PostRepository $postRepository,
ValidatorInterface $validator,
CurrentRoute $currentRoute,
FormHydrator $formHydrator
): Response {
Expand Down Expand Up @@ -94,7 +92,7 @@ public function edit(
}

$parameters['body'] = $body;
$parameters['errors'] = $form->getValidationResult()->getErrorMessagesIndexedByAttribute();
$parameters['errors'] = $form->getValidationResult()->getErrorMessagesIndexedByProperty();
}

return $this->viewRenderer->render('__form', $parameters);
Expand Down
2 changes: 1 addition & 1 deletion blog/src/Blog/Tag/TagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Psr\Http\Message\ResponseInterface as Response;
use Yiisoft\Data\Paginator\OffsetPaginator;
use Yiisoft\Router\CurrentRoute;
use Yiisoft\Yii\View\ViewRenderer;
use Yiisoft\Yii\View\Renderer\ViewRenderer;

final class TagController
{
Expand Down
16 changes: 8 additions & 8 deletions blog/src/Command/Fixture/AddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,29 +129,29 @@ private function addPosts(int $count): void
for ($i = 0; $i < $count; $i++) {
/** @var User $postUser */
$postUser = $this->users[array_rand($this->users)];
$post = new Post($this->faker->text(64), $this->faker->realText(rand(1000, 4000)));
$post = new Post($this->faker->text(64), $this->faker->realText(random_int(1000, 4000)));
$postUser->addPost($post);
$public = rand(0, 2) > 0;
$public = random_int(0, 2) > 0;
$post->setPublic($public);
if ($public) {
$post->setPublishedAt(new DateTimeImmutable(date('r', rand(strtotime('-2 years'), time()))));
$post->setPublishedAt(new DateTimeImmutable(date('r', random_int(strtotime('-2 years'), time()))));
}
// link tags
$postTags = (array) array_rand($this->tags, rand(1, count($this->tags)));
$postTags = (array) array_rand($this->tags, random_int(1, count($this->tags)));
foreach ($postTags as $tagId) {
$tag = $this->tags[$tagId];
$post->addTag($tag);
// todo: uncomment when issue is resolved https://github.com/cycle/orm/issues/70
// $tag->addPost($post);
}
// add comments
$commentsCount = rand(0, $count);
$commentsCount = random_int(0, $count);
for ($j = 0; $j <= $commentsCount; $j++) {
$comment = new Comment($this->faker->realText(rand(100, 500)));
$commentPublic = rand(0, 3) > 0;
$comment = new Comment($this->faker->realText(random_int(100, 500)));
$commentPublic = random_int(0, 3) > 0;
$comment->setPublic($commentPublic);
if ($commentPublic) {
$comment->setPublishedAt(new DateTimeImmutable(date('r', rand(strtotime('-1 years'), time()))));
$comment->setPublishedAt(new DateTimeImmutable(date('r', random_int(strtotime('-1 years'), time()))));
}
$commentUser = $this->users[array_rand($this->users)];
$commentUser->addComment($comment);
Expand Down
2 changes: 1 addition & 1 deletion blog/src/Contact/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Yiisoft\Http\Method;
use Yiisoft\Http\Status;
use Yiisoft\Router\UrlGeneratorInterface;
use Yiisoft\Yii\View\ViewRenderer;
use Yiisoft\Yii\View\Renderer\ViewRenderer;

final class ContactController
{
Expand Down
2 changes: 1 addition & 1 deletion blog/src/Contact/ContactForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class ContactForm extends FormModel implements RulesProviderInterface
#[UploadedFiles('ContactForm.attachFiles')]
private array $attachFiles = [];

public function getAttributeLabels(): array
public function getPropertyLabels(): array
{
return [
'name' => 'Name',
Expand Down
2 changes: 1 addition & 1 deletion blog/src/Contact/views/contact/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Yiisoft\View\WebView;

/**
* @var Yiisoft\Yii\View\Csrf $csrf
* @var Yiisoft\Yii\View\Renderer\Csrf $csrf
* @var ContactForm $form
* @var UrlGeneratorInterface $url
* @var WebView $this
Expand Down
2 changes: 1 addition & 1 deletion blog/src/Controller/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace App\Controller;

use Psr\Http\Message\ResponseInterface;
use Yiisoft\Yii\View\ViewRenderer;
use Yiisoft\Yii\View\Renderer\ViewRenderer;

final class SiteController
{
Expand Down
2 changes: 1 addition & 1 deletion blog/src/Handler/NotFoundHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Yiisoft\Http\Status;
use Yiisoft\Yii\View\ViewRenderer;
use Yiisoft\Yii\View\Renderer\ViewRenderer;

final class NotFoundHandler implements RequestHandlerInterface
{
Expand Down
2 changes: 1 addition & 1 deletion blog/src/User/Console/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

if ($user === false) {
$errors = $this->signupForm->getValidationResult()?->getErrorMessagesIndexedByAttribute();
$errors = $this->signupForm->getValidationResult()?->getErrorMessagesIndexedByProperty();
array_walk($errors, fn($error, $attribute) => $io->error("$attribute: " . implode("\n", (array) $error)));
return ExitCode::DATAERR;
}
Expand Down
2 changes: 1 addition & 1 deletion blog/src/User/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Yiisoft\Input\Http\Attribute\Parameter\Body;
use Yiisoft\Input\Http\Attribute\Parameter\Query;
use Yiisoft\Router\HydratorAttribute\RouteArgument;
use Yiisoft\Yii\View\ViewRenderer;
use Yiisoft\Yii\View\Renderer\ViewRenderer;

final class UserController
{
Expand Down
2 changes: 1 addition & 1 deletion blog/src/ViewInjection/CommonViewInjection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace App\ViewInjection;

use Yiisoft\Router\UrlGeneratorInterface;
use Yiisoft\Yii\View\CommonParametersInjectionInterface;
use Yiisoft\Yii\View\Renderer\CommonParametersInjectionInterface;

final class CommonViewInjection implements CommonParametersInjectionInterface
{
Expand Down
2 changes: 1 addition & 1 deletion blog/src/ViewInjection/LayoutViewInjection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use App\Auth\Identity;
use Yiisoft\User\CurrentUser;
use Yiisoft\Yii\View\LayoutParametersInjectionInterface;
use Yiisoft\Yii\View\Renderer\LayoutParametersInjectionInterface;

final class LayoutViewInjection implements LayoutParametersInjectionInterface
{
Expand Down
2 changes: 1 addition & 1 deletion blog/src/ViewInjection/LinkTagsViewInjection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\ViewInjection;

use Yiisoft\Yii\View\LinkTagsInjectionInterface;
use Yiisoft\Yii\View\Renderer\LinkTagsInjectionInterface;

final class LinkTagsViewInjection implements LinkTagsInjectionInterface
{
Expand Down
2 changes: 1 addition & 1 deletion blog/src/ViewInjection/MetaTagsViewInjection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\ViewInjection;

use Yiisoft\Yii\View\MetaTagsInjectionInterface;
use Yiisoft\Yii\View\Renderer\MetaTagsInjectionInterface;

final class MetaTagsViewInjection implements MetaTagsInjectionInterface
{
Expand Down

0 comments on commit 96b9726

Please sign in to comment.