biati-digital / nova-php-cs-fixer

Nova php-cs-fixer extension with HTML support
10 stars 1 forks source link

Very Slow after Update Nova 11 #31

Closed moskoweb closed 1 year ago

moskoweb commented 1 year ago

Mac OS Version MacBook Air M2, 2022 Ventura 13.3.1 (a) (22E772610a)

PHP version PHP 8.2.6

Nova version 11.1

Describe the bug After updating to the latest version of Nova, when saving and processing PHP CS Fixer, page validation and formatting were very slow, taking almost a minute to complete the task.

Extension Debug output (REQUIRED)

PHP CS Fixer[20:47:34.976000] Extension configuration

PHP CS Fixer[20:47:34.977000] {
 "phppath": "/opt/homebrew/bin/php",
 "csfixerpath": "/opt/homebrew/bin/php-cs-fixer",
 "port": 8631,
 "server": true,
 "log": true,
 "fixerv3": true,
 "standard": "PSR12",
 "rules": "ordered_imports: true\nno_unused_imports: true\nblank_line_after_namespace: true\nblank_line_before_statement: true\nblank_line_after_opening_tag: true\narray_syntax: { \"syntax\": \"short\" }\nconcat_space: { \"spacing\": \"one\" }\narray_indentation: true\nencoding: true\nmethod_argument_space: true\nsingle_quote: true\nspace_after_semicolon: true\noperator_linebreak: true\nconcat_space: { \"spacing\": \"one\" }\nbinary_operator_spaces:{\"default\":\"align_single_space_minimal\"}\nnot_operator_with_space:true",
 "phpcsconfig": "",
 "onsave": true,
 "onlyiflocalconfigfile": false,
 "ignoreremote": false,
 "phpRespectNova": false,
 "phpUseTabs": false,
 "phpTabWidth": 4,
 "htmltry": true,
 "htmladditional": false,
 "htmlrules": "preserve_newlines: true",
 "twig": true,
 "twigRespectNova": false,
 "twigUseTabs": false,
 "twigTabWidth": 4,
 "twigrules": "new_line: true",
 "blade": false,
 "bladeRespectNova": false,
 "bladeUseTabs": false,
 "bladeTabWidth": 4,
 "bladerules": "end_with_newline: true\nkeep_array_indentation: true\nspace_in_paren: true\nspace_in_empty_paren: true\nunescape_strings: true",
 "phpcsfixerVersion": "3.4.0"
}

PHP CS Fixer[20:47:34.980000] Doing HTML

PHP CS Fixer[20:47:34.980000] {
 "indent_size": 4,
 "indent_with_tabs": false,
 "preserve_newlines": true,
 "indent_scripts": "keep",
 "max_preserve_newlines": 3,
 "content_unformatted": [
  "pre",
  "code"
 ]
}

PHP CS Fixer[20:47:34.980000] Format HTML inside PHP before processing PHP with config

PHP CS Fixer[20:47:34.980000] {"indent_size":4,"indent_with_tabs":false,"preserve_newlines":true,"indent_scripts":"keep","max_preserve_newlines":3,"content_unformatted":["pre","code"],"end_with_newline":false}

PHP CS Fixer[20:47:35.001000] HTML in PHP formatted in 22ms

PHP CS Fixer[20:47:35.006000] temp file created in

PHP CS Fixer[20:47:35.006000] /Users/alanmosko/Library/Application Support/Nova/Workspaces/C0B71C73-80C8-4757-98CD-10163091BB1F/biati.phpcsfixer/apporchidscreensadvertorialadvertorialeditscreen.php

PHP CS Fixer[20:47:35.006000] Using existing cache file

PHP CS Fixer[20:47:35.006000] Cache file path is /Users/alanmosko/Library/Application Support/Nova/Extensions/biati.phpcsfixer/php/.php-cs-fixer.cache

PHP CS Fixer[20:47:35.007000] Additional user rules

PHP CS Fixer[20:47:35.007000] {
 "ordered_imports": true,
 "no_unused_imports": true,
 "blank_line_after_namespace": true,
 "blank_line_before_statement": true,
 "blank_line_after_opening_tag": true,
 "array_syntax": {
  "syntax": "short"
 },
 "concat_space": {
  "spacing": "one"
 },
 "array_indentation": true,
 "encoding": true,
 "method_argument_space": true,
 "single_quote": true,
 "space_after_semicolon": true,
 "operator_linebreak": true,
 "binary_operator_spaces": {
  "default": "align_single_space_minimal"
 },
 "not_operator_with_space": true
}

PHP CS Fixer[20:47:35.007000] Generated command to fix file

PHP CS Fixer[20:47:35.007000] /opt/homebrew/bin/php "/opt/homebrew/bin/php-cs-fixer" fix "/Users/alanmosko/Library/Application Support/Nova/Workspaces/C0B71C73-80C8-4757-98CD-10163091BB1F/biati.phpcsfixer/apporchidscreensadvertorialadvertorialeditscreen.php" --rules='{"@PSR12":true,"ordered_imports":true,"no_unused_imports":true,"blank_line_after_namespace":true,"blank_line_before_statement":true,"blank_line_after_opening_tag":true,"array_syntax":{"syntax":"short"},"concat_space":{"spacing":"one"},"array_indentation":true,"encoding":true,"method_argument_space":true,"single_quote":true,"space_after_semicolon":true,"operator_linebreak":true,"binary_operator_spaces":{"default":"align_single_space_minimal"},"not_operator_with_space":true}' --using-cache=yes --cache-file=/Users/alanmosko/Library/Application\ Support/Nova/Extensions/biati.phpcsfixer/php/.php-cs-fixer.cache

PHP CS Fixer[20:47:35.007000] Calling PHP Formatting server on URL

PHP CS Fixer[20:47:35.007000] http://localhost:8631/index.php

PHP CS Fixer[20:48:36.013000] rawResponse [object NovaJSFetchResponse]

PHP CS Fixer[20:48:36.014000] Server response

PHP CS Fixer[20:48:36.015000] {
 "exec": "   1) /Users/alanmosko/Library/Application Support/Nova/Workspaces/C0B71C73-80C8-4757-98CD-10163091BB1F/biati.phpcsfixer/apporchidscreensadvertorialadvertorialeditscreen.php\n\nFixed 1 of 1 files in 0.195 seconds, 16.000 MB memory used\n",
 "content": "<?php\n\nnamespace App\\Orchid\\Screens\\Advertorial;\n\nuse App\\Models\\Advertorial;\nuse App\\Models\\Domain;\nuse App\\Orchid\\Layouts\\Components\\FormTrackingLayout;\nuse App\\Orchid\\Layouts\\Components\\FormUserOwnerLayout;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Validation\\Rule;\nuse Orchid\\Screen\\Actions\\Button;\nuse Orchid\\Screen\\Actions\\Link;\nuse Orchid\\Screen\\Fields;\nuse Orchid\\Screen\\Screen;\nuse Orchid\\Support\\Facades\\Layout;\n\nclass AdvertorialEditScreen extends Screen\n{\n    /**\n     * @var bool\n     */\n    public $exists = false;\n    protected $model;\n\n    /**\n     * Permissions for this screen\n     *\n     * @var array|string\n     */\n    public $permission = [\n        'platform.app.advertorials'\n    ];\n\n    /**\n     * Query data.\n     *\n     * @return array\n     */\n    public function query(Advertorial $model): iterable\n    {\n        /**\n         * Display header name.\n         */\n        $this->name = __('messages.advertorial.single');\n\n        $this->exists = $model->exists;\n        $this->model  = $model;\n\n        /**\n         * Display header description.\n         */\n        if ( ! $this->exists) {\n            $this->description = __('messages.general.add');\n        } else {\n            $this->description = __('messages.general.edit');\n        }\n\n        /**\n         * Check if is permission\n         */\n        if ($model->id) {\n            ! me()->isOwner($model);\n        }\n        if ( ! $model->user_id) {\n            $model->user_id = me()->id;\n        }\n\n        /**\n         * Check plan limit\n         */\n        if ( ! $this->exists && ! me()->hasLimit('advertorials', me()->advertorials()->count())) {\n            \\Toast::warning(__('messages.advertorial.toast.limit'));\n            abort(back());\n        }\n\n        return [\n            'model' => $model,\n            'meta'  => $model->meta->all()\n        ];\n    }\n\n    /**\n     * Button commands.\n     *\n     * @return \\Orchid\\Screen\\Action[]\n     */\n    public function commandBar(): iterable\n    {\n        return [\n            Link::make(__('messages.general.back'))\n                ->icon('arrow-left')\n                ->route('platform.advertorials.index'),\n\n            Button::make(__('messages.general.add'))\n                ->icon('plus')\n                ->method('create')\n                ->canSee( ! $this->exists),\n\n            Button::make(__('messages.general.update'))\n                ->icon('note')\n                ->method('update')\n                ->canSee($this->exists),\n\n            Link::make(__('messages.general.view-page'))\n            ->icon('eye')\n            ->canSee($this->exists)\n            ->href(\n                ($this->exists)\n                ? route('domain.advertorials.link', [$this->model->domain->domain, $this->model->slug])\n                : ''\n            )->target('_blank'),\n\n            Button::make(__('messages.general.delete'))\n                ->icon('trash')\n                ->method('delete')\n                ->canSee($this->exists),\n        ];\n    }\n\n    /**\n     * Views.\n     *\n     * @return \\Orchid\\Screen\\Layout[]|string[]\n     */\n    public function layout(): iterable\n    {\n        return [\n            (new FormUserOwnerLayout())->fields(),\n\n            Layout::block([\n                Layout::rows([\n                    Fields\\Group::make([\n                        Fields\\Input::make('model.name')\n                            ->title(__('messages.general.forms.name.title'))\n                            ->required(),\n\n                        Fields\\Select::make('model.domain_id')\n                            ->title(__('messages.domain.single'))\n                            ->fromQuery(Domain::whereIn('user_id', [1, $this->model->user_id]), 'domain')\n                            ->required(),\n\n                        Fields\\Input::make('model.slug')\n                            ->title(__('messages.general.forms.slug.title'))\n                            ->required()->placeholder(__('messages.general.forms.slug.placeholder'))\n                            ->class('form-control slugify')\n                            ->help(__('messages.general.forms.slug.help')),\n                    ]),\n                ]),\n            ])->title(__('messages.general.forms.title.page-data'))->vertical(true),\n\n            Layout::block([\n                Layout::tabs([\n                    __('Template') => [\n                        Layout::rows([\n                            Fields\\RadioButtons::make('meta.template')\n                                ->options([\n                                    'globo-journalism'    => __('Globo - Jornalismo'),\n                                    'globo-sport'         => __('Globo - Esporte'),\n                                    'globo-entertainment' => __('Globo - Entretenimento'),\n                                    'globo-recipe'        => __('Globo - Receitas'),\n                                    // 2 => __('Modelo 2'),\n                                    // 3 => __('Modelo 3'),\n                                    // 4 => __('Modelo 4'),\n                                    // 5 => __('Modelo 5'),\n                                    // 6 => __('Modelo 6'),\n                                ])\n                                ->title(__('Template:'))\n                                ->value('globo-journalism'),\n                        ]),\n                    ],\n\n                    __('Cabeçalho') => [\n                        Layout::columns([\n                            Layout::rows([\n                                Fields\\Picture::make('meta.header.logo')\n                                    ->title(__('Logo'))\n                                    ->acceptedFiles('.jpg,.png,.jpeg,.svg')\n                                    ->storage('b2'),\n                            ]),\n                            Layout::rows([\n                                Fields\\Input::make('meta.header.title')\n                                    ->title(__('Título')),\n\n                                Fields\\Input::make('meta.header.subtitle')\n                                    ->title(__('Subtítulo:'))\n                                    ->help(__('Opcional')),\n                            ]),\n                            Layout::rows([\n                                Fields\\Input::make('meta.header.button.text')\n                                    ->title(__('Texto do Botão')),\n\n                                Fields\\Input::make('meta.header.button.link')\n                                    ->title(__('Link do Botão')),\n                            ]),\n                        ]),\n                    ],\n\n                    __('Conteúdo') => [\n                        Layout::rows([\n                            Fields\\Group::make([\n                                Fields\\Input::make('meta.body.title')\n                                    ->title(__('Título')),\n\n                                Fields\\Input::make('meta.body.author')\n                                    ->title(__('Autor')),\n                            ]),\n\n                            Fields\\Group::make([\n                                Fields\\Input::make('meta.body.subtitle')\n                                    ->title(__('Subtítulo')),\n\n                                Fields\\DateTimer::make('meta.body.date')\n                                    ->title('Data de Publicação')\n                                    ->enableTime()\n                                    // ->format('d/m/Y H:i')\n                                    ->help(__('Se em branco, será exibido uma data dinâmica, com base no dia de acesso.')),\n                            ]),\n\n                            Fields\\TextArea::make('meta.body.content')\n                                ->title(__('Conteúdo'))\n                                ->class('text_editor')\n                                ->height('500px'),\n\n                            Fields\\Label::make('label')\n                            ->title(__('Conteúdo Dinâmico'))\n                            ->help(__('Você pode colocar algumas chaves de conteúdo dinâmico:')\n                            . '<br>\n                                <code>[BEFORE_YESTERDAY]</code>,\n                                <code>[YESTERDAY]</code>,\n                                <code>[CURRENT_DATE]</code>,\n                                <code>[CURRENT_TIME]</code>,\n                                <code>[TOMORROW]</code>,\n                                <code>[AFTER_TOMORROW]</code>,\n                                <code>[LAST_WEEK]</code>,\n                                <code>[NEXT_WEEK]</code>,\n                                <code>[CITY]</code>,\n                                <code>[STATE]</code>,\n                                <code>[COUNTRY]</code>,\n                                <code>[BANNER_IN_CONTENT]</code>\n                            '),\n                        ]),\n                        Layout::rows([\n                            Fields\\Group::make([\n                                Fields\\Input::make('meta.body.tags')\n                                    ->title(__('Tags:'))\n                                    ->help(__('Para separar as tags, coloque uma vírgula entre as tags.')),\n\n                                Fields\\Switcher::make('meta.body.newsletter.status')\n                                    ->sendTrueOrFalse()\n                                    ->title(__('Ativar Chamada Chamada para Newsletter?')),\n\n                                Fields\\Input::make('meta.body.newsletter.link')\n                                    ->title(__('Link para Inscrição:'))\n                                    ->type('url')->placeholder('https://...'),\n                            ]),\n                        ]),\n                    ],\n\n                    __('Conteúdos Relacionados') => [\n                        Layout::tabs([\n                            __('Conteúdo #1') => Layout::columns([\n                                Layout::rows([\n                                    Fields\\Picture::make('meta.related.0.image')\n                                        ->title(__('Imagem'))\n                                        ->acceptedFiles('.jpg,.png,.jpeg')\n                                        ->help(__('Tamanho Recomendado: 1280px por 720px'))\n                                        ->storage('b2'),\n                                ]),\n                                Layout::rows([\n                                    Fields\\Input::make('meta.related.0.title')\n                                        ->title(__('Título')),\n\n                                    Fields\\Input::make('meta.related.0.subtitle')\n                                        ->title(__('Subtítulo:'))\n                                        ->help(__('Opcional')),\n\n                                    Fields\\Input::make('meta.related.0.link')\n                                        ->title(__('Link do Conteúdo:'))\n                                        ->type('url')->placeholder('https://...'),\n                                ]),\n                                Layout::rows([\n                                    Fields\\TextArea::make('meta.related.0.description')\n                                        ->title(__('Descrição'))\n                                        ->rows(3),\n                                ]),\n                            ]),\n                            __('Conteúdo #2') => Layout::columns([\n                                Layout::rows([\n                                    Fields\\Picture::make('meta.related.1.image')\n                                        ->title(__('Imagem'))\n                                        ->acceptedFiles('.jpg,.png,.jpeg')\n                                        ->help(__('Tamanho Recomendado: 1280px por 720px'))\n                                        ->storage('b2'),\n                                ]),\n                                Layout::rows([\n                                    Fields\\Input::make('meta.related.1.title')\n                                        ->title(__('Título')),\n\n                                    Fields\\Input::make('meta.related.1.subtitle')\n                                        ->title(__('Subtítulo:'))\n                                        ->help(__('Opcional')),\n\n                                    Fields\\Input::make('meta.related.1.link')\n                                        ->title(__('Link do Conteúdo:'))\n                                        ->type('url')->placeholder('https://...'),\n                                ]),\n                                Layout::rows([\n                                    Fields\\TextArea::make('meta.related.1.description')\n                                        ->title(__('Descrição'))\n                                        ->rows(3),\n                                ]),\n                            ]),\n                            __('Conteúdo #3') => Layout::columns([\n                                Layout::rows([\n                                    Fields\\Picture::make('meta.related.2.image')\n                                        ->title(__('Imagem'))\n                                        ->acceptedFiles('.jpg,.png,.jpeg')\n                                        ->help(__('Tamanho Recomendado: 1280px por 720px'))\n                                        ->storage('b2'),\n                                ]),\n                                Layout::rows([\n                                    Fields\\Input::make('meta.related.2.title')\n                                        ->title(__('Título')),\n\n                                    Fields\\Input::make('meta.related.2.subtitle')\n                                        ->title(__('Subtítulo:'))\n                                        ->help(__('Opcional')),\n\n                                    Fields\\Input::make('meta.related.2.link')\n                                        ->title(__('Link do Conteúdo:'))\n                                        ->type('url')->placeholder('https://...'),\n                                ]),\n                                Layout::rows([\n                                    Fields\\TextArea::make('meta.related.2.description')\n                                        ->title(__('Descrição'))\n                                        ->rows(3),\n                                ]),\n                            ]),\n                        ]),\n                    ],\n\n                    __('Rodapé') => [\n                        Layout::rows([\n                            Fields\\Input::make('meta.footer.copyright')\n                                ->title(__('Copyright'))\n                                ->placeholder('Todos os direitos reservados...'),\n\n                            Fields\\Input::make('meta.footer.terms_of_use')\n                                ->title(__('Link para Termos de Uso'))\n                                ->type('url')->placeholder('https://...')\n                                ->help(__('Se não definido nenhum link, será colocado o link padrão da página do seu domínio.')),\n\n                            Fields\\Input::make('meta.footer.privacy_policy')\n                                ->title(__('Link para Política de Privacidade'))\n                                ->type('url')->placeholder('https://...')\n                                ->help(__('Se não definido nenhum link, será colocado o link padrão da página do seu domínio.')),\n                        ]),\n                    ],\n\n                    __('Banners de Publicidade') => [\n                        Layout::rows([\n                            Fields\\Input::make('meta.banners.link')\n                                ->title(__('Link de Destino dos Banner')),\n\n                            Fields\\Group::make([\n                                Fields\\Picture::make('meta.banners.title.before')\n                                    ->title(__('Banner Antes do Título'))\n                                    ->acceptedFiles('.jpg,.png,.jpeg,.gif')\n                                    ->help(__('Tamanho Recomendado: 1448px por 375px'))\n                                    ->storage('b2'),\n\n                                Fields\\Picture::make('meta.banners.content.before')\n                                    ->title(__('Banner Antes do Conteúdo'))\n                                    ->acceptedFiles('.jpg,.png,.jpeg,.gif')\n                                    ->help(__('Tamanho Recomendado: 1448px por 375px'))\n                                    ->storage('b2'),\n                            ]),\n\n                            Fields\\Group::make([\n                                Fields\\Picture::make('meta.banners.content.aside')\n                                    ->title(__('Banner Ao Lado do Conteúdo'))\n                                    ->acceptedFiles('.jpg,.png,.jpeg,.gif')\n                                    ->help(__('Tamanho Recomendado: 512px por 512px'))\n                                    ->storage('b2'),\n\n                                Fields\\Picture::make('meta.banners.content.middle')\n                                    ->title(__('Banner Em Meio ao Conteúdo'))\n                                    ->acceptedFiles('.jpg,.png,.jpeg,.gif')\n                                    ->help(__('Tamanho Recomendado: 1448px por 375px'))\n                                    ->storage('b2'),\n                            ]),\n\n                            Fields\\Group::make([\n                                Fields\\Picture::make('meta.banners.content.after')\n                                    ->title(__('Banner Depois do Conteúdo'))\n                                    ->acceptedFiles('.jpg,.png,.jpeg,.gif')\n                                    ->help(__('Tamanho Recomendado: 1448px por 375px'))\n                                    ->storage('b2'),\n\n                                Fields\\Picture::make('meta.banners.related.after')\n                                    ->title(__('Banner Abaixo do Conteúdo Relacionados'))\n                                    ->acceptedFiles('.jpg,.png,.jpeg,.gif')\n                                    ->help(__('Tamanho Recomendado: 1448px por 375px'))\n                                    ->storage('b2'),\n                            ]),\n                        ]),\n                    ],\n                ]),\n            ])->title(__('Conteúdo de Página'))->vertical(true),\n\n            (new FormTrackingLayout())->fields(),\n\n            Layout::block([\n                Layout::tabs([\n                    'SEO e Social' => [\n                        Layout::rows([\n                            Fields\\Group::make([\n                                Fields\\Input::make('meta.social.title')\n                                    ->title(__('Título')),\n\n                                Fields\\TextArea::make('meta.social.description')\n                                    ->title(__('Descrição'))\n                                    ->rows(3),\n                            ]),\n                            Fields\\Group::make([\n                                Fields\\Picture::make('meta.social.image')\n                                    ->title(__('Imagem'))\n                                    ->acceptedFiles('.jpg,.png,.jpeg')\n                                    ->storage('b2'),\n\n                                Fields\\Picture::make('meta.social.favicon')\n                                    ->title(__('Favicon'))\n                                    ->acceptedFiles('.png')\n                                    ->storage('b2'),\n                            ]),\n                        ]),\n                    ],\n                    'Botão de WhatsApp' => [\n                        Layout::rows([\n                            Fields\\Group::make([\n                                Fields\\Switcher::make('meta.whatsapp.status')\n                                    ->sendTrueOrFalse()\n                                    ->title(__('Ativar Botão do WhatsApp?')),\n\n                                Fields\\Input::make('meta.whatsapp.phone')\n                                    ->title(__('Número de WhatsApp'))\n                                    ->mask('55 (99) 99999-9999'),\n\n                                Fields\\TextArea::make('meta.whatsapp.message')\n                                    ->title(__('Mensagem de Contato'))\n                                    ->rows(2)\n                                    ->help(__('Insira uma mensagem para que possa identificar a origem do contato.')),\n                            ]),\n                        ]),\n                    ],\n                    'Adicionais' => [\n                        Layout::rows([\n                            Fields\\Group::make([\n                                Fields\\Switcher::make('meta.url_parameters')\n                                    ->sendTrueOrFalse()\n                                    ->checked()\n                                    ->title(__('messages.page.forms.additional.url_parameters.title'))\n                                    ->help(__('messages.page.forms.additional.url_parameters.help')),\n\n                                Fields\\Switcher::make('meta.cookie.status')\n                                    ->sendTrueOrFalse()\n                                    ->title(__('messages.page.forms.additional.cookie_status.title')),\n                            ]),\n                            Fields\\Group::make([\n                                Fields\\Input::make('meta.back_redirect')\n                                    ->type('url')->placeholder('https://...')\n                                    ->title(__('messages.page.forms.additional.back_redirect.title'))\n                                    ->help(__('messages.page.forms.additional.back_redirect.help')),\n\n                                Fields\\Input::make('meta.exit_redirect')\n                                    ->type('url')->placeholder('https://...')\n                                    ->title(__('messages.page.forms.additional.exit_redirect.title'))\n                                    ->help(__('messages.page.forms.additional.exit_redirect.help')),\n                            ]),\n                        ]),\n                    ],\n                    'Scripts' => [\n                        Layout::rows([\n                            Fields\\Group::make([\n                                Fields\\Code::make('meta.script.header')\n                                    ->language(Fields\\Code::MARKUP)\n                                    ->title(__('Cabeçalho')),\n\n                                Fields\\Code::make('meta.script.footer')\n                                    ->language(Fields\\Code::MARKUP)\n                                    ->title(__('Rodapé')),\n                            ]),\n                        ]),\n                    ],\n                ]),\n            ])->title('Recursos Extra')->vertical(true),\n        ];\n    }\n\n    /**\n     * @param Page    $page\n     * @param Request $request\n     *\n     * @return \\Illuminate\\Http\\RedirectResponse\n     */\n    public function create(Request $request, Advertorial $model)\n    {\n        $data = $request->get('model');\n        $meta = $request->get('meta');\n\n        if (Advertorial::where([\n            ['slug',      '=', data_get($data, 'slug')],\n            ['domain_id', '=', data_get($data, 'domain_id')],\n        ])->exists()\n        ) {\n            $request->validate([\n                'model.slug' => [\n                    'required',\n                    Rule::unique(Advertorial::class, 'slug')->ignore($model),\n                ]\n            ]);\n        }\n\n        if (is_null(data_get($data, 'user_id'))) {\n            $data['user_id'] = auth()->user()->id;\n        }\n\n        $model->meta = $meta;\n        $model->fill($data)->save();\n\n        \\Toast::success(__('messages.advertorial.toast.created'));\n\n        return redirect()->route('platform.advertorials.edit', $model);\n    }\n\n    /**\n     * @param Page    $page\n     * @param Request $request\n     *\n     * @return \\Illuminate\\Http\\RedirectResponse\n     */\n    public function update(Request $request, Advertorial $model)\n    {\n        $data = $request->get('model');\n        $meta = $request->get('meta');\n\n        if (Advertorial::where([\n            ['slug',      '=', data_get($data, 'slug')],\n            ['domain_id', '=', data_get($data, 'domain_id')],\n            ['id',       '!=', $model->id],\n        ])->exists()\n        ) {\n            $request->validate([\n                'model.slug' => [\n                    'required',\n                    Rule::unique(Advertorial::class, 'slug')->ignore($model),\n                ]\n            ]);\n        }\n\n        $model->meta = $meta;\n        $model->fill($data)->save();\n\n        \\Toast::success(__('messages.advertorial.toast.updated'));\n\n        return redirect()->route('platform.advertorials.edit', $model);\n    }\n\n    /**\n     * @param Advertorial $model\n     *\n     * @return \\Illuminate\\Http\\RedirectResponse\n     * @throws \\Exception\n     */\n    public function delete(Advertorial $model)\n    {\n        $model->slug = $model->slug . '-delete';\n        $model->save();\n\n        $model->delete();\n\n        \\Toast::success(__('messages.advertorial.toast.deleted'));\n\n        return redirect()->route('platform.advertorials.index');\n    }\n}\n",
 "command_errors": "   1) /Users/alanmosko/Library/Application Support/Nova/Workspaces/C0B71C73-80C8-4757-98CD-10163091BB1F/biati.phpcsfixer/apporchidscreensadvertorialadvertorialeditscreen.php\n\nFixed 1 of 1 files in 0.195 seconds, 16.000 MB memory used\n",
 "id": "phpcsfixer",
 "success": true,
 "apple": true,
 "command": "/opt/homebrew/bin/php \"/opt/homebrew/bin/php-cs-fixer\" fix \"/Users/alanmosko/Library/Application Support/Nova/Workspaces/C0B71C73-80C8-4757-98CD-10163091BB1F/biati.phpcsfixer/apporchidscreensadvertorialadvertorialeditscreen.php\" --rules='{\"@PSR12\":true,\"ordered_imports\":true,\"no_unused_imports\":true,\"blank_line_after_namespace\":true,\"blank_line_before_statement\":true,\"blank_line_after_opening_tag\":true,\"array_syntax\":{\"syntax\":\"short\"},\"concat_space\":{\"spacing\":\"one\"},\"array_indentation\":true,\"encoding\":true,\"method_argument_space\":true,\"single_quote\":true,\"space_after_semicolon\":true,\"operator_linebreak\":true,\"binary_operator_spaces\":{\"default\":\"align_single_space_minimal\"},\"not_operator_with_space\":true}' --using-cache=yes --cache-file=/Users/alanmosko/Library/Application\\ Support/Nova/Extensions/biati.phpcsfixer/php/.php-cs-fixer.cache"
}

PHP CS Fixer[20:48:36.017000] PHP formatted in server took 61010ms

PHP CS Fixer[20:48:36.018000] Updating document content

PHP CS Fixer[20:48:36.180000] Updating editor indent

PHP CS Fixer[20:48:36.181000] {
 "tabLength": 4,
 "softTabs": true
}

PHP CS Fixer[20:48:36.239000] Formatting process done
biati-digital commented 1 year ago

This is probably a bug in Nova, there are several complains about the latest update (crashes on paste, slow on save, etc) the only thing i can recommend is to downgrade and wait for a new Nova update. Nova has done this at least 3 times since it was released.

If a new update is released and this error is still present we will investigate.

moskoweb commented 1 year ago

Hello,

I downgraded the version, and now it's still slow, I don't know if you updated something in the extension after updating Nova, but it really seems that it's slow to run.

biati-digital commented 1 year ago

The extension has not been updated in 11 months, like I mentioned earlier, Nova has introduced errors like this at least 3 times, they eventually release an update that fixes this errors.

You can make some tests if you want but from past experience i recommend you to wait for a new update.

Did you try the extension with Nova 10+?

moskoweb commented 1 year ago

I used it before with 10, I updated to 11.1, and that's when I opened here, I updated to 11.2, and it's still slow, I'm analyzing the logs and trying to understand what it could be, if it's something local or extension.

I disabled the Dedicated Server in the extension, and it seems to run fast, but it gives an error.

PHP CS Fixer[17:25:26.763000] Extension configuration

PHP CS Fixer[17:25:26.765000] {
 "phppath": "/opt/homebrew/bin/php",
 "csfixerpath": "/opt/homebrew/bin/php-cs-fixer",
 "port": 8631,
 "server": false,
 "log": true,
 "fixerv3": true,
 "standard": "PSR12",
 "rules": "ordered_imports: true\nno_unused_imports: true\nblank_line_after_namespace: true\nblank_line_before_statement: true\nblank_line_after_opening_tag: true\narray_syntax: { \"syntax\": \"short\" }\nconcat_space: { \"spacing\": \"one\" }\narray_indentation: true\nencoding: true\nmethod_argument_space: true\nsingle_quote: true\nspace_after_semicolon: true\noperator_linebreak: true\nconcat_space: { \"spacing\": \"one\" }\nbinary_operator_spaces:{\"default\":\"align_single_space_minimal\"}\nnot_operator_with_space:true",
 "phpcsconfig": "",
 "onsave": true,
 "onlyiflocalconfigfile": false,
 "ignoreremote": false,
 "phpRespectNova": false,
 "phpUseTabs": false,
 "phpTabWidth": 4,
 "htmltry": true,
 "htmladditional": false,
 "htmlrules": "preserve_newlines: true",
 "twig": true,
 "twigRespectNova": false,
 "twigUseTabs": false,
 "twigTabWidth": 4,
 "twigrules": "new_line: true",
 "blade": false,
 "bladeRespectNova": false,
 "bladeUseTabs": false,
 "bladeTabWidth": 4,
 "bladerules": "end_with_newline: true\nkeep_array_indentation: true\nspace_in_paren: true\nspace_in_empty_paren: true\nunescape_strings: true",
 "phpcsfixerVersion": "3.4.0"
}

PHP CS Fixer[17:25:26.773000] The file does not contain HTML, skip HTML formatting

PHP CS Fixer[17:25:26.782000] temp file created in

PHP CS Fixer[17:25:26.782000] /Users/alanmosko/Library/Application Support/Nova/Workspaces/4BA50F2A-DDCE-404D-8A83-0197C1CD1887/biati.phpcsfixer/apphttpcontrollersapiwhatsappapisalmancontroller.php

PHP CS Fixer[17:25:26.785000] Using existing cache file

PHP CS Fixer[17:25:26.785000] Cache file path is /Users/alanmosko/Library/Application Support/Nova/Extensions/biati.phpcsfixer/php/.php-cs-fixer.cache

PHP CS Fixer[17:25:26.789000] Additional user rules

PHP CS Fixer[17:25:26.791000] {
 "ordered_imports": true,
 "no_unused_imports": true,
 "blank_line_after_namespace": true,
 "blank_line_before_statement": true,
 "blank_line_after_opening_tag": true,
 "array_syntax": {
  "syntax": "short"
 },
 "concat_space": {
  "spacing": "one"
 },
 "array_indentation": true,
 "encoding": true,
 "method_argument_space": true,
 "single_quote": true,
 "space_after_semicolon": true,
 "operator_linebreak": true,
 "binary_operator_spaces": {
  "default": "align_single_space_minimal"
 },
 "not_operator_with_space": true
}

PHP CS Fixer[17:25:26.792000] Generated command to fix file

PHP CS Fixer[17:25:26.793000] /opt/homebrew/bin/php /opt/homebrew/bin/php-cs-fixer fix /Users/alanmosko/Library/Application Support/Nova/Workspaces/4BA50F2A-DDCE-404D-8A83-0197C1CD1887/biati.phpcsfixer/apphttpcontrollersapiwhatsappapisalmancontroller.php --rules={"@PSR12":true,"ordered_imports":true,"no_unused_imports":true,"blank_line_after_namespace":true,"blank_line_before_statement":true,"blank_line_after_opening_tag":true,"array_syntax":{"syntax":"short"},"concat_space":{"spacing":"one"},"array_indentation":true,"encoding":true,"method_argument_space":true,"single_quote":true,"space_after_semicolon":true,"operator_linebreak":true,"binary_operator_spaces":{"default":"align_single_space_minimal"},"not_operator_with_space":true} --using-cache=yes --cache-file=/Users/alanmosko/Library/Application Support/Nova/Extensions/biati.phpcsfixer/php/.php-cs-fixer.cache

PHP CS Fixer[17:25:26.802000] Calling PHP Formatting using a process

PHP CS Fixer[17:25:27.421000] PHP formatted in process took 628ms

PHP CS Fixer[17:25:27.421000]    1) /Users/alanmosko/Library/Application Support/Nova/Workspaces/4BA50F2A-DDCE-404D-8A83-0197C1CD1887/biati.phpcsfixer/apphttpcontrollersapiwhatsappapisalmancontroller.php

Fixed 1 of 1 files in 0.355 seconds, 20.000 MB memory used

PHP CS Fixer[17:25:27.421000] Formatting process error

PHP CS Fixer[17:25:27.421000] Loaded config default.
 Using cache file "/Users/alanmosko/Library/Application Support/Nova/Extensions/biati.phpcsfixer/php/.php-cs-fixer.cache".
biati-digital commented 1 year ago

I see that you are using a custom path for phpcsfixer, that can also be the problem, try removing your custom fixer and make some tests.

moskoweb commented 1 year ago

Yes, I use the custom one, because since I installed the extension, the default plugin option has never worked, it always gives me an error.

I did a new test, and it seems that the training response time is fast, but what is being slow is the extension time to rewrite the file.

I took the command that runs in the log, and changed the file path created by the extension to the real file path, and the formation was immediate:

php-cs-fixer fix **[REAL_PATH_FILE]** --rules='{"@PSR12":true,"ordered_imports":true,"no_unused_imports":true,"blank_line_after_namespace":true,"blank_line_before_statement":true,"blank_line_after_opening_tag":true,"array_syntax":{"syntax":"short"},"concat_space":{"spacing":"one"},"array_indentation":true,"encoding":true,"method_argument_space":true,"single_quote":true,"space_after_semicolon":true,"operator_linebreak":true,"binary_operator_spaces":{"default":"align_single_space_minimal"},"not_operator_with_space":true}' --using-cache=yes
Loaded config default.
Using cache file ".php-cs-fixer.cache".
   1) .../MyFile.php

Fixed 1 of 1 files in 0.393 seconds, 22.000 MB memory used
moskoweb commented 1 year ago

And I also noticed that when I disable the function of using the dedicated server, the command is executed, completed successfully, but returns an error:

Captura de Tela 2023-06-15 às 12 18 38

I made the modification below locally, and it solved the problem of slow running without the dedicated server. It may be that the problem with the server is similar.

https://github.com/biati-digital/nova-php-cs-fixer/compare/main...moskoweb:nova-php-cs-fixer:patch-1

biati-digital commented 1 year ago

I did a new test, and it seems that the training response time is fast, but what is being slow is the extension time to rewrite the file.

The extension does not rewrite the file, it only formats the code and then it gives the output to Nova, Nova is the one that updates the file, restores scroll position, etc.

I made the modification below locally, and it solved the problem of slow running without the dedicated server. It may be that the problem with the server is similar.

I'm not exactly sure how your change would solve a slowness problem, your change will add support for newer versions of php-cs-fixer as they have changed the output but in your screenshot it shows that it took the process 536ms to format the code, that's really fast, then it returns an error because the extension it's expecting the output to contain "Fixed all files" but newer versions of php-cs-fixer changed that.

Did you test the dedicated server option after your change?

I'll merger your PR but it would be great if we make sure the dedicated server option works correctly, there's been cases where users have better results with the dedicated server option, even in an old version of the extension i removed the "dedicated server" option to simply run the process using Nova and there were several complains from users so i had to add it again, i think it depends a lot on the user config, php version, php-cs-fixer, etc.

moskoweb commented 1 year ago

Due to the continuous slow server, it seems to me that it is waiting for the result but it takes a while to receive the result, even finishing the process of formatting the file.

It could be that Nova has changed the way it returns the NovaJSFetchResponse object, I don't know, assumption.

Why when I deactivate the server, it is almost instantaneous the execution of PHP CS Fixer, while with the server it seems that it stays up to 60 seconds and timeout.

https://github.com/biati-digital/nova-php-cs-fixer/assets/6052272/7f6e6583-467a-43aa-aa21-d71a99d6d1d6

biati-digital commented 1 year ago

It seems something changed, i currently have a lot of work so can not check the server option, i'll include your fix and set the option "PHP dedicated server" to false by default.

Thank's for taking a look at this.