bmewburn / vscode-intelephense

PHP intellisense for Visual Studio Code
https://intelephense.com
Other
1.64k stars 94 forks source link

Support for Editor: Format On Save Mode when set to `modifications` or `modificationsIfAvailable` #3096

Open Andrii-Antoniuk opened 1 month ago

Andrii-Antoniuk commented 1 month ago

Feature description or problem with existing feature The formatter to work as expected on save if the mode is set to modifications or modificationsIfAvailable

Additional context Example file:

It's expected that __construct method will be formatted and fixed, since it's part of the modification.

<?php

namespace BKGroup\CheckoutRemarks\Observer;

use Magento\Framework\App\ResourceConnection;

class SaveRemarksToOrder implements \Magento\Framework\Event\ObserverInterface
{
    public function __construct(
        private ResourceConnection $resourceConnection
    ) {

    }

    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        /** @var string $data */
        $order = $observer->getData('order');
        $quote = $observer->getData('quote');
        $quoteId = $quote->getId();

        $connection = $this->resourceConnection->getConnection();
        $tableName = $this->resourceConnection->getTableName('order_remarks');

        $data = [
            'quote_id' => $quoteId,
            'order_id' => $order->getEntityId(),
        ];

        $connection->insertOnDuplicate($tableName, $data);
    }
}

image

bmewburn commented 1 month ago

Is the file under source control? I think that is a requirement for this in VSCode. Intelephense has no understanding of format modes, it provides a document and range format provider, it is up to the editor to call these providers.

Andrii-Antoniuk commented 1 month ago

Yes, it is.

I will check with other languages and resolve this issue if it's a vscode problem