SantosSi
Repos
6
Followers
3

Events

issue comment
RenamePropertyToMatchTypeRector: respect leading _ for private properties

My goal is a different one: to combine both tools having a completely different way of working and also set of checks: phpunit works by reporting and suggesting,

Created at 2 weeks ago
opened issue
RenamePropertyToMatchTypeRector: respect leading _ for private properties

Bug Report

PHP Code Sniffer (phpcs) requires a leading underscore for private properties. This should be respected by rector.

| Subject | Details | | :------------- | :--------------------| | Rector version | last dev-main | | Installed as | composer dependency |

Minimal PHP Code Causing Issue

See https://getrector.org/demo/e2f55bef-9d70-41bb-9d6b-1aab1d4a8b0e

<?php

final class DemoFile
{
    // php code sniffer (phpcs) requires the leading underscore
    /**
     * Database object
     *
     * @var \PDO|null PDO object
     */
    private ?\PDO $_pdo = null;
}

Responsible rules

  • RenamePropertyToMatchTypeRector

Expected Behavior

Accept the property name named after the type, but with a leading underscore.

Created at 2 weeks ago
opened issue
RenameForeachValueVariableToMatchExprVariableRector does not regard iteration variable

Bug Report

| Subject | Details | | :------------- | :--------------------| | Rector version | last dev-main | | Installed as | composer dependency |

Minimal PHP Code Causing Issue

See https://getrector.org/demo/90da132c-f8ba-499a-9aaf-7e23a2d807e7

<?php

final class DemoFile
{
    public function run()
    {
        $numbers = ['one', 'two'];
        foreach ($numbers as $txt) {
            echo "This is number ".$txt;
        }
        unset($txt);
    }
}

Responsible rules

  • RenameForeachValueVariableToMatchExprVariableRector

Expected Behavior

Should have changed $txt unset($txt) to unset($number). It should change that var name everywhere within the scope,

Created at 1 month ago
issue comment
GetMockBuilderGetMockToCreateMockRector breaks test code

Find a comment that could explain the misbehavior in my comment in #87.

Created at 1 month ago
issue comment
[PHPUnit] Skip onlyMethods on GetMockBuilderGetMockToCreateMockRector

The reason for the misbehavior is that just checking for the existence of getMockBuilder() without regarding the following fluent style call(s) that further configure(s) the mock's behavior it is wrong. Reason is that on PHPUnit 9.5.22 createMock() is an equivalent of and in the end runs:

       return $this->getMockBuilder($originalClassName)
                    ->disableOriginalConstructor()
                    ->disableOriginalClone()
                    ->disableArgumentCloning()
                    ->disallowMockingUnknownTypes()
                    ->getMock();

which is not identical to the more verbose calls it suggests to replace in the original code. Instead the rector should only replace if the functions from the snippet above are called or, when omitted, they are the default in the PHPUnit version. BTW, I found the URL displayed next to the applied rule just proves that someone did this, but not why and under what conditions. This PR proves that that was not enough to replace someone else's source code. I found this a lot more helpful.

Created at 1 month ago
issue comment
EncapsedStringsToSprintfRector: support gettext's _()

Wow guys, impressive debugging speed!

Created at 1 month ago
issue comment
EncapsedStringsToSprintfRector: support gettext's _()

@samsonasik The hyperlink variants I provided above lists the following functions translating texts one way or another, copied here for your convenience: dcgettext dcngettext dgettext dngettext gettext ngettext Please review my opinion for confirmation.

Created at 1 month ago
opened issue
EncapsedStringsToSprintfRector: support gettext's _()

Bug Report

| Subject | Details | | :------------- | :---------------------------------------------------------------| | Rector version | v0.13.10 |

EncapsedStringsToSprintfRector does not respect gettext's _() translation function. It also changes the string to be re-translated, but the functions are called in the wrong order.

Minimal PHP Code Causing Issue

(https://getrector.org/demo/c693e8db-6a7a-4103-9b02-ff7d2f28a5e5) Changes the code to: echo _(sprintf('We have %d apples.', $amount));

Expected Behaviour

echo sprintf(_('We have %d apples.'), $amount));

  1. Either change to match the expected behavior. Then the string has to be re-translated.
  2. Or else leave it as it is when the string is processed by _() or its variants, like gettext(), ngettext, etc. If possible, make this rector configurable to give the dev team the option to keep the translations intact (leave the code as is) or not (run the rector), e.g. depending on the effort required to translate, which can be quite high with many strings and/or languages involved.
Created at 1 month ago
CODE_OF_CONDUCT and LICENSE not on the list of files to be translated

From the files linked in https://standard.publiccode.net/, CODE_OF_CONDUCT and LICENSE are not listed in https://github.com/publiccodenet/community-translations-standard/blob/main/README.md to be translated. Is that a mistake or by intention? If a mistake, how do we update the translators and the translations (e.g. my scripts in the PR 23 do not include them), and what has to be corrected in the workflow? If by intention, what is the reason? (BTW, when opening this Issue, as it is the first one for this project, I was reminded to review the code of conduct.)

Created at 2 months ago

Refactoring to functions, UI: more progress msg, +Language pt

Refactored spaghetti code into functions with function comments. User Interface: more messages sent to the standard output to show progress, including a completion message. Added configured language pt (portuguese) to start translating.

Created at 2 months ago
issue comment
Relicensing SQUAD under the GPLv3

I consent.

Created at 2 months ago
issue comment
Automate review template updates

Do we have a standard for writing criteria documents? I could not find one. What I spotted from .md criteria files, the content for the review-template is between "## Requirements" and the next "##" at the beginning of the line. An initial command for the above would be: awk 'BEGIN {p=0}; /## Requirements/ {p=1 ; next}; /##/ {p=0 ; next}; p {print}' Also, I suppose the items are one-liners after "*" at the beginning of the line. This would be to analyse the output of the command before to get the Requirements section content. Once these rules are confirmed, scripts are easier to write.

Created at 2 months ago