Skip to content

Correct typos and language #457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ the code should be flagged or not. Additionally, making auto-fixes to code in a

This defensive coding in a sniff should, of course, also be safeguarded via tests.

Parse/compile errors can take various forms. Some can be handled without much problems by PHPCS, some can not.
Parse/compile errors can take various forms. Some can be handled without many problems by PHPCS, some can not.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"without much problems" is an expression and is correct. "without many problems" changes the meaning of the sentence.


If a code snippet to be tested could lead to a broken token stream due to a parse/compile error, the code snippet should always
be put in a separate test case file by itself and be accompanied by a comment stating the test is an intentional parse error.
Expand Down
2 changes: 1 addition & 1 deletion .github/community-cc-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This list will be used on select tickets to ping the wider PHP_CodeSniffer community for input.

If you want to be on this list, feel free to submit a PR to add yourself.
If you want to be removed from the list, dito, submit a PR to remove yourself and it will be merged without questions.
If you want to be removed from the list, dito, submit a PR to remove yourself, and it will be merged without questions.

PRs adding/removing other people to/from the list will only be merged if the people being added/removed leave a comment on the PR consenting to it.

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
run: npm install --global remark-cli --foreground-scripts true --fund false

# To allow for creating a custom config which references rules which are included
# in the presets, without having to install all rules individually, a local install
# in the presets, without having to install all rules individually, a local installation
# works best (and installing the presets in the first place, of course).
#
# Note: the first group of packages are all part of the mono "Remark lint" repo.
Expand Down
2 changes: 1 addition & 1 deletion .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ config:
heading_line_length: 100
# Number of characters for code blocks.
code_block_line_length: 100
# Stern length checking (applies to tables, code blocks etc which have their own max line length).
# Stern length checking (applies to tables, code blocks etc. which have their own max line length).
stern: true

# MD022/blanks-around-headings : Headings should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md022.md
Expand Down
92 changes: 46 additions & 46 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static function load($class)
{
// Include the composer autoloader if there is one, but re-register it
// so this autoloader runs before the composer one as we need to include
// all files so we can figure out what the class/interface/trait name is.
// all files, so we can figure out what the class/interface/trait name is.
if (self::$composerAutoloader === null) {
// Make sure we don't try to load any of Composer's classes
// while the autoloader is being setup.
Expand Down Expand Up @@ -204,7 +204,7 @@ public static function determineLoadedClass($classesBeforeLoad, $classesAfterLoa
}

// Since PHP 7.4 get_declared_classes() does not guarantee any order, making
// it impossible to use order to determine which is the parent an which is the child.
// it impossible to use order to determine which is the parent and which is the child.
// Let's reduce the list of candidates by removing all the classes known to be "parents".
// That way, at the end, only the "main" class just included will remain.
$newClasses = array_reduce(
Expand Down
3 changes: 3 additions & 0 deletions reproductions/3875.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file doesn't belong here.


declare(strict_types=1);
6 changes: 3 additions & 3 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
* @property bool $stdin Read content from STDIN instead of supplied files.
* @property string $stdinContent Content passed directly to PHPCS on STDIN.
* @property string $stdinPath The path to use for content passed on STDIN.
* @property bool $trackTime Whether or not to track sniff run time.
Copy link
Member

@jrfnl jrfnl Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing wrong with the original text as far as I can see. (here and below)

* @property bool $trackTime Whether to track sniff run time.
*
* @property array<string, string> $extensions File extensions that should be checked, and what tokenizer to use.
* E.g., array('inc' => 'PHP');
Expand Down Expand Up @@ -152,7 +152,7 @@ class Config
];

/**
* Whether or not to kill the process when an unknown command line arg is found.
* Whether to kill the process when an unknown command line arg is found.
*
* If FALSE, arguments that are not command line options or file/directory paths
* will be ignored and execution will continue. These values will be stored in
Expand Down Expand Up @@ -364,7 +364,7 @@ public function setSettings($settings)
* Creates a Config object and populates it with command line values.
*
* @param array $cliArgs An array of values gathered from CLI args.
* @param bool $dieOnUnknownArg Whether or not to kill the process when an
* @param bool $dieOnUnknownArg Whether to kill the process when an
* unknown command line arg is found.
*
* @return void
Expand Down
12 changes: 6 additions & 6 deletions src/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ public function parse()

$this->numTokens = count($this->tokens);

// Check for mixed line endings as these can cause tokenizer errors and we
// Check for mixed line endings as these can cause tokenizer errors, and we
// should let the user know that the results they get may be incorrect.
// This is done by removing all backslashes, removing the newline char we
// detected, then converting newlines chars into text. If any backslashes
Expand Down Expand Up @@ -1861,7 +1861,7 @@ public function getMemberProperties($stackPtr)
&& ($this->tokens[$ptr]['code'] === T_INTERFACE
|| $this->tokens[$ptr]['code'] === T_ENUM)
) {
// T_VARIABLEs in interfaces/enums can actually be method arguments
// T_VARIABLEs in interfaces/enums can actually be method arguments,
// but they won't be seen as being inside the method because there
// are no scope openers and closers for abstract methods. If it is in
// parentheses, we can be pretty sure it is a method argument.
Expand Down Expand Up @@ -2260,7 +2260,7 @@ public function getTokensAsString($start, $length, $origContent=false)
* be returned.
* @param bool $local If true, tokens outside the current statement
* will not be checked. IE. checking will stop
* at the previous semi-colon found.
* at the previous semicolon found.
*
* @return int|false
* @see findNext()
Expand Down Expand Up @@ -2341,7 +2341,7 @@ public function findPrevious(
* be returned.
* @param bool $local If true, tokens outside the current statement
* will not be checked. i.e., checking will stop
* at the next semi-colon found.
* at the next semicolon found.
*
* @return int|false
* @see findPrevious()
Expand Down Expand Up @@ -2479,7 +2479,7 @@ public function findStartOfStatement($start, $ignore=null)
// If we are starting at a token that ends a scope block, skip to
// the start and continue from there.
// If we are starting at a token that ends a statement, skip this
// token so we find the true start of the statement.
// token, so we find the true start of the statement.
while (isset($endTokens[$this->tokens[$start]['code']]) === true
|| (isset($this->tokens[$start]['scope_condition']) === true
&& $start === $this->tokens[$start]['scope_closer'])
Expand Down Expand Up @@ -2582,7 +2582,7 @@ public function findEndOfStatement($start, $ignore=null)
$prevComma = $this->findNext(T_COMMA, ($prevMatchArrow + 1), $start);
if ($prevComma === false) {
// No comma between this token and the last match arrow,
// so this token exists after the arrow and we can continue
// so this token exists after the arrow, and we can continue
// checking as normal.
$beforeArrow = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Filters/ExactMatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function accept()
/**
* Returns an iterator for the current entry.
*
* Ensures that the disallowed files list and the allowed files list are preserved so they don't have
* Ensures that the disallowed files list and the allowed files list are preserved, so they don't have
* to be generated each time.
*
* @return \RecursiveIterator
Expand Down
8 changes: 4 additions & 4 deletions src/Filters/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function accept()
/**
* Returns an iterator for the current entry.
*
* Ensures that the ignore patterns are preserved so they don't have
* Ensures that the ignore patterns are preserved, so they don't have
* to be generated each time.
*
* @return \RecursiveIterator
Expand All @@ -146,7 +146,7 @@ public function getChildren()
$this->ruleset
);

// Set the ignore patterns so we don't have to generate them again.
// Set the ignore patterns, so we don't have to generate them again.
$children->ignoreDirPatterns = $this->ignoreDirPatterns;
$children->ignoreFilePatterns = $this->ignoreFilePatterns;
$children->acceptedPaths = $this->acceptedPaths;
Expand All @@ -167,15 +167,15 @@ public function getChildren()
protected function shouldProcessFile($path)
{
// Check that the file's extension is one we are checking.
// We are strict about checking the extension and we don't
// We are strict about checking the extension, and we don't
// let files through with no extension or that start with a dot.
$fileName = basename($path);
$fileParts = explode('.', $fileName);
if ($fileParts[0] === $fileName || $fileParts[0] === '') {
return false;
}

// Checking multi-part file extensions, so need to create a
// Checking multipart file extensions, so need to create a
// complete extension list and make sure one is allowed.
$extensions = [];
array_shift($fileParts);
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function getTitle(DOMNode $doc)
/**
* Generates the documentation for a standard.
*
* It's probably wise for doc generators to override this method so they
* It's probably wise for doc generators to override this method, so they
* have control over how the docs are produced. Otherwise, the processSniff
* method should be overridden to output content for each sniff.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/HTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ protected function printToc()
*/
protected function printFooter()
{
// Turn off errors so we don't get timezone warnings if people
// Turn off errors, so we don't get timezone warnings if people
// don't have their timezone set.
$errorLevel = error_reporting(0);
echo ' <div class="tag-line">';
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function printHeader()
*/
protected function printFooter()
{
// Turn off errors so we don't get timezone warnings if people
// Turn off errors, so we don't get timezone warnings if people
// don't have their timezone set.
error_reporting(0);
echo 'Documentation generated on '.date('r');
Expand Down
4 changes: 2 additions & 2 deletions src/Generators/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function printCodeComparisonBlock(DOMNode $node)
foreach ($words as $word) {
if (strlen($tempTitle.$word) >= 45) {
if (strlen($tempTitle.$word) === 45) {
// Adding the extra space will push us to the edge
// Adding the extra space will push us to the edge,
// so we are done.
$firstTitleLines[] = $tempTitle.$word;
$tempTitle = '';
Expand Down Expand Up @@ -173,7 +173,7 @@ protected function printCodeComparisonBlock(DOMNode $node)
foreach ($words as $word) {
if (strlen($tempTitle.$word) >= 45) {
if (strlen($tempTitle.$word) === 45) {
// Adding the extra space will push us to the edge
// Adding the extra space will push us to the edge,
// so we are done.
$secondTitleLines[] = $tempTitle.$word;
$tempTitle = '';
Expand Down
2 changes: 1 addition & 1 deletion src/Reports/Cbf.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
}

if ($fixed === true) {
// The filename in the report may be truncated due to a basepath setting
// The filename in the report may be truncated due to a basepath setting,
// but we are using it for writing here and not display,
// so find the correct path if basepath is in use.
$newFilename = $report['filename'].$phpcsFile->config->suffix;
Expand Down
2 changes: 1 addition & 1 deletion src/Reports/Code.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
}

// Make sure the last token in the file sits on an imaginary
// last line so it is easier to generate code snippets at the
// last line, so it is easier to generate code snippets at the
// end of the file.
$lineTokens[$lastLine]['end'] = $stackPtr;

Expand Down
2 changes: 1 addition & 1 deletion src/Reports/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public function makeFriendlyName($name)
if ($i < ($length - 1)) {
$next = $name[($i + 1)];
if (strtolower($next) === $next) {
// Next char is lowercase so it is a word boundary.
// Next char is lowercase, so it is a word boundary.
$name[$i] = strtolower($name[$i]);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Ruleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public function explain()

$sniffCount = count($sniffs);

// Add a dummy entry to the end so we loop one last time
// Add a dummy entry to the end, so we loop one last time
// and echo out the collected info about the last standard.
$sniffs[] = '';

Expand Down Expand Up @@ -944,7 +944,7 @@ private function expandRulesetReference($ref, $rulesetDir, $depth=0)

if ($newRef === false) {
// The sniff is not locally installed, so check if it is being
// referenced as a remote sniff outside the install. We do this
// referenced as a remote sniff outside the installation. We do this
// by looking through all directories where we have found ruleset
// files before, looking for ones for this particular standard,
// and seeing if it is in there.
Expand Down Expand Up @@ -1321,7 +1321,7 @@ public function registerSniffs($files, $restrictions, $exclusions)
$listeners = [];

foreach ($files as $file) {
// Work out where the position of /StandardName/Sniffs/... is
// Work out where the position of /StandardName/Sniffs/... is,
// so we can determine what the class will be called.
$sniffPos = strrpos($file, DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR);
if ($sniffPos === false) {
Expand Down
10 changes: 5 additions & 5 deletions src/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function runPHPCS()
return 0;
}

// Other report formats don't really make sense in interactive mode
// Other report formats don't really make sense in interactive mode,
// so we hard-code the full report here and when outputting.
// We also ensure parallel processing is off because we need to do one file at a time.
if ($this->config->interactive === true) {
Expand All @@ -122,7 +122,7 @@ public function runPHPCS()
$toScreen = $this->reporter->printReports();

// Only print timer output if no reports were
// printed to the screen so we don't put additional output
// printed to the screen, so we don't put additional output
// in something like an XML report. If we are printing to screen,
// the report types would have already worked out who should
// print the timer info.
Expand Down Expand Up @@ -173,7 +173,7 @@ public function runPHPCBF()
// values the user has set.
$this->config = new Config();

// When processing STDIN, we can't output anything to the screen
// When processing STDIN, we can't output anything to the screen,
// or it will end up mixed in with the file output.
if ($this->config->stdin === true) {
$this->config->verbosity = 0;
Expand All @@ -182,7 +182,7 @@ public function runPHPCBF()
// Init the run and load the rulesets to set additional config vars.
$this->init();

// When processing STDIN, we only process one file at a time and
// When processing STDIN, we only process one file at a time, and
// we don't process all the way through, so we can't use the parallel
// running system.
if ($this->config->stdin === true) {
Expand Down Expand Up @@ -525,7 +525,7 @@ private function run()
$debugOutput = ob_get_contents();
ob_end_clean();

// Write information about the run to the filesystem
// Write information about the run to the filesystem,
// so it can be picked up by the main process.
$childOutput = [
'totalFiles' => $this->reporter->totalFiles,
Expand Down
10 changes: 5 additions & 5 deletions src/Sniffs/AbstractPatternSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class AbstractPatternSniff implements Sniff
private $parsedPatterns = [];

/**
* Tokens that this sniff wishes to process outside of the patterns.
* Tokens that this sniff wishes to process outside the patterns.
*
* @var int[]
* @see registerSupplementary()
Expand Down Expand Up @@ -337,7 +337,7 @@ protected function processPattern($patternInfo, File $phpcsFile, $stackPtr)
);

if ($next === false || isset($tokens[$next][$to]) === false) {
// If there was not opener, then we must be
// If there was no opener, then we must be
// using the wrong pattern.
return false;
}
Expand Down Expand Up @@ -430,7 +430,7 @@ protected function processPattern($patternInfo, File $phpcsFile, $stackPtr)
continue;
}

// If the next token is a comment, the we need to skip the
// If the next token is a comment, then we need to skip the
// current token as we should allow a space before a
// comment for readability.
if (isset($tokens[($stackPtr + 1)]) === true
Expand Down Expand Up @@ -598,7 +598,7 @@ protected function processPattern($patternInfo, File $phpcsFile, $stackPtr)
if ($next === false
|| isset($tokens[$next][$pattern[$i]['to']]) === false
) {
// If there was not opener, then we must
// If there was no opener, then we must
// be using the wrong pattern.
return false;
}
Expand Down Expand Up @@ -812,7 +812,7 @@ private function parse($pattern)
// if any, to the start of this special pattern.
if ($lastToken === 0) {
// Note that if the last special token was zero characters ago,
// there will be nothing to process so we can skip this bit.
// there will be nothing to process, so we can skip this bit.
// This happens if you have something like: EOL... in your pattern.
$str = '';
} else {
Expand Down
Loading