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

  • SEARCH
  • Home
  • 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 5973915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:52:05+00:00 2026-05-22T20:52:05+00:00

Imagine i have 2 classes (i’ve simplified the logic here): class Table { public

  • 0

Imagine i have 2 classes (i’ve simplified the logic here):

class Table {
    public function addRow (Row $row){
        $this->row = $row;
    }
    // lots of code
}
class Row {
    // lots of code
}

And i want to extend the table class to do something similar so i create 2 new classes:

class SpecialTable extends Table{
    public function addRow (SpecialRow $row){
        parent::addRow($row);
    }
    // lots of code
}
class SpecialRow extends Row{
    // lots of code
}

When i try to add a SpecialRow to a SpecialTable object i get a warning similar to:

PHP Strict standards:  Declaration of SpecialTable::addRow() should be compatible with that of Table::addRow() in /SpecialTable.php on line XX

Can someone help me here? Is this bad practice and i should code it differently? Or is it just a warning that i should ignore?

Many thanks for any suggestions / guidance.

  • 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-22T20:52:06+00:00Added an answer on May 22, 2026 at 8:52 pm

    You should probably use a name like SpecialTable::addSpecialRow() if you’re changing the argument type – otherwise SpecialTable doesn’t actually extend Table, it overloads it (which isn’t supported in PHP).

    Based on your simplified example, it should be public function addRow(Row $row) since you just call the parent. Depending on what you’re actually doing to $row in that function, you could type-hint Row and check whether it’s a SpecialRow in code, or just use Row if you don’t need its Specialness.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine I have table like this: id:Product:shop_id 1:Basketball:41 2:Football:41 3:Rocket:45 4:Car:86 5:Plane:86 Now, this
Suppose you have 2 classes like so: public class ClassA { public int X
Assume we have legacy classes, that can't be modified: class Foo { public void
I have a table of classes, and a table of subjects. CLASS |class_id|class_name|subject_id|date_time| ------------------------------------------
Imagine I have abstract base class Shape , with derived classes Circle and Rectangle
Imagine we have following classes: public interface MyInterface<T> { List<T> getList(T t); } abstract
imagine I have a bunch of C++ related classes (all extending the same base
Imagine I have an function which goes through one million/billion strings and checks smth
Imagine I have a property defined in global.asax. public List<string> Roles { get {
In C#, I have a class hierarchy with a couple of abstract base classes

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.