Skip to content

Fixes the "Display full permissions" example using fileperms. - #5842

Merged
lacatoire merged 2 commits into
php:masterfrom
brcontainer:patch-1
Sep 8, 2026
Merged

lacatoire merged 2 commits into
php:masterfrom
brcontainer:patch-1

Conversation

@brcontainer

@brcontainer brcontainer commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

In the regular file example, you are using r, when you should be using -:

case 0x8000: // regular
    $info = 'r';

This is according to ls -l:

Character 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:

Image

Another problem is that the use of fileperms() will never utilize this:

case 0xA000: // symbolic link
    $info = 'l';

Test:

$ 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.

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.
@lacatoire

Copy link
Copy Markdown
Member

Well done @brcontainer ;)

@lacatoire
lacatoire merged commit f5c4950 into php:master Sep 8, 2026
2 checks passed
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--
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants