Skip to main content

All Questions

Tagged with
1 vote
1 answer
50 views

PHP inheritance with inherited properties

I'd like to have the following class configuration. class Parent { protected ParentMapperInterface $mapper; public function __construct(ParentMapperInterface $mapper) { $this->...
Dima Dz's user avatar
  • 524
0 votes
0 answers
34 views

Is anti-pattern to handle redirections and view variables within Cake Components?

I am working on a project with CakePHP 2.x and I found 3 Controllers that share the same logic but some part of that logic is to set view variables and redirections. class ControllerA { public ...
pacoCham's user avatar
-2 votes
1 answer
27 views

Is there a way to access a variable from a acctual CHILD class?

ps: I dont want to acess a parent class var but rather an actual child class How do I access the $table var from User class? I know it sounds silly but is there a way to access this child class var ...
Jeú Casulo's user avatar
0 votes
1 answer
146 views

Constructor method inherited from another class can't see my additional arguments

I am writing a web application in PHP in the Sylius framework. I created a new class that inherits from the framework's built-in ResourceController class: class ResourceController extends \Sylius\...
TeslaX93's user avatar
0 votes
0 answers
65 views

Extending classes with generics in PHP using docblocks and proper type hinting in implmentation class functions

I'm trying to make a generic Laravel authorization policy since its repetitive to write checking for a permission in the corresponding format: {model}_view {model}_store {model}_update {model}_delete ...
Reflexecute's user avatar
0 votes
0 answers
56 views

Changing class data type from parent to child in PHP

I have a parent class let say Foo... class Foo { protected string $value; public function __construct(string $value) { $this->value = $value; } // ...OTHER METHOD } And, the class ...
khai's user avatar
  • 79
0 votes
1 answer
162 views

PHP (IntelliJ/PhpStorm inspection): "Method should be final"

Since a month or something like this the IntelliJ/PhpStorm inspection "Method should be final" is shown on almost any function as a warning. I know I can disable certain inspections I just ...
Blackbam's user avatar
  • 18.9k
-2 votes
1 answer
42 views

OOP in PHP - Inheritance - protected method error [closed]

//((inheritance)) class ParentClass { public function public_message() { echo "This is a Public message" . "<br>" . "from Parent class ."; } ...
shahriar 's user avatar
0 votes
0 answers
46 views

PHP OOP - subclasses

I have the following scenario: There is a base class called a Document and two subclasses called FileDocument and TextDocument. FileDocument class has properties fileName, fileType and blob. ...
 Ibrahim EL-Sanosi's user avatar
0 votes
1 answer
95 views

When a class extends another class and also implements an interface, shouldn't it override all the abstract methods of the parent class and interface?

As far as I know, when a class extending another class, It's should override all abstract methods of parent class and It can also override non-abstract methods And also when a class implementing an ...
mahdi_sheykh's user avatar
-1 votes
1 answer
63 views

Why child exception is not found?

I have a child exception that inherit of his parent that extends to the Exception class : namespace Exceptions; use Exception; class InvalidFieldException extends Exception { } class ...
Yokke's user avatar
  • 5
0 votes
1 answer
604 views

Laravel PHP overriding method with different parameters

Apologies if this has been asked many times before and if this is simply not doable in Laravel/PHP. In my Laravel app I have a PostController which uses Laravel's resourceful naming conventions. I ...
Ben's user avatar
  • 343
2 votes
1 answer
415 views

PHP Symfony - Autowiring Interface as constructor argument but using specific class from interface on test .env

Imagine we have the following Interface: interface FooInterface { //... } We have two classes that implements this interface: class Foo implements FooInterface { //... } class Bar implements ...
Cuberino's user avatar
0 votes
1 answer
30 views

How can I set the value of a static property per inherited class in PHP

I found out that due to inheritance static properties are shared in sibling classes even when called in static context instead of self abstract class Repository { protected static ?string $tableName =...
Chris Athanasiadis's user avatar
0 votes
0 answers
34 views

PHP static:: vs $this in Late Static Bindings [duplicate]

class ParentClass { private function first(): void { p(__METHOD__); } public function test(): void { static::first(); $this->first(); $B = new ...
Max Denusenko's user avatar

15 30 50 per page
1
2 3 4 5
81