php / php/doc-en

Inconsistency about ::class and literal strings

Open
#1,646 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Category: Engine Status: Needs Triage
Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

Description

This doesn't work (https://3v4l.org/MM1pJ):

<?php

$foo = 'Foo';
var_dump($foo::class);

But this does (https://3v4l.org/Rb3oU)

<?php

var_dump('Foo'::class);

Is this intentional? I'd say both or neither should be supported.

PHP Version

Irrelevant

Operating System

N/A

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two PHP examples at the linked 3v4l.org pages and compare the documentation for ::class and literal strings. Determine whether the differing behavior is intentional, then document the rule consistently; done means the documentation clearly explains both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.