Fixes the "Display full permissions" example using fileperms. - #5842
Merged
Merged
Conversation
In the *regular file* example, you are using `r`, when you should be using `-`:
```php
case 0x8000: // regular
$info = 'r';
```
This is according to `ls -l`:
| Indicador | Description |
| --- | --- |
| `-` | regular |
| `d` | directory |
| `l` | symbolic link |
| `c` | character device |
| `b` | block device |
| `p` | FIFO |
| `s` | socket |
The page states that the output of the code for `/etc/passwd` is:
```
-rw-r--r--
```
However, I obtained this:
<img width="476" height="106" alt="Image" src="https://github.com/user-attachments/assets/903f045f-6d96-45f0-9142-9fa601ccf924" />
Another problem is that the use of `fileperms()` will never utilize this:
```php
case 0xA000: // symbolic link
$info = 'l';
```
Test:
```bash
$ ln -s sample.txt samplelnk.txt
$ ls -l samplelnk.txt
lrwxrwxrwx 1 Brcontainer Brcontainer 10 Sep 7 16:46 samplelnk.txt -> sample.txt
```
Whereas in PHP (`$perms = fileperms('samplelnk.txt');`), I got this: `-rw-r--r--`.
Therefore, the snippet for the example is essentially _dead code_. I don't think this section needs to be removed, but it would be important to document it to avoid confusion.
> Note: In the code, I kept the parentheses solely to aid readability and understanding.
Member
|
Well done @brcontainer ;) |
brcontainer
added a commit
to brcontainer/doc-de
that referenced
this pull request
Sep 8, 2026
Same as: php/doc-en#5842 Incorrect: ```php case 0x8000: // regular $info = 'r'; ```
brcontainer
added a commit
to brcontainer/doc-es
that referenced
this pull request
Sep 8, 2026
Same as: php/doc-en#5842 Incorrect: ```php case 0x8000: // regular $info = 'r'; ```
brcontainer
added a commit
to brcontainer/doc-fr
that referenced
this pull request
Sep 8, 2026
Same as: php/doc-en#5842 Incorrect: ```php case 0x8000: // regular $info = 'r'; ```
brcontainer
added a commit
to brcontainer/doc-it
that referenced
this pull request
Sep 8, 2026
Same as: php/doc-en#5842 Incorrect: ```php case 0x8000: // regular $info = 'r'; ```
brcontainer
added a commit
to brcontainer/doc-ja
that referenced
this pull request
Sep 8, 2026
Same as: php/doc-en#5842 Incorrect: ```php case 0x8000: // regular $info = 'r'; ```
brcontainer
added a commit
to brcontainer/doc-pt_br
that referenced
this pull request
Sep 8, 2026
Same as: php/doc-en#5842 Incorrect: ```php case 0x8000: $info = 'r'; ```
brcontainer
added a commit
to brcontainer/doc-ru
that referenced
this pull request
Sep 8, 2026
Same as: php/doc-en#5842 Incorrect: ```php case 0x8000: $info = 'r'; ```
KentarouTakeda
pushed a commit
to php/doc-ja
that referenced
this pull request
Sep 8, 2026
* Fixes Example #2 using fileperms Same as: php/doc-en#5842 Incorrect: ```php case 0x8000: // regular $info = 'r'; ``` * EN-Revision
PhilDaiguille
pushed a commit
to php/doc-es
that referenced
this pull request
Sep 8, 2026
* Fixes Example #2 using fileperms Same as: php/doc-en#5842 Incorrect: ```php case 0x8000: // regular $info = 'r'; ``` * Update fileperms.xml with additional file types * Refactor file permissions switch case comments Updated comments in fileperms.xml to Spanish and removed unknown case. * EN-Revision * Fix representation of regular file type in XML
brcontainer
added a commit
to brcontainer/doc-tr
that referenced
this pull request
Sep 8, 2026
Same as: php/doc-en#5842 Incorrect: ```php case 0x8000: $info = 'r'; ```
brcontainer
added a commit
to brcontainer/doc-zh
that referenced
this pull request
Sep 8, 2026
Same as: php/doc-en#5842 Incorrect: ```php case 0x8000: $info = 'r'; ```
KentarouTakeda
pushed a commit
to php/doc-ja
that referenced
this pull request
Sep 8, 2026
* Fixes Example #2 using fileperms Same as: php/doc-en#5842 Incorrect: ```php case 0x8000: // regular $info = 'r'; ``` * EN-Revision * Change file type representation from 'r' to '-'
mmalferov
added a commit
to php/doc-ru
that referenced
this pull request
Sep 9, 2026
* Fixes Example #2 using fileperms Same as: php/doc-en#5842 Incorrect: ```php case 0x8000: $info = 'r'; ``` * EN-Revision * Reorder file type cases in fileperms function * Update fileperms.xml --------- Co-authored-by: Mikhail Alferov <malferov@gmail.com>
brcontainer
added a commit
to brcontainer/doc-tr
that referenced
this pull request
Sep 10, 2026
Same as: php/doc-en#5842; Incorrect: ```php case 0x8000: // regular $info = 'r'; ``` The output in the example for `etc/password` should be: ``` -rw-r--r-- ``` But what is obtained is: ``` rrw-r--r-- ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the regular file example, you are using
r, when you should be using-:This is according to
ls -l:-dlcbpsThe page states that the output of the code for
/etc/passwdis:However, I obtained this:
Another problem is that the use of
fileperms()will never utilize this:Test:
$ ln -s sample.txt samplelnk.txt $ ls -l samplelnk.txt lrwxrwxrwx 1 Brcontainer Brcontainer 10 Sep 7 16:46 samplelnk.txt -> sample.txtWhereas in PHP (
$perms = fileperms('samplelnk.txt');), I got this:-rw-r--r--.Therefore, the snippet for the example is essentially dead code. I don't think this section needs to be removed, but it would be important to document it to avoid confusion.