Access to an undefined property object::$credits
97 <td><?php echo htmlspecialchars($txn->payer_email) ?></td>
98 <td><?php echo htmlspecialchars($txn->mc_gross) ?></td>
99 <td><?php echo htmlspecialchars($txn->mc_currency) ?></td>
100 <td><?php echo number_format($txn->credits) ?></td>101 </tr>
102 <?php else: ?>
103 <tr>
Access to an undefined property object::$mc_currency
96 <td><?php echo $this->formatDateTime($txn->payment_date) ?></td>
97 <td><?php echo htmlspecialchars($txn->payer_email) ?></td>
98 <td><?php echo htmlspecialchars($txn->mc_gross) ?></td>
99 <td><?php echo htmlspecialchars($txn->mc_currency) ?></td>100 <td><?php echo number_format($txn->credits) ?></td>
101 </tr>
102 <?php else: ?>
Access to an undefined property object::$mc_gross
95 <td><?php echo htmlspecialchars($txn->txn_id) ?></td>
96 <td><?php echo $this->formatDateTime($txn->payment_date) ?></td>
97 <td><?php echo htmlspecialchars($txn->payer_email) ?></td>
98 <td><?php echo htmlspecialchars($txn->mc_gross) ?></td> 99 <td><?php echo htmlspecialchars($txn->mc_currency) ?></td>
100 <td><?php echo number_format($txn->credits) ?></td>
101 </tr>
Access to an undefined property object::$payer_email
94 <tr>
95 <td><?php echo htmlspecialchars($txn->txn_id) ?></td>
96 <td><?php echo $this->formatDateTime($txn->payment_date) ?></td>
97 <td><?php echo htmlspecialchars($txn->payer_email) ?></td> 98 <td><?php echo htmlspecialchars($txn->mc_gross) ?></td>
99 <td><?php echo htmlspecialchars($txn->mc_currency) ?></td>
100 <td><?php echo number_format($txn->credits) ?></td>
Access to an undefined property object::$payment_date
93 ?>
94 <tr>
95 <td><?php echo htmlspecialchars($txn->txn_id) ?></td>
96 <td><?php echo $this->formatDateTime($txn->payment_date) ?></td> 97 <td><?php echo htmlspecialchars($txn->payer_email) ?></td>
98 <td><?php echo htmlspecialchars($txn->mc_gross) ?></td>
99 <td><?php echo htmlspecialchars($txn->mc_currency) ?></td>
Access to an undefined property object::$credits
23 <td><?php echo htmlspecialchars($txn->payer_email) ?></td>
24 <td><?php echo htmlspecialchars($txn->mc_gross) ?></td>
25 <td><?php echo htmlspecialchars($txn->mc_currency) ?></td>
26 <td><?php echo number_format($txn->credits) ?></td> 27 </tr>
28 <?php else: ?>
29 <tr>
Access to an undefined property object::$mc_currency
22 <td><?php echo $this->formatDateTime($txn->payment_date) ?></td>
23 <td><?php echo htmlspecialchars($txn->payer_email) ?></td>
24 <td><?php echo htmlspecialchars($txn->mc_gross) ?></td>
25 <td><?php echo htmlspecialchars($txn->mc_currency) ?></td> 26 <td><?php echo number_format($txn->credits) ?></td>
27 </tr>
28 <?php else: ?>
Access to an undefined property object::$mc_gross
21 <td><?php echo htmlspecialchars($txn->txn_id) ?></td>
22 <td><?php echo $this->formatDateTime($txn->payment_date) ?></td>
23 <td><?php echo htmlspecialchars($txn->payer_email) ?></td>
24 <td><?php echo htmlspecialchars($txn->mc_gross) ?></td> 25 <td><?php echo htmlspecialchars($txn->mc_currency) ?></td>
26 <td><?php echo number_format($txn->credits) ?></td>
27 </tr>
Access to an undefined property object::$payer_email
20 <tr>
21 <td><?php echo htmlspecialchars($txn->txn_id) ?></td>
22 <td><?php echo $this->formatDateTime($txn->payment_date) ?></td>
23 <td><?php echo htmlspecialchars($txn->payer_email) ?></td> 24 <td><?php echo htmlspecialchars($txn->mc_gross) ?></td>
25 <td><?php echo htmlspecialchars($txn->mc_currency) ?></td>
26 <td><?php echo number_format($txn->credits) ?></td>
Access to an undefined property object::$payment_date
19 ?>
20 <tr>
21 <td><?php echo htmlspecialchars($txn->txn_id) ?></td>
22 <td><?php echo $this->formatDateTime($txn->payment_date) ?></td> 23 <td><?php echo htmlspecialchars($txn->payer_email) ?></td>
24 <td><?php echo htmlspecialchars($txn->mc_gross) ?></td>
25 <td><?php echo htmlspecialchars($txn->mc_currency) ?></td>
Access to an undefined property Flux_StripeNotifyRequest::$webhookSecret
126 */
127 public function process()
128 {
129 if (!$this->verifyHeader($this->payload, $this->sigHeader, $this->webhookSecret, $this->DEFAULT_TOLERANCE)) {130 http_response_code(400);
131 return;
132 }
Access to an undefined property Flux_StripeNotifyRequest::$logStripe
115 protected function logStripe()
116 {
117 $args = func_get_args();
118 $func = array($this->logStripe, 'puts');119 return call_user_func_array($func, $args);
120 }
121
Access to an undefined property Flux_DataObject::$account_id
6}
7
8$session = Flux::$sessionData;
9$customDataArray = array('server_name' => $session->loginAthenaGroup->serverName, 'account_id' => $session->account->account_id);10$customDataEscaped = htmlspecialchars(base64_encode(serialize($customDataArray)));
11?>
12<link rel="stylesheet" href="<?php echo $this->themePath('css/stripe.css') ?>" type="text/css" media="screen" title="" charset="utf-8" />
Description
The property you are trying to access is not defined and will cause unexpected behavior when used.
This issue will be raised in the following cases:
- An undefined property is accessed.
- A private property from a parent class is accessed.
- A protected property of an instance of a class is accessed.
- The variable whose property is being accessed is not an instance of a class, or is not defined.
- Using properties via
__get()
or__set()
magic methods.
Bad practice
class Admin
{
public function getName(): string
{
return $this->name; // $name is not declared as a property of the class Admin
}
}
class User
{
private string $name = 'John Doe';
}
class Admin extends User
{
public function getName(): string
{
return $this->name; // $name is a private property of the parent class
}
}
class User
{
protected string $name = 'John Doe';
}
class Admin
{
public function getName(): string
{
$user = new User;
return $user->name; // $name is a protected property defined in the User class, and cannot be accessed outside of it or its descendent classes
}
}
class Admin
{
public string $user = 'John';
public function getName(): string
{
return $this->user->name; // $this->user is not an instance of any class
}
}
Accesing magic properties:
Though in this example, the __set()
method is implemented, it doesn't guarantee that properties(username
in this case) being accessed will always be there!
class Admin
{
public function __set(string $name, mixed $value): void
{
$this->{$name} = $value;
}
public function getUsername(): string
{
// invalid: property "username" doesn't exist
return $this->username;
}
}
$admin = new Admin();
// Pay attention to this line. If this line weren't present, the "getUsername" method wouldn't be able to find the "username" property.
$admin->username = 'john';
$admin->getUsername();
Recommended
class Admin
{
public string $name = 'John Doe';
public function getName(): string
{
return $this->name;
}
}
class User
{
protected string $name = 'John Doe';
}
class Admin extends User
{
public function getName(): string
{
return $this->name;
}
}
class User
{
public string $name = 'John Doe';
}
class Admin
{
public function getName(): string
{
$user = new User;
return $user->name;
}
}
class User
{
public string $name = 'John Doe';
}
class Admin
{
public ?User $user;
public function __construct()
{
$this->user = new User;
}
public function getName(): string
{
return $this->user->name;
}
}
Accesing magic properties:
Use @property
PHPDoc tag at the class level to let analyzer know what properties it can access. It'll fix the issue causing this error.
/**
* @property string $username
*/
class Admin
{
public function __set(string $name, mixed $value): void
{
$this->{$name} = $value;
}
public function getUsername(): string
{
return $this->username;
}
}