Skip to content

PHP Comprehensive Coverage #282

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

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d53a70b
Add redirects workflow
norareidy May 20, 2025
c5f7fd8
DOCSP-47058: Shift TOC (#251)
norareidy May 21, 2025
6bc8578
fix gh action
norareidy May 22, 2025
09d6e1b
DOCSP-47057: Network compression (#254)
norareidy May 23, 2025
96655ab
DOCSP-47055: Collation (#258)
norareidy May 29, 2025
6510515
DOCSP-47060: Causal consistency (#261)
norareidy Jun 3, 2025
9b5226b
Fix phpcs workflow
alcaeus Jun 3, 2025
030a3db
First fixes
alcaeus Jun 5, 2025
af46eea
Fix trailing commas
alcaeus Jun 5, 2025
817a1f6
Fix string quoting
alcaeus Jun 5, 2025
24cf864
Fix whitespace errors
alcaeus Jun 5, 2025
553e57d
Fix use statements
alcaeus Jun 5, 2025
5e7dc3f
Exclude sniff that would break comments
alcaeus Jun 5, 2025
902ea35
Fix multiline function declarations
alcaeus Jun 5, 2025
c9cdb9f
Fix wrong array indentation
alcaeus Jun 5, 2025
04729ef
Fix snake_case variable names
alcaeus Jun 5, 2025
3ffd674
Remove more false-positive errors
alcaeus Jun 5, 2025
3bef185
Fix control structure spacing
alcaeus Jun 5, 2025
fb1f8e0
Fix arrays
alcaeus Jun 5, 2025
c6e661f
Use property promotion
alcaeus Jun 5, 2025
e2abc50
Simplify multiline array rules
alcaeus Jun 5, 2025
440eb4e
Check code formatting (#265)
norareidy Jun 5, 2025
90a66cc
DOCSP-47059: Work with BSON (#263)
norareidy Jun 6, 2025
6094b72
DOCSP-50222: Reorganize auth pages (#266)
norareidy Jun 10, 2025
b236465
DOCSP-47065: Load balancing (#257)
norareidy Jun 10, 2025
99f0974
DOCSP-47056: Monitoring (#260)
norareidy Jun 10, 2025
1aea063
DOCSP-47071: Extended JSON (#268)
norareidy Jun 16, 2025
444d478
DOCSP-47072: Client parameters (#273)
norareidy Jun 17, 2025
83c6c62
DOCSP-47069: Polling SRV records (#274)
norareidy Jun 18, 2025
59aa88c
DOCSP-50753: agg tutorial link (#275)
rustagir Jun 23, 2025
7f8c17b
DOCSP-47063: Logging (#267)
norareidy Jun 23, 2025
8e52a11
DOCSP-50185: Connection troubleshooting (#272)
norareidy Jun 25, 2025
184797a
DOCSP-50220: Break up FAQ (#276)
norareidy Jun 25, 2025
90ce43c
DOCSP-50960: Install with pie (#278)
norareidy Jul 1, 2025
1af97bc
DOCSP-51123: CC edits and cleanup (#279)
norareidy Jul 2, 2025
68c225c
DOCSP-50772: isView() (#281)
rustagir Jul 3, 2025
cdf0009
Merge remote-tracking branch 'upstream/master' into comp-cov
norareidy Jul 3, 2025
fb1f852
phpcs
norareidy Jul 3, 2025
c4f9367
vale
norareidy Jul 3, 2025
548bf68
use toc labels/titles
norareidy Jul 7, 2025
59471b9
more titles
norareidy Jul 7, 2025
ed1795b
label
norareidy Jul 7, 2025
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/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ runs:
with:
php-version: ${{ inputs.php-version }}
extensions: "mongodb-${{ inputs.driver-version }}"
key: "extcache-v1"
key: "extcache-${{ inputs.driver-version }}"

- name: Cache extensions
uses: actions/cache@v4
Expand Down
133 changes: 133 additions & 0 deletions .github/workflows/add-redirects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Verify Redirects

on:
pull_request_target:

jobs:
verify-redirects:
name: Verifying Redirects
runs-on: ubuntu-latest
env:
REDIRECTS_FILE: "pr/config/redirects"
permissions:
pull-requests: write
steps:
- name: Check Out Base Branch
uses: actions/checkout@v4

- name: Checkout PR Head Branch
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
path: pr

- name: Get Changed Files
id: changed-files
uses: tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c
with:
include_all_old_new_renamed_files: true

- name: Find Missing Redirects for Renamed Files
id: renamed-files
if: steps.changed-files.outputs.renamed_files_count > 0
env:
RENAMED_FILES: ${{ steps.changed-files.outputs.all_old_new_renamed_files }}
run: |
renamed_redirects=""

for file in $RENAMED_FILES; do

# only run for .txt files
if [[ ! "$file" == *.txt ]]; then
continue
fi

# format old and new URLs
old=$(echo "$file" | cut -d',' -f1)
old="${old#source}"
old="${old%.txt}"
new=$(echo "$file" | cut -d',' -f2)
new="${new#source}"
new="${new%.txt}"

redirect='${prefix}/${version}'"$old"'/ -> ${base}/${version}'"$new"'/'

# if redirect not already in file, add to string to add to PR description
if ! grep -q "$redirect" $REDIRECTS_FILE; then
renamed_redirects+="<li>[&lt;v&gt;-*]: $redirect</li>"
fi
done

echo "redirects=${renamed_redirects}" >> "$GITHUB_OUTPUT"

- name: Find Missing Redirects for Deleted Files
id: deleted-files
if: steps.changed-files.outputs.deleted_files_count > 0
env:
DELETED_FILES: ${{ steps.changed-files.outputs.deleted_files }}
run: |
deleted_redirects=""

for file in $DELETED_FILES; do

# only run for .txt files
if [[ ! "$file" == *.txt ]]; then
continue
fi

# format old URL
old=$(echo "$file" | cut -d',' -f1)
old="${old#source}"
old="${old%.txt}"

redirect='${prefix}/${version}'"$old"'/ -> ${base}/${version}/'

# escape special characters before searching for string
escaped_redirect=$(printf '%s\n' "$redirect" | sed 's/[[*${}|\\]/\\&/g')

# if redirect not already in file, add to string to add to PR description
if ! grep -qE "${escaped_redirect}$" $REDIRECTS_FILE; then
deleted_redirects+="<li>[&lt;v&gt;-*]: $redirect</li>"
fi
done

echo "redirects=${deleted_redirects}" >> "$GITHUB_OUTPUT"

- name: Build Redirect HTML
id: build-redirect-html
env:
RENAMED_REDIRECTS: ${{ steps.renamed-files.outputs.redirects }}
DELETED_REDIRECTS: ${{ steps.deleted-files.outputs.redirects }}
run: |
redirect_html=''
combined_redirects="${RENAMED_REDIRECTS}${DELETED_REDIRECTS}"

if [ -n "$combined_redirects" ]; then
redirect_html="<h3>Suggested redirects for moved, renamed, and deleted files:</h3><p><em>Replace &lt;v&gt; with the earliest backport target version</p></em>$combined_redirects"
fi

echo "redirect_html=${redirect_html}" >> "$GITHUB_OUTPUT"

- name: Update PR Description
uses: MongoCaleb/pr-description-action@4bdfe35b98f64532b419ad20b350a92546cd3aa1
with:
regex: "- \\[( |x)\\] Did you add redirects\\?.*"
appendContentOnMatchOnly: false
regexFlags: is
content: "- [ ] Did you add redirects?\n ${{ steps.build-redirect-html.outputs.redirect_html }}"
token: ${{ secrets.GITHUB_TOKEN }}

- name: Check for duplicates in redirects file
run: |
if [[ -f "$REDIRECTS_FILE" ]]; then
duplicates=$(sort "$REDIRECTS_FILE" | uniq -d)
if [[ -n "$duplicates" ]]; then
echo "Duplicate lines found in $REDIRECTS_FILE:"
echo "$duplicates"
exit 1 # error
fi
else
"Redirects file doesn't exist. Skipping duplicate check."
fi
1 change: 1 addition & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- "source/**/*.php"
- ".github/workflows/*.yml"
- ".github/actions/**"

env:
PHP_VERSION: "8.2"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- "source/**/*.php"
- ".github/workflows/*.yml"
- ".github/actions/**"
workflow_call:
inputs:
ref:
Expand Down
2 changes: 1 addition & 1 deletion composer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
}
40 changes: 37 additions & 3 deletions config/redirects
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ raw: ${prefix}/stable -> ${base}/current/
# redirects in standardized docs
[v1.20-*]: ${prefix}/${version}/tutorial/install-php-library/ -> ${base}/${version}/get-started/
[v1.20-*]: ${prefix}/${version}/tutorial/connecting/ -> ${base}/${version}/connect/
[v1.20-*]: ${prefix}/${version}/tutorial/server-selection/ -> ${base}/${version}/monitoring/cluster-monitoring/
[v1.20-*]: ${prefix}/${version}/tutorial/server-selection/ -> ${base}/${version}/monitoring-logging/monitoring/
[v1.20-*]: ${prefix}/${version}/tutorial/crud/ -> ${base}/${version}/read/
[v1.20-*]: ${prefix}/${version}/tutorial/codecs/ -> ${base}/${version}/data-formats/codecs/
[v1.20-*]: ${prefix}/${version}/tutorial/collation/ -> ${base}/${version}/
Expand All @@ -45,7 +45,7 @@ raw: ${prefix}/stable -> ${base}/current/
# note: this mapping does not account for all of the new pages
[*-v1.19]: ${prefix}/${version}/tutorial/install-php-library/ -> ${base}/v1.x/get-started/
[*-v1.19]: ${prefix}/${version}/tutorial/connecting/ -> ${base}/v1.x/connect/
[*-v1.19]: ${prefix}/${version}/tutorial/server-selection/ -> ${base}/v1.x/monitoring/cluster-monitoring/
[*-v1.19]: ${prefix}/${version}/tutorial/server-selection/ -> ${base}/v1.x/monitoring-logging/monitoring/
[*-v1.19]: ${prefix}/${version}/tutorial/crud/ -> ${base}/v1.x/read/
[*-v1.19]: ${prefix}/${version}/tutorial/codecs/ -> ${base}/v1.x/data-formats/codecs/
[*-v1.19]: ${prefix}/${version}/tutorial/collation/ -> ${base}/v1.x/
Expand All @@ -59,4 +59,38 @@ raw: ${prefix}/stable -> ${base}/current/
[*-v1.19]: ${prefix}/${version}/tutorial/example-data/ -> ${base}/v1.x/
[*-v1.19]: ${prefix}/${version}/tutorial/modeling-bson-data/ -> ${base}/v1.x/data-formats/modeling-bson-data/
[*-v1.19]: ${prefix}/${version}/tutorial/stable-api/ -> ${base}/v1.x/stable-api/
[*-v1.19]: ${prefix}/${version}/tutorial/aws-lambda/ -> ${base}/v1.x/aws-lambda/
[*-v1.19]: ${prefix}/${version}/tutorial/aws-lambda/ -> ${base}/v1.x/aws-lambda/

# comprehensive coverage redirects
[*-master]: ${prefix}/${version}/aggregation/atlas-search/ -> ${base}/${version}/atlas-search/
[*-master]: ${prefix}/${version}/aws-lambda/ -> ${base}/${version}/connect/aws-lambda/
[*-master]: ${prefix}/${version}/connect/stable-api/ -> ${base}/${version}/connect/connection-options/stable-api/
[*-master]: ${prefix}/${version}/builders/ -> ${base}/${version}/crud/builders/
[*-master]: ${prefix}/${version}/write/bulk-write/ -> ${base}/${version}/crud/bulk-write/
[*-master]: ${prefix}/${version}/write/delete/ -> ${base}/${version}/crud/delete/
[*-master]: ${prefix}/${version}/write/gridfs/ -> ${base}/${version}/crud/gridfs/
[*-master]: ${prefix}/${version}/write/insert/ -> ${base}/${version}/crud/insert/
[*-master]: ${prefix}/${version}/read/count/ -> ${base}/${version}/crud/query/count/
[*-master]: ${prefix}/${version}/read/cursor/ -> ${base}/${version}/crud/query/cursor/
[*-master]: ${prefix}/${version}/read/distinct/ -> ${base}/${version}/crud/query/distinct/
[*-master]: ${prefix}/${version}/read/project/ -> ${base}/${version}/crud/query/project/
[*-master]: ${prefix}/${version}/read/retrieve/ -> ${base}/${version}/crud/query/retrieve/
[*-master]: ${prefix}/${version}/read/specify-a-query/ -> ${base}/${version}/crud/query/specify-a-query/
[*-master]: ${prefix}/${version}/read/specify-documents-to-return/ -> ${base}/${version}/crud/query/specify-documents-to-return/
[*-master]: ${prefix}/${version}/read-write-pref/ -> ${base}/${version}/crud/read-write-pref/
[*-master]: ${prefix}/${version}/write/replace/ -> ${base}/${version}/crud/replace/
[*-master]: ${prefix}/${version}/write/transaction/ -> ${base}/${version}/crud/transaction/
[*-master]: ${prefix}/${version}/write/update/ -> ${base}/${version}/crud/update/
[*-master]: ${prefix}/${version}/data-formats/codecs/ -> ${base}/${version}/data-formats/custom-types/codecs/
[*-master]: ${prefix}/${version}/databases-collections/time-series/ -> ${base}/${version}/data-formats/time-series/
[*-master]: ${prefix}/${version}/read/change-streams/ -> ${base}/${version}/monitoring-logging/change-streams/
[*-master]: ${prefix}/${version}/monitoring/cluster-monitoring/ -> ${base}/${version}/monitoring-logging/monitoring/
[*-master]: ${prefix}/${version}/compatibility/ -> ${base}/${version}/references/compatibility/
[*-master]: ${prefix}/${version}/whats-new/ -> ${base}/${version}/references/release-notes/
[*-master]: ${prefix}/${version}/upgrade/ -> ${base}/${version}/references/upgrade/
[*-master]: ${prefix}/${version}/connect/tls/ -> ${base}/${version}/security/tls/
[*-master]: ${prefix}/${version}/aggregation/vector-search/ -> ${base}/${version}/vector-search/
[*-master]: ${prefix}/${version}/monitoring/ -> ${base}/${version}/monitoring-logging/
[*-master]: ${prefix}/${version}/read/ -> ${base}/${version}/crud/
[*-master]: ${prefix}/${version}/write/ -> ${base}/${version}/crud/
[*-master]: ${prefix}/${version}/faq/ -> ${base}/${version}/
119 changes: 119 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?xml version="1.0"?>
<ruleset>
<arg name="basepath" value="." />
<arg name="extensions" value="php" />
<arg name="parallel" value="80" />
<arg name="cache" value=".phpcs-cache" />
<arg name="colors" />

<!-- Ignore warnings (n), show progress of the run (p), and show sniff names (s) -->
<arg value="nps"/>

<file>source</file>

<!-- Target minimum supported PHP version -->
<config name="php_version" value="80100"/>

<!-- ****************************************** -->
<!-- Import rules from doctrine/coding-standard -->
<!-- ****************************************** -->
<rule ref="Doctrine">
<!-- ******************************************** -->
<!-- Exclude sniffs we simply don't want for docs -->
<!-- ******************************************** -->
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly" />
<exclude name="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps" />
<!-- Results in false positives with comments used to denote include blocks -->
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountAfterControlStructure" />
<exclude name="Squiz.Classes.ClassFileName.NoMatch" />
<!-- Results in false positives with comments used to denote include blocks before functions -->
<exclude name="Squiz.Commenting.FunctionComment.WrongStyle" />
<!-- Results in false positives with comments used to denote include blocks after functions -->
<exclude name="Squiz.WhiteSpace.FunctionSpacing.After" />
<!-- The following three excludes allow for more compact single-item array declarations -->
<exclude name="Squiz.Arrays.ArrayDeclaration.IndexNoNewline" />
<exclude name="Generic.Arrays.ArrayIndent.CloseBraceNotNewLine" />
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNewLine" />

<!-- *********************************** -->
<!-- Exclude sniffs that cause BC breaks -->
<!-- *********************************** -->
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming" />
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming" />
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming" />
<exclude name="SlevomatCodingStandard.Classes.SuperfluousTraitNaming" />

<!-- Can cause subtle BC breaks -->
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes" />


<!-- **************************************** -->
<!-- Exclude sniffs that force unwanted style -->
<!-- **************************************** -->
<exclude name="Generic.Formatting.MultipleStatementAlignment" />
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNoFullStop" />
<exclude name="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat.DisallowedShortNullable" />

<!-- Keep long typehints (for now) -->
<exclude name="PSR12.Keywords.ShortFormTypeKeywords" />
<exclude name="SlevomatCodingStandard.PHP.TypeCast.InvalidCastUsed" />
<exclude name="SlevomatCodingStandard.TypeHints.LongTypeHints" />


<!-- ************************************************ -->
<!-- Exclude sniffs that may cause functional changes -->
<!-- ************************************************ -->
<exclude name="Generic.PHP.ForbiddenFunctions.FoundWithAlternative" />
<exclude name="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison" />
<exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit" />
<exclude name="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn" />
<exclude name="SlevomatCodingStandard.Functions.StaticClosure" />
<exclude name="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure" />
<exclude name="SlevomatCodingStandard.Operators.DisallowEqualOperators" />


<!-- ********************************************************* -->
<!-- Exclude sniffs that cause a huge diff - enable separately -->
<!-- ********************************************************* -->
<exclude name="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectAnnotationsGroup" />


<!-- ********************* -->
<!-- Exclude broken sniffs -->
<!-- ********************* -->

<!-- Sniff currently broken when casting arrays, see https://github.com/squizlabs/PHP_CodeSniffer/issues/2937#issuecomment-615498860 -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNoNewline" />

<!-- Disable forbidden annotation sniff as excluding @api from the list doesn't work -->
<exclude name="SlevomatCodingStandard.Commenting.ForbiddenAnnotations.AnnotationForbidden" />
</rule>


<!-- **************************************** -->
<!-- Enable rules not enforced by Doctrine CS -->
<!-- **************************************** -->

<!-- Require arrow functions where possible -->
<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction"/>


<!-- ****************************************************** -->
<!-- Don't require annotations to specify traversable types -->
<!-- ****************************************************** -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification" />
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification" />
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" />
</rule>

<rule ref="Generic.Files.InlineHTML.Found">
<exclude-pattern>source/includes/aws-lambda/index.php</exclude-pattern>
</rule>

</ruleset>
10 changes: 5 additions & 5 deletions snooty.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ toc_landing_pages = [
"/reference/class/MongoDBModelDatabaseInfo",
"/reference/class/MongoDBModelIndexInfo",
"/connect",
"/read",
"/databases-collections",
"/write",
"/connect/connection-options/",
"/aggregation",
"/data-formats",
"/data-formats/custom-types",
"/indexes",
"/security",
"/data-formats",
"/upgrade",
"/aggregation",
"/security/authentication",
]

sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/"
Expand Down
Loading
Loading