Skip to content

Commit 0e6f0c7

Browse files
authored
Merge pull request #3 from magento-commerce/develop
v6 release scope
2 parents da46c5d + b74f41f commit 0e6f0c7

23 files changed

+470
-70
lines changed

.github/CODE_OF_CONDUCT.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language.
12+
* Being respectful of differing viewpoints and experiences.
13+
* Gracefully accepting constructive criticism.
14+
* Focusing on what is best for the community.
15+
* Showing empathy towards other community members.
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances.
20+
* Trolling, insulting/derogatory comments, and personal or political attacks.
21+
* Public or private harassment.
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission.
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting.
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version].
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

.github/CONTRIBUTING.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Contributing to Magento Coding Standard code
2+
3+
Contributions to the Magento Coding Standard codebase are done using the fork & pull model.
4+
This contribution model has contributors maintaining their own fork of the Magento Coding Standard repository.
5+
The forked repository is then used to submit a request to the base repository to “pull” a set of changes.
6+
For more information on pull requests please refer to [GitHub Help](https://help.github.com/articles/about-pull-requests/).
7+
8+
Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes or optimizations.
9+
10+
The Magento Coding Standard development team or community maintainers will review all issues and contributions submitted by the community of developers in the first in, first out order.
11+
During the review we might require clarifications from the contributor.
12+
If there is no response from the contributor within two weeks, the pull request will be closed.
13+
14+
For more detailed information on contribution please read our [beginners guide](https://github.com/magento/magento2/wiki/Getting-Started).
15+
16+
## Contribution requirements
17+
18+
1. Contributions must adhere to the [Magento coding standards](https://devdocs.magento.com/guides/v2.3/coding-standards/bk-coding-standards.html).
19+
2. Pull requests (PRs) must be accompanied by a meaningful description of their purpose. Comprehensive descriptions increase the chances of a pull request being merged quickly and without additional clarification requests.
20+
3. Commits must be accompanied by meaningful commit messages.
21+
4. PRs which include bug fixes must be accompanied with a step-by-step description of how to reproduce the bug.
22+
3. PRs which include new logic or new rules must be submitted along with:
23+
* Unit test coverage
24+
* Proposed [documentation](https://devdocs.magento.com) updates. Documentation contributions can be submitted via the [devdocs GitHub](https://github.com/magento/devdocs).
25+
4. For larger features or changes, please [open an issue](https://github.com/magento/magento-coding-standard/issues) to discuss the proposed changes prior to development. This may prevent duplicate or unnecessary effort and allow other contributors to provide input.
26+
5. All automated tests must pass (all builds on [Travis CI](https://travis-ci.com/github/magento/magento-coding-standard) must be green).
27+
28+
## Contribution process
29+
30+
If you are a new GitHub user, we recommend that you create your own [free github account](https://github.com/signup/free).
31+
This will allow you to collaborate with the Magento Coding Standard development team, fork the Magento Coding Standard project and send pull requests.
32+
33+
1. Search current [listed issues](https://github.com/magento/magento-coding-standard/issues) (open or closed) for similar proposals of intended contribution before starting work on a new contribution.
34+
2. Review the [Contributor License Agreement](https://opensource.adobe.com/cla.html) if this is your first time contributing.
35+
3. Create and test your work.
36+
4. Fork the Magento Coding Standard repository according to the [Fork A Repository instructions](https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#fork) and when you are ready to send us a pull request – follow the [Create A Pull Request instructions](https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#pull_request).
37+
5. Once your contribution is received the Magento Coding Standard development team will review the contribution and collaborate with you as needed.
38+
39+
## Code of Conduct
40+
41+
Please note that this project is released with a Contributor Code of Conduct. We expect you to agree to its terms when participating in this project.
42+
The full text is available in the repository [Wiki](https://github.com/magento/magento2/wiki/Magento-Code-of-Conduct).
43+
44+
## Connecting with Community!
45+
46+
If you have any questions, join us in [#beginners](https://magentocommeng.slack.com/messages/CH8BGFX9D) Slack chat. If you are not on our slack, [click here](http://tinyurl.com/engcom-slack) to join.
47+
48+
Need to find a project? Check out the [Slack Channels](https://github.com/magento/magento2/wiki/Slack-Channels) (with listed project info) and the [Magento Community Portal](https://opensource.magento.com/).

.travis.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ php:
55
- 7.1
66
- 7.2
77
- 7.3
8-
install: composer install --no-interaction --prefer-source
8+
- 7.4
9+
cache:
10+
directories:
11+
- $HOME/.composer/cache/files
12+
install: composer install --no-interaction --prefer-dist
913
script:
1014
- vendor/bin/phpunit
1115
- vendor/bin/phpcs --standard=Magento2 Magento2/ --extensions=php

LICENSE.TXT renamed to LICENSE.txt

File renamed without changes.

Magento2/Helpers/Commenting/PHPDocFormattingValidator.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,15 @@ public function hasDeprecatedWellFormatted($commentStartPtr, $tokens)
122122
return true;
123123
}
124124

125+
$seeTagRequired = false;
125126
if ($tokens[$deprecatedPtr + 2]['code'] !== T_DOC_COMMENT_STRING) {
126-
return false;
127+
$seeTagRequired = true;
127128
}
128-
129129
$seePtr = $this->getTagPosition('@see', $commentStartPtr, $tokens);
130130
if ($seePtr === -1) {
131-
return true;
131+
return !$seeTagRequired;
132132
}
133-
if ($tokens[$seePtr + 2]['code'] !== T_DOC_COMMENT_STRING) {
134-
return false;
135-
}
136-
137-
return true;
133+
return $tokens[$seePtr + 2]['code'] === T_DOC_COMMENT_STRING;
138134
}
139135

140136
/**

Magento2/Sniffs/Commenting/ClassAndInterfacePHPDocFormattingSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function process(File $phpcsFile, $stackPtr)
6565
if ($this->PHPDocFormattingValidator->providesMeaning($namePtr, $commentStartPtr, $tokens) !== true) {
6666
$phpcsFile->addWarning(
6767
sprintf(
68-
'%s description should contain additional information beyond the name already supplies.',
68+
'%s description must contain meaningful information beyond what its name provides or be removed.',
6969
ucfirst($tokens[$stackPtr]['content'])
7070
),
7171
$stackPtr,

Magento2/Sniffs/Functions/DiscouragedFunctionSniff.php

+13-4
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,21 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
5858
'^dngettext$' => null,
5959
'^domxml_.*$' => null,
6060
'^fbsql_.*$' => null,
61+
'^fbsql$' => null,
6162
'^fdf_add_doc_javascript$' => null,
6263
'^fdf_open$' => null,
6364
'^fopen$' => 'Magento\Framework\Filesystem\DriverInterface::fileOpen()',
6465
'^fclose$' => 'Magento\Framework\Filesystem\DriverInterface::fileClose()',
65-
'^fsockopen$' => null,
66+
'^fsockopen$' => 'Magento\Framework\Filesystem\Driver\Http::open()',
6667
'^ftp_.*$' => null,
6768
'^fwrite$' => 'Magento\Framework\Filesystem\DriverInterface::fileWrite()',
68-
'^gettext$' => null,
69+
'^fputs$' => 'Magento\Framework\Filesystem\DriverInterface::fileWrite()',
70+
'^gettext$' => 'Magento\Framework\Translate\AdapterInterface::translate()',
71+
'^_$' => 'Magento\Framework\Translate\AdapterInterface::translate()',
6972
'^gz.*$' => null,
7073
'^header$' => null,
7174
'^highlight_file$' => null,
75+
'^show_source$' => null,
7276
'^ibase_.*$' => null,
7377
'^id3_set_tag$' => null,
7478
'^ifx_.*$' => null,
@@ -88,6 +92,7 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
8892
'^msql_.*$' => null,
8993
'^mssql_.*$' => null,
9094
'^mysql_.*$' => null,
95+
'^mysql.*$' => null,
9196
'^odbc_.*$' => null,
9297
'^opendir$' => null,
9398
'^openlog$' => null,
@@ -119,9 +124,10 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
119124
'^session_.*$' => null,
120125
'^set_include_path$' => null,
121126
'^ini_set$' => null,
127+
'^ini_alter$' => null,
122128
'^set_time_limit$' => null,
123129
'^setcookie$' => null,
124-
'^setlocale$' => null,
130+
'^setlocale$' => 'Magento\Framework\Translate\AdapterInterface::setlocale()',
125131
'^setrawcookie$' => null,
126132
'^sleep$' => null,
127133
'^socket_.*$' => null,
@@ -135,7 +141,9 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
135141
'^vprintf$' => null,
136142
'^mysqli.*$' => null,
137143
'^oci_connect$' => null,
144+
'^ocilogon$' => null,
138145
'^oci_pconnect$' => null,
146+
'^ociplogon$' => null,
139147
'^quotemeta$' => null,
140148
'^sqlite_popen$' => null,
141149
'^time_nanosleep$' => null,
@@ -168,6 +176,7 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
168176
'^ircg_nickname_unescape$' => null,
169177
'^ldap_get_values$' => null,
170178
'^mb_decode_mimeheader$' => null,
179+
'^i18n_mime_header_decode$' => null,
171180
'^mb_parse_str$' => null,
172181
'^mcrypt_decrypt$' => null,
173182
'^mdecrypt_generic$' => null,
@@ -201,7 +210,6 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
201210
'^stat$' => null,
202211
'^lchgrp$' => null,
203212
'^lchown$' => null,
204-
'^show_source$' => null,
205213
'^is_dir$' => 'Magento\Framework\Filesystem\DriverInterface::isDirectory()',
206214
'^is_executable$' => null,
207215
'^is_file$' => 'Magento\Framework\Filesystem\DriverInterface::isFile()',
@@ -220,5 +228,6 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
220228
'^intval$' => '(int) construction',
221229
'^strval$' => '(string) construction',
222230
'^htmlspecialchars$' => '\Magento\Framework\Escaper->escapeHtml',
231+
'^getimagesize$' => 'getimagesizefromstring',
223232
];
224233
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
/**
3+
* Copyright © Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento2\Sniffs\Methods;
7+
8+
use PHP_CodeSniffer\Sniffs\Sniff;
9+
use PHP_CodeSniffer\Files\File;
10+
11+
/**
12+
* Detects possible use of deprecated model methods.
13+
*/
14+
class DeprecatedModelMethodSniff implements Sniff
15+
{
16+
const RESOURCE_METHOD = "getResource";
17+
18+
/**
19+
* String representation of warning.
20+
*
21+
* @var string
22+
*/
23+
protected $warningMessage = "The use of the deprecated method 'getResource()' to '%s' the data detected.";
24+
25+
/**
26+
* Warning violation code.
27+
*
28+
* @var string
29+
*/
30+
protected $warningCode = 'FoundDeprecatedModelMethod';
31+
32+
/**
33+
* List of deprecated method.
34+
*
35+
* @var array
36+
*/
37+
protected $methods = [
38+
'save',
39+
'load',
40+
'delete'
41+
];
42+
43+
protected $severity = 0;
44+
45+
/**
46+
* @inheritdoc
47+
*/
48+
public function register()
49+
{
50+
return [
51+
T_OBJECT_OPERATOR
52+
];
53+
}
54+
/**
55+
* @inheritdoc
56+
*/
57+
public function process(File $phpcsFile, $stackPtr)
58+
{
59+
$tokens = $phpcsFile->getTokens();
60+
$endOfStatement = $phpcsFile->findEndOfStatement($stackPtr);
61+
$resourcePosition = $phpcsFile->findNext(
62+
T_STRING,
63+
$stackPtr + 1,
64+
$endOfStatement,
65+
false,
66+
self::RESOURCE_METHOD
67+
);
68+
if ($resourcePosition !== false) {
69+
$methodPosition = $phpcsFile->findNext([T_STRING, T_VARIABLE], $resourcePosition + 1, $endOfStatement);
70+
if ($methodPosition !== false && in_array($tokens[$methodPosition]['content'], $this->methods, true)) {
71+
$phpcsFile->addWarning(
72+
sprintf($this->warningMessage, $tokens[$methodPosition]['content']),
73+
$stackPtr,
74+
$this->warningCode
75+
);
76+
}
77+
}
78+
}
79+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Rule: Do not import from `Test` namespaces
2+
## Background
3+
Sometimes IDE imports the namespace with `Test` automatically for return data type like string, float etc or any other means.
4+
5+
## Reasoning
6+
Time to time we're getting issue with running tests on PRs in magento/magento2 repository because someone imported `\Magento\Tests\NamingConvention\true\string` by mistake. As result - we have "No build reports available" for "Database Compare build", "Functional Tests build", "Sample Data Tests build" while Static tests are shown as "failing" but in results - we don't really have reason
7+
8+
## How it works
9+
Any occurrence starts with `Magento\Tests` in import from the namespace will raise the warning.
10+
11+
## How to fix
12+
13+
Remove `Magento\Tests` from the imported namespaces
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
/**
3+
* Copyright © Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento2\Sniffs\Namespaces;
7+
8+
use PHP_CodeSniffer\Sniffs\Sniff;
9+
use PHP_CodeSniffer\Files\File;
10+
use PHP_CodeSniffer\Util\Tokens;
11+
12+
/**
13+
* Detects static test namespace.
14+
*/
15+
class ImportsFromTestNamespaceSniff implements Sniff
16+
{
17+
/**
18+
* @var string
19+
*/
20+
private $prohibitNamespace = 'Magento\Tests';
21+
22+
/**
23+
* @var string
24+
*/
25+
protected $warningMessage = 'Application modules should not use classed from test modules.';
26+
27+
/**
28+
* @var string
29+
*/
30+
protected $warningCode = 'WrongImport';
31+
32+
/**
33+
* @inheritdoc
34+
*/
35+
public function register()
36+
{
37+
return [T_USE];
38+
}
39+
40+
/**
41+
* @inheritdoc
42+
*/
43+
public function process(File $phpcsFile, $stackPtr)
44+
{
45+
$next = $phpcsFile->findNext([T_COMMA, T_SEMICOLON, T_OPEN_USE_GROUP, T_CLOSE_TAG], ($stackPtr + 1));
46+
$tokens = $phpcsFile->getTokens();
47+
$getTokenAsContent = $phpcsFile->getTokensAsString($stackPtr, ($next - $stackPtr));
48+
if (strpos($getTokenAsContent, $this->prohibitNamespace) !== false) {
49+
$phpcsFile->addWarning($this->warningMessage, $stackPtr, $this->warningCode);
50+
}
51+
if ($next !== false
52+
&& $tokens[$next]['code'] !== T_SEMICOLON
53+
&& $tokens[$next]['code'] !== T_CLOSE_TAG
54+
) {
55+
$baseUse = rtrim($phpcsFile->getTokensAsString($stackPtr, ($next - $stackPtr)));
56+
$baseUse = str_replace('use \\', '', $baseUse);
57+
$closingCurly = $phpcsFile->findNext(T_CLOSE_USE_GROUP, ($next + 1));
58+
do {
59+
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), $closingCurly, true);
60+
$groupedAsContent = $baseUse. $tokens[$next]['content'];
61+
$next = $phpcsFile->findNext(T_COMMA, ($next + 1), $closingCurly);
62+
if (strpos($groupedAsContent, $this->prohibitNamespace) !== false) {
63+
$phpcsFile->addWarning($this->warningMessage, $stackPtr, $this->warningCode);
64+
return;
65+
}
66+
} while ($next !== false);
67+
}
68+
}
69+
}

Magento2/Sniffs/Performance/ForeachArrayMergeSniff.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ Typical example when `array_merge` is being used in the loop:
1515

1616
In order to reduce execution time `array_merge` can be called only once:
1717
``` php
18-
$options = [[]];
18+
$options = [];
1919
foreach ($configurationSources as $source) {
2020
// code here
2121
$options[] = $source->getOptions();
2222
}
2323

24-
// PHP 5.6+
25-
$options = array_merge(...$options);
24+
$options = array_merge([], ...$options);
2625
```

0 commit comments

Comments
 (0)