Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6655533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:31:54+00:00 2026-05-26T01:31:54+00:00

I have an object User that has attributes whose accessability is declared as protected

  • 0

I have an object “User” that has attributes whose accessability is declared as protected but which can be set directly via a magic __set-method.

enter image description here

Now PhpStorm signals this apparent inconsistency with a big red column on the right side.

Is it possible to explain to PhpStorm what is going on so this is not shown as an error any more?


EDIT :

I use PhpStorm 2.1.4

okay here is some code that exemplifies the issue (together with the so far suggested workaround from Alexey which sadly doesn’t do it for me):

c.php:

<?php
/**
 * @property mixed $a
 */
class c1
{
    protected $a;

    public function __construct() { $this->a = __CLASS__; }

    public function __get($n) { return $this->{$n}; }
}

/**
 * @property $a mixed
 */
class c2
{
    protected $a;

    public function __construct() { $this->a = __CLASS__; }

    public function __get($n) { return $this->{$n}; }
}

test.php

<?php
require "c.php";

$c1 = new c1();
var_dump($c1->a);

$c2 = new c2();
var_dump($c2->a);

and the output:

string 'c1' (length=2)
string 'c2' (length=2)

and how it looks like in PhpStorm:

enter image description here

my goal:

either having PhpStorm “understand” the design or just getting rid of those annoying red marks everywhere while not impairing the error detection apart from this issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:31:54+00:00Added an answer on May 26, 2026 at 1:31 am

    This is now working in PHPStorm 3 🙂

    Unfortunately this is a open request in our tracker, see
    http://youtrack.jetbrains.net/issue/WI-4468

    The only way to avoid this warnings now, is to add @property to $user’s class declaration. i.e.

    /**
     * @property $name string
     */
    class User {
        protected $name; 
    }
    $user = new User();
    $user->name = "me";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an User object that has many attributes. In my edit profile screen
I have a project that requires user-defined attributes for a particular object at runtime
I have a function that loads a user object from a web service asynchronously.
I have a NSTimer object that I need to invalidate if a user taps
I have the following code that loads a user's Active Directory DirectoryEntry object from
I have a form that is bind to an object, and when the user
I have an application where for each object the user can specify his own
I have a script which creates a user-defined object like this: obj = new
i have a User with attributes User.id i have an object with Object.id, Object.name
I have form object that I set to request in GET request handler in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.