com php-langspec: Improve check_refs: spec/07-variabl es.md tools/check_refs.php
| From: | Nikita Popov | Date: | Tue, 15 Nov 2016 21:44:02 +0000 |
| Subject: | com php-langspec: Improve check_refs: spec/07-variabl es.md tools/check_refs.php | ||
| Groups: | php.standards.cvs | ||
| Request: | Send a blank email to standards--cvs+get-364@lists.php.net to get a copy of this message | ||
Commit: 0fd1786650afcdd580d02a8cca535fdf4d33a27e
Author: Nikita Popov <nikic@php.net> Tue, 15 Nov 2016 22:38:27 +0100
Parents: 883396eb050375ad973b25c1142bf015b5e3adb2
Branches: master
Link: http://git.php.net/?p=php-langspec.git;a=commitdiff;h=0fd1786650afcdd580d02a8cca535fdf4d33a27e
Log:
Improve check_refs
Handle manual anchor. Return exit code.
Changed paths:
M spec/07-variables.md
M tools/check_refs.php
Diff:
diff --git a/spec/07-variables..md b/spec/07-variables.md
index 6e59bf4..3fa4cb7 100644
--- a/spec/07-variables.md
+++ b/spec/07-variables.md
@@ -153,7 +153,7 @@ Since undefined local variables are not defined implicitly, they stay undefined.
*byRef Context*
-If the undefined variable is used in a [byRef context](04-basic-concepts#byRef) then PHP defines
the variable implicitly. Hence, a VSlot is created for it and
NULL is stored in it. A
notice is *not* emitted in such a case.
+If the undefined variable is used in a byRef context then PHP defines the variable implicitly.
Hence, a VSlot is created for it and NULL is stored in it. A notice is *not* emitted in
such a case.
*Examples of Undefined Variables*
diff --git a/tools/check_refs.php b/tools/check_refs.php
index eab817c..aede04a 100644
--- a/tools/check_refs.php
+++ b/tools/check_refs.php
@@ -10,9 +10,18 @@ foreach (spec_files() as $fileName => $path) {
$fullAnchor = $fileName . '#' . $info['anchor'];
$anchors[$fullAnchor] = true;
}
+
+ // Collect manual anchors as well
+ if (preg_match_all('/<a name="([^"]+)">/', $contents, $matches))
{
+ foreach ($matches[1] as $anchor) {
+ $fullAnchor = $fileName . '#' . $anchor;
+ $anchors[$fullAnchor] = true;
+ }
+ }
}
// Find unknown anchor references
+$foundUnknown = false;
foreach (spec_files() as $fileName => $path) {
$contents = file_get_contents($path);
@@ -33,7 +42,10 @@ foreach (spec_files() as $fileName => $path) {
}
if (!isset($anchors[$anchor])) {
+ $foundUnknown = true;
echo "Unknown anchor $anchor in $fileName\n";
}
}
}
+
+exit($foundUnknown ? 1 : 0);