Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b25dfb1

Browse filesBrowse files
committed
[NEW] acmark changes - coding standard
1 parent dff82a9 commit b25dfb1
Copy full SHA for b25dfb1

File tree

Expand file treeCollapse file tree

3 files changed

+38
-77
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+38
-77
lines changed

‎Magento2/Sniffs/Exceptions/DirectThrowSniff.php

Copy file name to clipboardExpand all lines: Magento2/Sniffs/Exceptions/DirectThrowSniff.php
+35-33Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,40 +41,42 @@ public function register()
4141
*/
4242
public function process(File $phpcsFile, $stackPtr)
4343
{
44-
$tokens = $phpcsFile->getTokens();
45-
$endOfStatement = $phpcsFile->findEndOfStatement($stackPtr);
46-
$posOfException = $phpcsFile->findNext(T_STRING, $stackPtr, $endOfStatement);
44+
// NOTE: not used for now
4745

48-
$fullExceptionString = $this->getFullClassNameAndAlias($tokens, $stackPtr, $endOfStatement);
49-
$exceptionString = 'Exception';
50-
$customExceptionFound = false;
51-
foreach ($tokens as $key => $token) {
52-
if ($token['code'] !== T_USE) {
53-
continue;
54-
}
55-
$endOfUse = $phpcsFile->findEndOfStatement($key);
56-
$useStatementValue = $this->getFullClassNameAndAlias($tokens, $key, $endOfUse);
57-
//we safely consider use statement has alias will not be a direct exception class
58-
if (empty($useStatementValue['alias'])) {
59-
if (substr($useStatementValue['name'], 0, strlen($exceptionString)) !== $exceptionString
60-
&& substr($useStatementValue['name'], -strlen($exceptionString)) === $exceptionString
61-
&& $useStatementValue['name'] !== $exceptionString
62-
) {
63-
$customExceptionFound = true;
64-
break;
65-
}
66-
}
67-
}
68-
if (($tokens[$posOfException]['content'] === 'Exception' && !$customExceptionFound)
69-
|| $fullExceptionString['name'] === '\Exception'
70-
) {
71-
$phpcsFile->addWarning(
72-
$this->warningMessage,
73-
$stackPtr,
74-
$this->warningCode,
75-
[$posOfException]
76-
);
77-
}
46+
// $tokens = $phpcsFile->getTokens();
47+
// $endOfStatement = $phpcsFile->findEndOfStatement($stackPtr);
48+
// $posOfException = $phpcsFile->findNext(T_STRING, $stackPtr, $endOfStatement);
49+
50+
// $fullExceptionString = $this->getFullClassNameAndAlias($tokens, $stackPtr, $endOfStatement);
51+
// $exceptionString = 'Exception';
52+
// $customExceptionFound = false;
53+
// foreach ($tokens as $key => $token) {
54+
// if ($token['code'] !== T_USE) {
55+
// continue;
56+
// }
57+
// $endOfUse = $phpcsFile->findEndOfStatement($key);
58+
// $useStatementValue = $this->getFullClassNameAndAlias($tokens, $key, $endOfUse);
59+
// //we safely consider use statement has alias will not be a direct exception class
60+
// if (empty($useStatementValue['alias'])) {
61+
// if (substr($useStatementValue['name'], 0, strlen($exceptionString)) !== $exceptionString
62+
// && substr($useStatementValue['name'], -strlen($exceptionString)) === $exceptionString
63+
// && $useStatementValue['name'] !== $exceptionString
64+
// ) {
65+
// $customExceptionFound = true;
66+
// break;
67+
// }
68+
// }
69+
// }
70+
// if (($tokens[$posOfException]['content'] === 'Exception' && !$customExceptionFound)
71+
// || $fullExceptionString['name'] === '\Exception'
72+
// ) {
73+
// $phpcsFile->addWarning(
74+
// $this->warningMessage,
75+
// $stackPtr,
76+
// $this->warningCode,
77+
// [$posOfException]
78+
// );
79+
// }
7880
}
7981

8082
/**

‎Magento2/Sniffs/Functions/DiscouragedFunctionSniff.php

Copy file name to clipboardExpand all lines: Magento2/Sniffs/Functions/DiscouragedFunctionSniff.php
-43Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,9 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
3939
'^call_user_func_array$' => null,
4040
'^chdir$' => null,
4141
'^chgrp$' => null,
42-
// '^chmod$' => 'Magento\Framework\Filesystem\DriverInterface::changePermissions()
43-
// or Magento\Framework\Filesystem\DriverInterface::changePermissionsRecursively',
4442
'^chown$' => null,
4543
'^chroot$' => null,
4644
'^com_load_typelib$' => null,
47-
// '^copy$' => 'Magento\Framework\Filesystem\DriverInterface::copy',
48-
// '^curl_.*$' => null,
4945
'^cyrus_connect$' => null,
5046
'^dba_.*$' => null,
5147
'^dbase_.*$' => null,
@@ -54,21 +50,13 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
5450
'^dcngettext$' => null,
5551
'^dgettext$' => null,
5652
'^dio_.*$' => null,
57-
// '^dirname$' => 'Magento\Framework\Filesystem\DriverInterface::getParentDirectory',
5853
'^dngettext$' => null,
5954
'^domxml_.*$' => null,
6055
'^fbsql_.*$' => null,
6156
'^fbsql$' => null,
6257
'^fdf_add_doc_javascript$' => null,
6358
'^fdf_open$' => null,
64-
// '^fopen$' => 'Magento\Framework\Filesystem\DriverInterface::fileOpen',
65-
// '^fclose$' => 'Magento\Framework\Filesystem\DriverInterface::fileClose',
66-
// '^fsockopen$' => 'Magento\Framework\Filesystem\Driver\Http::open',
6759
'^ftp_.*$' => null,
68-
// '^fwrite$' => 'Magento\Framework\Filesystem\DriverInterface::fileWrite',
69-
// '^fputs$' => 'Magento\Framework\Filesystem\DriverInterface::fileWrite',
70-
// '^gettext$' => 'Magento\Framework\Translate\AdapterInterface::translate',
71-
// // '^_$' => 'Magento\Framework\Translate\AdapterInterface::translate',
7260
'^gz.*$' => null,
7361
'^header$' => null,
7462
'^highlight_file$' => null,
@@ -84,7 +72,6 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
8472
'^link$' => null,
8573
'^mail$' => null,
8674
'^mb_send_mail$' => null,
87-
// '^mkdir$' => 'Magento\Framework\Filesystem\DriverInterface::createDirectory',
8875
'^move_uploaded_file$' => null,
8976
'^msession_.*$' => null,
9077
'^msg_send$' => null,
@@ -94,15 +81,13 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
9481
'^mysql_.*$' => null,
9582
'^mysql.*$' => null,
9683
'^odbc_.*$' => null,
97-
'^opendir$' => null,
9884
'^openlog$' => null,
9985
'^ora_.*$' => null,
10086
'^ovrimos_.*$' => null,
10187
'^parse_ini_file$' => null,
10288
'^parse_str$' => null,
10389
'^parse_url$' => null,
10490
'^parsekit_compile_string$' => null,
105-
// '^pathinfo$' => 'Magento\Framework\Filesystem\Io\File::getPathInfo',
10691
'^pcntl_.*$' => null,
10792
'^posix_.*$' => null,
10893
'^pfpro_.*$' => null,
@@ -112,32 +97,24 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
11297
'^print_r$' => null,
11398
'^printf$' => null,
11499
'^putenv$' => null,
115-
// '^readfile$' => 'Magento\Framework\Filesystem\DriverInterface::fileRead',
116100
'^readgzfile$' => null,
117-
// '^readline$' => 'Magento\Framework\Filesystem\DriverInterface::fileReadLine',
118101
'^readlink$' => null,
119102
'^register_shutdown_function$' => null,
120103
'^register_tick_function$' => null,
121-
// '^rename$' => 'Magento\Framework\Filesystem\DriverInterface::rename',
122-
// '^rmdir$' => 'Magento\Framework\Filesystem\DriverInterface::deleteDirectory',
123104
'^scandir$' => null,
124105
'^session_.*$' => null,
125106
'^set_include_path$' => null,
126107
'^ini_set$' => null,
127108
'^ini_alter$' => null,
128109
'^set_time_limit$' => null,
129110
'^setcookie$' => null,
130-
// '^setlocale$' => 'Magento\Framework\Translate\AdapterInterface::setLocale',
131111
'^setrawcookie$' => null,
132112
'^sleep$' => null,
133113
'^socket_.*$' => null,
134114
'^stream_.*$' => null,
135115
'^sybase_.*$' => null,
136-
// '^symlink$' => 'Magento\Framework\Filesystem\DriverInterface::symlink',
137116
'^syslog$' => null,
138-
// '^touch$' => 'Magento\Framework\Filesystem\DriverInterface::touch',
139117
'^trigger_error$' => null,
140-
'^unlink$' => null,
141118
'^vprintf$' => null,
142119
'^mysqli.*$' => null,
143120
'^oci_connect$' => null,
@@ -158,7 +135,6 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
158135
'^fdf_.*$' => null,
159136
'^fget.*$' => null,
160137
'^fread$' => null,
161-
// '^fflush$' => 'Magento\Framework\Filesystem\DriverInterface::fileFlush',
162138
'^get_browser$' => null,
163139
'^get_headers$' => null,
164140
'^get_meta_tags$' => null,
@@ -204,40 +180,21 @@ class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
204180
'^gettype$' => null,
205181
'^var_dump$' => null,
206182
'^tempnam$' => null,
207-
// '^realpath$' => 'Magento\Framework\Filesystem\DriverInterface::getRealPath',
208183
'^linkinfo$' => null,
209-
// '^lstat$' => 'Magento\Framework\Filesystem\DriverInterface::stat',
210184
'^stat$' => null,
211185
'^lchgrp$' => null,
212186
'^lchown$' => null,
213-
// '^is_dir$' => 'Magento\Framework\Filesystem\DriverInterface::isDirectory',
214187
'^is_executable$' => null,
215-
// '^is_file$' => 'Magento\Framework\Filesystem\DriverInterface::isFile',
216188
'^is_link$' => null,
217-
// '^is_readable$' => 'Magento\Framework\Filesystem\DriverInterface::isReadable',
218-
// '^is_writable$' => 'Magento\Framework\Filesystem\DriverInterface::isWritable',
219-
// '^is_writeable$' => 'Magento\Framework\Filesystem\DriverInterface::isWritable',
220189
'^is_uploaded_file$' => null,
221-
// '^glob$' => 'Magento\Framework\Filesystem\Glob::glob',
222190
'^ssh2_.*$' => null,
223-
// '^delete$' => 'Magento\Framework\Filesystem\DriverInterface::deleteFile',
224191
'^file.*$' => null,
225192
'^chop$' => 'rtrim()',
226193
'^sizeof$' => 'count()',
227194
'^is_null$' => 'strict comparison "=== null"',
228195
'^intval$' => '(int) construction',
229196
'^strval$' => '(string) construction',
230-
// '^htmlspecialchars$' => '\Magento\Framework\Escaper->escapeHtml',
231197
'^getimagesize$' => 'getimagesizefromstring',
232-
// '^file_exists$' => 'Magento\Framework\Filesystem\DriverInterface::isExists',
233-
// '^file_get_contents$' => 'Magento\Framework\Filesystem\DriverInterface::fileGetContents',
234-
// '^file_put_contents$' => 'Magento\Framework\Filesystem\DriverInterface::filePutContents',
235-
// '^fgetcsv$' => 'Magento\Framework\Filesystem\DriverInterface::fileGetCsv',
236-
// '^fputcsv$' => 'Magento\Framework\Filesystem\DriverInterface::filePutCsv',
237-
// '^ftell$' => 'Magento\Framework\Filesystem\DriverInterface::fileTell',
238-
// '^fseek$' => 'Magento\Framework\Filesystem\DriverInterface::fileSeek',
239-
// '^feof$' => 'Magento\Framework\Filesystem\DriverInterface::endOfFile',
240-
// '^flock$' => 'Magento\Framework\Filesystem\DriverInterface::fileLock',
241198
'^date_sunrise$' => 'date_sun_info',
242199
'^date_sunset$' => 'date_sun_info',
243200
'^strptime$' => 'date_parse_from_format',

‎README.md

Copy file name to clipboardExpand all lines: README.md
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
## Fork changes:
44
- removed SuperGlobals sniff (global $db - allowed now) - Magento2/Sniffs/Security/SuperglobalSniff.php
55
- removed Magento Framework from DiscouragedFunctions sniff (Filesystem, Translate...) - Magento2/Sniffs/Functions/DiscouragedFunctionSniff.php
6-
- removed curl from DiscouragedFunctions sniff - Magento2/Sniffs/Functions/DiscouragedFunctionSniff.php
6+
- removed base functions curl, unlink... from DiscouragedFunctions sniff - Magento2/Sniffs/Functions/DiscouragedFunctionSniff.php
7+
- ignored Direct Throw of Generic Exception - Magento2/Sniffs/Exceptions/DirectThrowSniff.php
8+
79

810
## Description
911

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.