com php-langspec: Improve check_refs: spec/07-variabl es.md tools/check_refs.php
[email protected] (Nikita Popov) Tue, 15 Nov 2016 21:44:02 +0000
| Newsgroups | php.standards.cvs |
|---|---|
| Message-ID | <[email protected]> |
Commit: 0fd1786650afcdd580d02a8cca535fdf4d33a27e=0AAuthor: Nikita Pop= ov <[email protected]> Tue, 15 Nov 2016 22:38:27 +0100=0AParents: 883= 396eb050375ad973b25c1142bf015b5e3adb2=0ABranches: master=0A=0ALink: = http://git.php.net/?p=3Dphp-langspec.git;a=3Dcommitdiff;h=3D0fd1786650afcdd= 580d02a8cca535fdf4d33a27e=0A=0ALog:=0AImprove check_refs=0A=0AHandle manual= anchor. Return exit code.=0A=0AChanged paths:=0A M spec/07-variables.md= =0A M tools/check_refs.php=0A=0A=0ADiff:=0Adiff --git a/spec/07-variables= .md b/spec/07-variables.md=0Aindex 6e59bf4..3fa4cb7 100644=0A--- a/spec/07-= variables.md=0A+++ b/spec/07-variables.md=0A@@ -153,7 +153,7 @@ Since undef= ined local variables are not defined implicitly, they stay undefined.=0A = =0A *byRef Context*=0A =0A-If the undefined variable is used in a [byRef co= ntext](04-basic-concepts#byRef) then PHP defines the variable implicitly. H= ence, a VSlot is created for it and `NULL` is stored in it. A notice is *no= t* emitted in such a case.=0A+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 cas= e.=0A =0A *Examples of Undefined Variables*=0A =0Adiff --git a/tools/check_= refs.php b/tools/check_refs.php=0Aindex eab817c..aede04a 100644=0A--- a/too= ls/check_refs.php=0A+++ b/tools/check_refs.php=0A@@ -10,9 +10,18 @@ foreach= (spec_files() as $fileName =3D> $path) {=0A $fullAnchor =3D $fileN= ame . '#' . $info['anchor'];=0A $anchors[$fullAnchor] =3D true;=0A = }=0A+=0A+ // Collect manual anchors as well=0A+ if (preg_match_al= l('/<a name=3D"([^"]+)">/', $contents, $matches)) {=0A+ foreach ($ma= tches[1] as $anchor) {=0A+ $fullAnchor =3D $fileName . '#' . $an= chor;=0A+ $anchors[$fullAnchor] =3D true;=0A+ }=0A+ }= =0A }=0A =0A // Find unknown anchor references=0A+$foundUnknown =3D false;= =0A foreach (spec_files() as $fileName =3D> $path) {=0A $contents =3D f= ile_get_contents($path);=0A =0A@@ -33,7 +42,10 @@ foreach (spec_files() as = $fileName =3D> $path) {=0A }=0A =0A if (!isset($anchors[$an= chor])) {=0A+ $foundUnknown =3D true;=0A echo "Unkno= wn anchor $anchor in $fileName\n";=0A }=0A }=0A }=0A+=0A+exit($= foundUnknown ? 1 : 0);=0A