Skip to content

Commit d376275

Browse files
committed
Add vendor-prefixed dir to use it without install
1 parent 5300147 commit d376275

File tree

2,036 files changed

+224817
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,036 files changed

+224817
-0
lines changed

vendor-prefixed/autoload.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
// autoload.php @generated by Composer
4+
5+
require_once __DIR__ . '/composer/autoload_real.php';
6+
7+
return ComposerAutoloaderInitGravityFormsUploadAzure::getLoader();

vendor-prefixed/automattic/phpcs-neutron-standard/GUIDELINES.md

Lines changed: 363 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php
2+
3+
declare (strict_types=1);
4+
namespace Dekode\GravityForms\Vendor\NeutronStandard;
5+
6+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File;
7+
class SniffHelpers
8+
{
9+
public function isFunctionCall(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
10+
{
11+
$tokens = $phpcsFile->getTokens();
12+
$nextNonWhitespacePtr = $phpcsFile->findNext(\T_WHITESPACE, $stackPtr + 1, null, \true, null, \false);
13+
// if the next non-whitespace token is not a paren, then this is not a function call
14+
if ($tokens[$nextNonWhitespacePtr]['type'] !== 'T_OPEN_PARENTHESIS') {
15+
return \false;
16+
}
17+
// if the previous non-whitespace token is a function, then this is not a function call
18+
$prevNonWhitespacePtr = $phpcsFile->findPrevious(\T_WHITESPACE, $stackPtr - 1, null, \true, null, \false);
19+
if ($tokens[$prevNonWhitespacePtr]['type'] === 'T_FUNCTION') {
20+
return \false;
21+
}
22+
return \true;
23+
}
24+
// From https://stackoverflow.com/questions/619610/whats-the-most-efficient-test-of-whether-a-php-string-ends-with-another-string
25+
public function doesStringEndWith(string $string, string $test) : bool
26+
{
27+
$strlen = \strlen($string);
28+
$testlen = \strlen($test);
29+
if ($testlen > $strlen) {
30+
return \false;
31+
}
32+
return \substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
33+
}
34+
public function getNextNonWhitespace(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
35+
{
36+
$tokens = $phpcsFile->getTokens();
37+
$nextNonWhitespacePtr = $phpcsFile->findNext(\T_WHITESPACE, $stackPtr + 1, null, \true, null, \true);
38+
return $nextNonWhitespacePtr ? $tokens[$nextNonWhitespacePtr] : null;
39+
}
40+
public function getNextNewlinePtr(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
41+
{
42+
return $phpcsFile->findNext(\T_WHITESPACE, $stackPtr + 1, null, \false, "\n");
43+
}
44+
public function getArgumentTypePtr(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
45+
{
46+
$ignoredTypes = [\T_WHITESPACE, \T_ELLIPSIS];
47+
$openParenPtr = $phpcsFile->findPrevious(T_OPEN_PARENTHESIS, $stackPtr - 1, null, \false);
48+
if (!$openParenPtr) {
49+
return \false;
50+
}
51+
return $phpcsFile->findPrevious($ignoredTypes, $stackPtr - 1, $openParenPtr, \true);
52+
}
53+
public function isReturnValueVoid(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
54+
{
55+
$tokens = $phpcsFile->getTokens();
56+
if (!\in_array($tokens[$stackPtr]['code'], [\T_RETURN, \T_YIELD], \false)) {
57+
return \false;
58+
}
59+
$returnValue = $this->getNextNonWhitespace($phpcsFile, $stackPtr);
60+
return !$returnValue || $returnValue['code'] === 'PHPCS_T_SEMICOLON';
61+
}
62+
public function getNextReturnTypePtr(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
63+
{
64+
$startOfFunctionPtr = $this->getStartOfFunctionPtr($phpcsFile, $stackPtr);
65+
$colonPtr = $phpcsFile->findNext(T_COLON, $stackPtr, $startOfFunctionPtr);
66+
if (!$colonPtr) {
67+
return \false;
68+
}
69+
$endOfTypePtr = $phpcsFile->findNext([T_OPEN_CURLY_BRACKET, T_SEMICOLON], $colonPtr + 1);
70+
if (!$endOfTypePtr) {
71+
throw new \Exception('Found colon for return type but no end-of-line');
72+
}
73+
return $phpcsFile->findPrevious([\T_WHITESPACE], $endOfTypePtr - 1, $colonPtr, \true);
74+
}
75+
public function getNextSemicolonPtr(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
76+
{
77+
return $phpcsFile->findNext(T_SEMICOLON, $stackPtr + 1);
78+
}
79+
public function getEndOfFunctionPtr(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
80+
{
81+
$tokens = $phpcsFile->getTokens();
82+
if ($this->isFunctionJustSignature($phpcsFile, $stackPtr)) {
83+
return $this->getNextSemicolonPtr($phpcsFile, $stackPtr);
84+
}
85+
$openFunctionBracketPtr = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, $stackPtr + 1);
86+
return $openFunctionBracketPtr && isset($tokens[$openFunctionBracketPtr]['bracket_closer']) ? $tokens[$openFunctionBracketPtr]['bracket_closer'] : $this->getNextSemicolonPtr($phpcsFile, $stackPtr);
87+
}
88+
public function getStartOfFunctionPtr(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
89+
{
90+
$openFunctionBracketPtr = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, $stackPtr + 1);
91+
$nextSemicolonPtr = $this->getNextSemicolonPtr($phpcsFile, $stackPtr);
92+
if ($openFunctionBracketPtr && $nextSemicolonPtr && $openFunctionBracketPtr > $nextSemicolonPtr) {
93+
return $nextSemicolonPtr;
94+
}
95+
return $openFunctionBracketPtr ? $openFunctionBracketPtr + 1 : $this->getEndOfFunctionPtr($phpcsFile, $stackPtr);
96+
}
97+
public function isFunctionJustSignature(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
98+
{
99+
$openFunctionBracketPtr = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, $stackPtr + 1);
100+
$nextSemicolonPtr = $this->getNextSemicolonPtr($phpcsFile, $stackPtr);
101+
if ($openFunctionBracketPtr && $nextSemicolonPtr && $openFunctionBracketPtr > $nextSemicolonPtr) {
102+
return \true;
103+
}
104+
return !$openFunctionBracketPtr;
105+
}
106+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Dekode\GravityForms\Vendor\NeutronStandard\Sniffs\Arrays;
4+
5+
use Dekode\GravityForms\Vendor\NeutronStandard\SniffHelpers;
6+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Sniffs\Sniff;
7+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File;
8+
class DisallowLongformArraySniff implements \Dekode\GravityForms\Vendor\PHP_CodeSniffer\Sniffs\Sniff
9+
{
10+
public function register()
11+
{
12+
return [\T_ARRAY];
13+
}
14+
public function process(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
15+
{
16+
$tokens = $phpcsFile->getTokens();
17+
$functionName = $tokens[$stackPtr]['content'];
18+
$helper = new \Dekode\GravityForms\Vendor\NeutronStandard\SniffHelpers();
19+
if ($functionName === 'array' && $helper->isFunctionCall($phpcsFile, $stackPtr)) {
20+
$error = 'Longform array is not allowed';
21+
$shouldFix = $phpcsFile->addFixableError($error, $stackPtr, 'LongformArray');
22+
if ($shouldFix) {
23+
$this->fixTokens($phpcsFile, $stackPtr);
24+
}
25+
}
26+
}
27+
private function fixTokens(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
28+
{
29+
$tokens = $phpcsFile->getTokens();
30+
$openParenPtr = $tokens[$stackPtr]['parenthesis_opener'];
31+
$closeParenPtr = $tokens[$stackPtr]['parenthesis_closer'];
32+
$phpcsFile->fixer->beginChangeset();
33+
$phpcsFile->fixer->replaceToken($stackPtr, '');
34+
$phpcsFile->fixer->replaceToken($openParenPtr, '[');
35+
$phpcsFile->fixer->replaceToken($closeParenPtr, ']');
36+
$phpcsFile->fixer->endChangeset();
37+
}
38+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace Dekode\GravityForms\Vendor\NeutronStandard\Sniffs\AssignAlign;
4+
5+
use Dekode\GravityForms\Vendor\NeutronStandard\SniffHelpers;
6+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Sniffs\Sniff;
7+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File;
8+
class DisallowAssignAlignSniff implements \Dekode\GravityForms\Vendor\PHP_CodeSniffer\Sniffs\Sniff
9+
{
10+
public function register()
11+
{
12+
return [\T_WHITESPACE];
13+
}
14+
public function process(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
15+
{
16+
$tokens = $phpcsFile->getTokens();
17+
// If the next non-whitespace after multiples spaces is an equal sign or double arrow, mark a warning
18+
if (\strlen($tokens[$stackPtr]['content']) <= 1) {
19+
return;
20+
}
21+
$nextNonWhitespacePtr = $phpcsFile->findNext(\T_WHITESPACE, $stackPtr + 1, null, \true, null, \false);
22+
if ($nextNonWhitespacePtr !== \false && $this->isTokenAnAssignment($tokens[$nextNonWhitespacePtr])) {
23+
$error = 'Assignment alignment is not allowed';
24+
$shouldFix = $phpcsFile->addFixableWarning($error, $stackPtr, 'Aligned');
25+
if ($shouldFix) {
26+
$this->fixTokens($phpcsFile, $stackPtr);
27+
}
28+
}
29+
}
30+
private function isTokenAnAssignment($token)
31+
{
32+
$assignOperators = [T_EQUAL, \T_DOUBLE_ARROW];
33+
return \in_array($token['code'], $assignOperators, \true);
34+
}
35+
private function fixTokens(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
36+
{
37+
$phpcsFile->fixer->beginChangeset();
38+
$phpcsFile->fixer->replaceToken($stackPtr, ' ');
39+
$phpcsFile->fixer->endChangeset();
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Dekode\GravityForms\Vendor\NeutronStandard\Sniffs\Conditions;
4+
5+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Sniffs\Sniff;
6+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File;
7+
class DisallowConditionAssignWithoutConditionalSniff implements \Dekode\GravityForms\Vendor\PHP_CodeSniffer\Sniffs\Sniff
8+
{
9+
public function register()
10+
{
11+
return [T_OPEN_PARENTHESIS];
12+
}
13+
public function process(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
14+
{
15+
$tokens = $phpcsFile->getTokens();
16+
// if previous non-whitespace token is `T_IF`
17+
$prevNonWhitespacePtr = $phpcsFile->findPrevious(\T_WHITESPACE, $stackPtr - 1, null, \true, null, \false);
18+
if ($tokens[$prevNonWhitespacePtr]['type'] !== 'T_IF') {
19+
return;
20+
}
21+
// if there is a T_EQUAL after this before the end of statement
22+
$endOfStatementPtr = $phpcsFile->findEndOfStatement($stackPtr + 1);
23+
$nextAssignPtr = $phpcsFile->findNext(T_EQUAL, $stackPtr + 1, $endOfStatementPtr, \false, null, \false);
24+
if (!$nextAssignPtr) {
25+
return;
26+
}
27+
// if there is not a T_IS_EQUAL (or any other comparator!) before the end of statement
28+
$comparators = [\T_IS_EQUAL, \T_IS_NOT_EQUAL, \T_IS_IDENTICAL, \T_IS_NOT_IDENTICAL, \T_IS_SMALLER_OR_EQUAL, \T_IS_GREATER_OR_EQUAL, T_LESS_THAN, T_GREATER_THAN, \T_SPACESHIP];
29+
$nextEqualPtr = $phpcsFile->findNext($comparators, $stackPtr + 1, $endOfStatementPtr, \false, null, \false);
30+
if ($nextEqualPtr) {
31+
return;
32+
}
33+
// mark an error
34+
$error = 'Conditions that contain assignments must have explicit comparators';
35+
$phpcsFile->addError($error, $stackPtr, 'ConditionAssignWithoutConditional');
36+
}
37+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Dekode\GravityForms\Vendor\NeutronStandard\Sniffs\Constants;
4+
5+
use Dekode\GravityForms\Vendor\NeutronStandard\SniffHelpers;
6+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Sniffs\Sniff;
7+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File;
8+
class DisallowDefineSniff implements \Dekode\GravityForms\Vendor\PHP_CodeSniffer\Sniffs\Sniff
9+
{
10+
public function register()
11+
{
12+
return [\T_STRING];
13+
}
14+
public function process(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
15+
{
16+
$helper = new \Dekode\GravityForms\Vendor\NeutronStandard\SniffHelpers();
17+
if (!$helper->isFunctionCall($phpcsFile, $stackPtr)) {
18+
return;
19+
}
20+
$tokens = $phpcsFile->getTokens();
21+
$functionName = $tokens[$stackPtr]['content'];
22+
if ($functionName === 'define') {
23+
$error = 'Define is not allowed';
24+
$phpcsFile->addError($error, $stackPtr, 'Define');
25+
}
26+
}
27+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Dekode\GravityForms\Vendor\NeutronStandard\Sniffs\Extract;
4+
5+
use Dekode\GravityForms\Vendor\NeutronStandard\SniffHelpers;
6+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Sniffs\Sniff;
7+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File;
8+
class DisallowExtractSniff implements \Dekode\GravityForms\Vendor\PHP_CodeSniffer\Sniffs\Sniff
9+
{
10+
public function register()
11+
{
12+
return [\T_STRING];
13+
}
14+
public function process(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
15+
{
16+
$tokens = $phpcsFile->getTokens();
17+
$functionName = $tokens[$stackPtr]['content'];
18+
$helper = new \Dekode\GravityForms\Vendor\NeutronStandard\SniffHelpers();
19+
if ($functionName === 'extract' && $helper->isFunctionCall($phpcsFile, $stackPtr)) {
20+
$error = 'Extract is not allowed';
21+
$phpcsFile->addError($error, $stackPtr, 'Extract');
22+
}
23+
}
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Dekode\GravityForms\Vendor\NeutronStandard\Sniffs\Functions;
4+
5+
use Dekode\GravityForms\Vendor\NeutronStandard\SniffHelpers;
6+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Sniffs\Sniff;
7+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File;
8+
class DisallowCallUserFuncSniff implements \Dekode\GravityForms\Vendor\PHP_CodeSniffer\Sniffs\Sniff
9+
{
10+
public function register()
11+
{
12+
return [\T_STRING];
13+
}
14+
public function process(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
15+
{
16+
$tokens = $phpcsFile->getTokens();
17+
$functionName = $tokens[$stackPtr]['content'];
18+
$helper = new \Dekode\GravityForms\Vendor\NeutronStandard\SniffHelpers();
19+
$disallowedFunctions = ['call_user_func', 'call_user_func_array'];
20+
if (\in_array($functionName, $disallowedFunctions) && $helper->isFunctionCall($phpcsFile, $stackPtr)) {
21+
$error = 'call_user_func and call_user_func_array are not allowed';
22+
$phpcsFile->addError($error, $stackPtr, 'CallUserFunc');
23+
}
24+
}
25+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Dekode\GravityForms\Vendor\NeutronStandard\Sniffs\Functions;
4+
5+
use Dekode\GravityForms\Vendor\NeutronStandard\SniffHelpers;
6+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Sniffs\Sniff;
7+
use Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File;
8+
class LongFunctionSniff implements \Dekode\GravityForms\Vendor\PHP_CodeSniffer\Sniffs\Sniff
9+
{
10+
public $maxFunctionLines = 40;
11+
public function register()
12+
{
13+
return [\T_FUNCTION];
14+
}
15+
public function process(\Dekode\GravityForms\Vendor\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
16+
{
17+
$helper = new \Dekode\GravityForms\Vendor\NeutronStandard\SniffHelpers();
18+
if ($helper->isFunctionJustSignature($phpcsFile, $stackPtr)) {
19+
return;
20+
}
21+
$tokens = $phpcsFile->getTokens();
22+
$startOfFunctionPtr = $helper->getStartOfFunctionPtr($phpcsFile, $stackPtr);
23+
$endOfFunctionPtr = $helper->getEndOfFunctionPtr($phpcsFile, $stackPtr);
24+
$newlineCount = 0;
25+
$commentTokens = [T_DOC_COMMENT_OPEN_TAG, T_DOC_COMMENT_CLOSE_TAG, T_DOC_COMMENT_STRING, \T_COMMENT, T_DOC_COMMENT_STAR, T_DOC_COMMENT_WHITESPACE];
26+
$newlineContainingTokens = [\T_WHITESPACE, \T_COMMENT];
27+
$currentLinePtr = $phpcsFile->findNext(\T_WHITESPACE, $startOfFunctionPtr, $endOfFunctionPtr, \false, "\n") + 2;
28+
$foundNonComment = \false;
29+
for ($index = $currentLinePtr; $index < $endOfFunctionPtr; $index++) {
30+
$token = $tokens[$index];
31+
if (!\in_array($token['code'], $commentTokens)) {
32+
if ($token['code'] !== \T_WHITESPACE || $token['content'] !== "\n") {
33+
$foundNonComment = \true;
34+
}
35+
}
36+
if (\in_array($token['code'], $newlineContainingTokens) && $helper->doesStringEndWith($token['content'], "\n")) {
37+
if ($foundNonComment) {
38+
$newlineCount++;
39+
}
40+
$foundNonComment = \false;
41+
}
42+
}
43+
if (\intval($newlineCount) > $this->maxFunctionLines) {
44+
$error = "Function is longer than {$this->maxFunctionLines} lines";
45+
$phpcsFile->addWarning($error, $stackPtr, 'LongFunction');
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)