NotionCommotion
Members-
Posts
2,446 -
Joined
-
Last visited
-
Days Won
10
Everything posted by NotionCommotion
-
Help authenticating to PostgreSQL
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
I should know this but I don't. How does one find the path to a desired socket file? I too am sure I don't need an authentication system on port 113. But I appear to have one and after spending a fair amount of time trying to figure out what it is, still am not closer. Should it have some service name? If so, please let me know what I might try. -
Help authenticating to PostgreSQL
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
Oh, I thought you were talking about one of the conf files and not the login prompt. I cannot leave the host field blank unless I include a service. Not sure but I think they are referring to a service as some pre-configured host/port/username thing. Did my indent server question make any sense? Evidently, all unix type systems have one running on port 113. I looked at all my services running on the machine and couldn't find one that seemed like this purpose. I couldn't find any options for socket connections described by https://www.pgadmin.org/docs/pgadmin4/development/config_py.html. Have you ever used pgadmin and if so configured to connect via a unix socket and not a host? Thanks -
Help authenticating to PostgreSQL
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
I previously didn't have permissions set up correctly for pgsql's log file so I didn't get the first log. 2020-03-17 20:32:45.678 UTC [2758] LOG: could not connect to Ident server at address "127.0.0.1", port 113: Connection refused 2020-03-17 20:32:45.678 UTC [2758] FATAL: Ident authentication failed for user "postgres" 2020-03-17 20:32:45.678 UTC [2758] DETAIL: Connection matched pg_hba.conf line 83: " host all all 127.0.0.1/32 ident" If connection was refused, I must have an Ident server, but cannot find it. I've looked for ident, identd, authd, xinetd, and others but no luck. I do have "ident - identify RCS keyword strings in files" but I don't think this is applicable. Also checked whether anything is listening to port 113 and can't find anything. Anything else it might be called? -
Help authenticating to PostgreSQL
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
Don't think it is ideal, but am able to connect after changing ident to trust for both local and host in /var/lib/pgsql/12/data/pg_hba.conf. -
Help authenticating to PostgreSQL
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
Thanks again requinix, A little off topic for the php coding help forum but relevant to this specific post. I also installed pgAdmin on the same machine as PostgreSQL, however, cannot connect as shown by /var/lib/pgsql/12/data/log/postgresql-Tue.log 2020-03-17 12:24:49.921 UTC [2272] FATAL: Ident authentication failed for user "michael" 2020-03-17 12:24:49.921 UTC [2272] DETAIL: Connection matched pg_hba.conf line 82: "host all all 127.0.0.1/32 ident" Since I am on the same machine, I used host 127.0.0.1. But then the user running the webserver and thus pgAmin is apache and not michael, true? I considered using PostgreSQL to set up authentication for apache but don't believe it is a good idea. Was thinking of adding my remote client's IP or the server's IP to pg_hba.conf and use some authentication other than ident, however, this too doesn't seem right. Maybe I should be using "service" instead of a username in the pgAdmin prompt but not sure what to include. Any advise would be much appreciated. # "local" is for Unix domain socket connections only local all all peer # IPv4 local connections: host all all 127.0.0.1/32 ident # IPv6 local connections: host all all ::1/128 ident # Allow replication connections from localhost, by a user with the # replication privilege. local replication all peer host replication all 127.0.0.1/32 ident host replication all ::1/128 ident -
Help authenticating to PostgreSQL
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
Thanks requinix, Your reply was very helpful. I am still a little confused about users and roles, schemas and databases, and clusters. Guess that is why you said "Be careful about ownerships". Are not roles and (postgresql) owners the same thing? Owners are operating system owners that are assigned postgresql roles, true? php-fpm was originally set up as follows but I received an error and discovered that I needed to change user from apache to $pool. Probably same thing for group? listen.owner and listen.group remains as is, right? Rest look okay? /etc/httpd/conf.d/php.conf ... Define PHP7_POOL_TESTING "proxy:unix:/run/php-fpm/testing.sock|fcgi://localhost" ... /etc/php-fpm.d/testing.conf [testing] prefix = /run/php-fpm user = apache ;need to change to $pool group = apache listen.owner = apache listen.group = apache listen.mode = 0660 listen = $pool.sock pm = ondemand pm.max_children = 50 php_value[session.save_handler] = files php_value[session.save_path] = /var/lib/php/session php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache slowlog = /var/log/php-fpm/testing-slow.log Using superuser user/role postgres, I created role michael and then created a database for that role (all role's must have a database of same name, right?). My desire was for this role to be the primary administrator but not quite have superuser status. I then created role testing which is the same as the php-fpm pool user, and then tried to create the database under role michael but couldn't. Shouldn't I be able to? Ended up doing so using role postgres. [michael@devserver www]$ sudo -u michael psql psql (12.2) Type "help" for help. michael=> \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- michael | michael | UTF8 | en_US.UTF-8 | en_US.UTF-8 | postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres (4 rows) michael=> \du List of roles Role name | Attributes | Member of ------------+------------------------------------------------------------+----------- testing | | {} michael | Create role, Create DB | {} postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} michael=> CREATE DATABASE testing OWNER testing; ERROR: must be member of role "testing" michael=> Eventually, was able to access the database via PDO. Why is the Schema shown as "public" [michael@devserver www]$ sudo -u testing psql psql (12.2) Type "help" for help. testing=> \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges ------------+------------+----------+-------------+-------------+----------------------- testing | testing | UTF8 | en_US.UTF-8 | en_US.UTF-8 | ... same as above (5 rows) testing=> \d List of relations Schema | Name | Type | Owner --------+-------------------------+----------+------------ public | playground | table | testing public | playground_equip_id_seq | sequence | testing (2 rows) testing=> Thanks again! -
Hi, Trying PostgreSQL for the first time but not making much progress. Get peer failure when not including a host and Ident error when including a host. Never heard of Ident authentication until today and don't know for sure if I even have such a server running. Using Centos7, PHP7.4 using remi's repo, and PostgreSQL 12 from their repo. Any thoughts? Thanks try { //use Unix domain sockets $dbh = new PDO("pgsql:dbname=postgres", 'postgres', 'secret'); } catch(Exception $e){ echo($e->getMessage().PHP_EOL); } try { $dbh = new PDO("pgsql:host=localhost;dbname=postgres", 'postgres', 'secret'); } catch(Exception $e){ echo($e->getMessage().PHP_EOL); } try { $dbh = new PDO("pgsql:host=127.0.0.1;dbname=postgres", 'postgres', 'secret'); } catch(Exception $e){ echo($e->getMessage().PHP_EOL); } SQLSTATE[08006] [7] FATAL: Peer authentication failed for user "postgres" SQLSTATE[08006] [7] FATAL: Ident authentication failed for user "postgres" SQLSTATE[08006] [7] FATAL: Ident authentication failed for user "postgres"
-
Database choices for PHP applications
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
Regardless of whether deferrable constraints are used, does anyone have any feedback on using PostgreSQL with PHP and how it compares to MySQL and/or MariaDB? -
Is closure and an arrow function just about the same?
NotionCommotion replied to NotionCommotion's topic in Javascript Help
Thanks kicken, Didn't know about target and super, but good to know the rest is not that foreign. -
Database choices for PHP applications
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
My "position" column is identical to your DisplayOrder column. Agree it is not mission critical and certainly need not be enforced by the DB and not even the application, and will drop it before stressing over it. I believe that any database which implements the standard for unique constraints which I believe is deferrable constraints will automatically eliminate my issue. -
Trying to better understand arrow functions and came up with the following script. Other than being longer and renaming this as _this and arguments as _arguments, is the following identical to an arrow function? Thanks return (function(_this, _arguments) { return function() { /* bla bla bla*/ }; })(this, arguments); https://jsbin.com/fazujup/1/edit?html,js,output <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Closure</title> </head> <body> <script type="text/javascript"> const test = { name: 'test object', createAnonFunction: function() { return function() { console.log('createAnonFunction this.name', this.name); console.log('createAnonFunction arguments', arguments); }; }, createArrowFunction: function() { return () => { console.log('createArrowFunction this.name', this.name); console.log('createArrowFunction arguments', arguments); }; }, createClosureFunction: function() { return (function(_this, _arguments) { return function() { console.log('createClosureFunction this.name', this.name); console.log('createClosureFunction arguments', arguments); console.log('createClosureFunction _this.name', _this.name); console.log('createClosureFunction _arguments', _arguments); }; })(this, arguments); }, createArrowFunctionSingleExp: function(a, b) { // if the function body is a single expression, you can leave off the brackets and put it inline. console.log('createArrowFunctionSingleExp this, a, b', this, a, b); return (a, b) => a + b; }, createArrowFunctionSingleArg: function(array) { //if there is only a single argument, you can even leave off the parenthesis around the argument console.log('createArrowFunctionSingleArg this, array', this, array); return array => array[0]; }, createArrowFunctionSingleExpObj: function(name, description) { //To indicate that instead you want a single expression that happens to be an object, you wrap the object with parentheses // ERROR => return (name, description) => {name: name, description: description}; console.log('createArrowFunctionSingleExpObj this', this); return (name, description) => ({name: name, description: description}); } }; const anon = test.createAnonFunction('hello', 'world'); const arrow = test.createArrowFunction('hello', 'world'); const closure = test.createClosureFunction('hello', 'world'); const arrowSingleExp = test.createArrowFunctionSingleExp('hello', 'world'); const arrowSingleArg = test.createArrowFunctionSingleArg('hello', 'world'); const arrowSingleExpObj = test.createArrowFunctionSingleExpObj('hello', 'world'); anon(); arrow(); closure(); console.log('arrowSingleExp', arrowSingleExp(4,5)); console.log('arrowSingleArg', arrowSingleArg(['zero','one'])); console.log('arrowSingleExpObj', arrowSingleExpObj('theName', 'theDescription')); </script> </body> </html>
-
Database choices for PHP applications
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
I've got the following table and data and wish to swap the position value for two records, delete and reorder the positions, or insert and reorder the positions. Currently, I perform the first task by reserving position zero as a temporary placeholder and perform the other two tasks by executing something like "UPDATE series SET position=position-1 WHERE chart_id=3 AND position > 2". It would be simpler to update the entity values and save them, however, I often encounter an interim unique constraint error. CREATE TABLE IF NOT EXISTS series ( id INT(11) NOT NULL AUTO_INCREMENT, chart_id INT(11) NOT NULL, position INT(11) NOT NULL PRIMARY KEY (id), UNIQUE INDEX unique_position (chart_id ASC, position ASC) VISIBLE, UNIQUE INDEX unique_name (chart_id ASC, name ASC) VISIBLE, INDEX IDX_582B2D4DBEF83E0A (chart_id ASC) VISIBLE, CONSTRAINT FK_582B2D4DBEF83E0A FOREIGN KEY (chart_id) REFERENCES chart (id) ON DELETE CASCADE) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci; |----|----------|----------| | id | position | chart_id | |----|----------|----------| | . | . | . | | . | . | . | | 3 | 6 | 2 | | 6 | 1 | 3 | | 1 | 2 | 3 | | 4 | 3 | 3 | | 5 | 4 | 3 | | 2 | 1 | 4 | | . | . | . | | . | . | . | |----|----------|----------| -
A while back, I started using Doctrine and feel it brings many benefits, however, I experience many issues when the database schema contains unique indexes. I have since learned that deferrable constraints exist for some DB's and their use will eliminate my issues. According to MySQL's documentation the SQL standard is to make them the default, however, MySQL does not do so (and apparently neither does MariaDB which I typically use). I am considering changing databases. Any recommendations? I've always heard good things about postgresql. Thoughts? Much of a learning curve to change? Thanks
-
Create an array from prepared statement result
NotionCommotion replied to Adamhumbug's topic in PHP Coding Help
Maybe I am missing something but... $stmt = $conn -> prepare('...'); $stmt -> bind_param('i', $jid); $stmt -> execute(); foreach($stmt as $row) { vardump($row); } -
Don’t know how to get values from stored procedure
NotionCommotion replied to narutofan's topic in PHP Coding Help
Are you using namespace? If so, you will need to use \PDO::FETCH_ASSOC instead of PDO::FETCH_ASSOC unless you have a PDO alias. Are you getting errors? Do you get any content or just with the stored procedure? Try a simple query such as SELECT 123 or select just from some table. -
I ended up mocking it up and didn't expect the following results. Creating the initial array uses 11MB, copying it uses very little, and changing it uses 529KB. I would have expected changing it would have used the same as creating it. And then when I reassign $bigArray with new values, it uses 11MB which I wasn't sure whether to expect or not and this was the basis of my original question. But then I don't reassign $bigArray but pass the array directly to the class, and it also uses 11MB which I definitely did not expect and thought that it would be saved only as a reference and use very little memory. I am using PHP7.4.1. What is going on? Thanks <?php error_reporting(E_ALL); ini_set('display_errors', 1); $settings=parse_ini_file(__DIR__.'/../../config.ini',true); $db=$settings['mysql']; $pdo=new \PDO("mysql:host={$db['host']};dbname={$db['dbname']};charset={$db['charset']}",$db['username'],$db['password'],array(\PDO::ATTR_EMULATE_PREPARES=>false,\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY=>true,\PDO::ATTR_ERRMODE=>\PDO::ERRMODE_EXCEPTION,\PDO::ATTR_DEFAULT_FETCH_MODE=>\PDO::FETCH_ASSOC)); $stmt=$pdo->query('SELECT * FROM test'); function display($memory) { $s=''; foreach($memory as $i => $m) { $delta=$i>0 ?[$m[1]-$memory[$i-1][1], $m[2]-$memory[$i-1][2], $m[3]-$memory[$i-1][3], $m[4]-$memory[$i-1][4]] :[null, null, null, null]; $m=array_merge($m, $delta); $s.='<tr><td>'.implode('</td><td>', $m).'</td></tr>'; } echo "<table><tbody><tr><td>Test</td><td>Used</td><td>Peak</td><td>Peak Used</td><td>Peak Allocated</td><td>Used Change</td><td>Peak Change</td><td>Peak Used Change</td><td>Peak Allocated Change</td></tr>$s</tbody></table>"; } function logger($msg, $log=true) { global $memory; $m = [$msg, round(memory_get_usage()/1000),round( memory_get_peak_usage()/1000), round(memory_get_usage(true)/1000), round(memory_get_peak_usage(true)/1000)]; if($log) $memory[] = $m; return $m; } function addDelta($msg, $before, $after) { global $memory; $m = [$msg, $after[1]-$before[1], $after[2]-$before[2], $after[3]-$before[3], $after[4]-$before[4]]; $memory[]=$m; return $m; } function getData($stmt) { $data=[]; for ($i = 0; $i <= 3; $i++) { $stmt->execute(); $data = array_merge($data, $stmt->fetchAll()); } return $data; } class DataHolder { private $data; public function __construct(array $data) { $this->data=$data; //$this->data[]='bla'; <-- I believe this will force PHP to make a new copy of the array but I am not doing so } } $memory=[]; logger('initial'); $bigArray1=getData($stmt); logger('after creating first data set'); $bidArrayCopy=$bigArray1; logger('after copying first data set'); $bigArray1[]=123; logger('after modifying first data set'); $dataHolders=[]; $log1=logger(null, false); for ($i = 1; $i <= 5; $i++) { logger("Copy Loop $i - Before"); $stmt->execute(); $bigArray=getData($stmt); $dataHolders[] = new DataHolder($bigArray); logger("Copy Loop $i - After"); } $log2=logger(null, false); $deltaCopy = addDelta('delta copy', $log1, $log2); for ($i = 1; $i <= 5; $i++) { logger("Set Loop $i - Before"); $stmt->execute(); $dataHolders[] = new DataHolder(getData($stmt)); logger("Set Loop $i - After"); } $log3=logger(null, false); $deltaSet = addDelta('delta set', $log2, $log3); addDelta('delta copy set', $deltaCopy, $deltaSet); display($memory); | Test | Used | Peak | Peak Used | Peak Allocated | Used Change | Peak Change | Peak Used Change | Peak Allocated Change | |--------------------------------|--------|--------|-----------|----------------|-------------|-------------|------------------|-----------------------| | initial | 1345 | 1345 | 2097 | 2097 | | | | | | after creating first data set | 12631 | 13294 | 2097 | 2097 | 11286 | 11949 | 0 | 0 | | after copying first data set | 12631 | 13294 | 2097 | 2097 | 0 | 0 | 0 | 0 | | after modifying first data set | 13160 | 13294 | 2097 | 2097 | 529 | 0 | 0 | 0 | | Copy Loop 1 - Before | 13161 | 13294 | 2097 | 2097 | 1 | 0 | 0 | 0 | | Copy Loop 1 - After | 24447 | 25110 | 2097 | 2097 | 11286 | 11816 | 0 | 0 | | Copy Loop 2 - Before | 24447 | 25110 | 2097 | 2097 | 0 | 0 | 0 | 0 | | Copy Loop 2 - After | 35733 | 36396 | 2097 | 2097 | 11286 | 11286 | 0 | 0 | | Copy Loop 3 - Before | 35734 | 36396 | 2097 | 2097 | 1 | 0 | 0 | 0 | | Copy Loop 3 - After | 47020 | 47683 | 2097 | 2097 | 11286 | 11287 | 0 | 0 | | Copy Loop 4 - Before | 47020 | 47683 | 2097 | 2097 | 0 | 0 | 0 | 0 | | Copy Loop 4 - After | 58306 | 58969 | 2097 | 2097 | 11286 | 11286 | 0 | 0 | | Copy Loop 5 - Before | 58307 | 58969 | 2097 | 2097 | 1 | 0 | 0 | 0 | | Copy Loop 5 - After | 69592 | 70256 | 4194 | 4194 | 11285 | 11287 | 2097 | 2097 | | delta copy | 56433 | 56962 | 2097 | 2097 | -13159 | -13294 | -2097 | -2097 | | Set Loop 1 - Before | 69594 | 70256 | 4194 | 4194 | 13161 | 13294 | 2097 | 2097 | | Set Loop 1 - After | 80879 | 81543 | 16777 | 16777 | 11285 | 11287 | 12583 | 12583 | | Set Loop 2 - Before | 80881 | 81543 | 16777 | 16777 | 2 | 0 | 0 | 0 | | Set Loop 2 - After | 92166 | 92830 | 27263 | 27263 | 11285 | 11287 | 10486 | 10486 | | Set Loop 3 - Before | 92167 | 92830 | 27263 | 27263 | 1 | 0 | 0 | 0 | | Set Loop 3 - After | 103453 | 104116 | 39846 | 39846 | 11286 | 11286 | 12583 | 12583 | | Set Loop 4 - Before | 103453 | 104116 | 39846 | 39846 | 0 | 0 | 0 | 0 | | Set Loop 4 - After | 114739 | 115402 | 50332 | 50332 | 11286 | 11286 | 10486 | 10486 | | Set Loop 5 - Before | 114740 | 115402 | 50332 | 50332 | 1 | 0 | 0 | 0 | | Set Loop 5 - After | 126026 | 126689 | 60817 | 60817 | 11286 | 11287 | 10485 | 10485 | | delta set | 56433 | 56433 | 56623 | 56623 | -69593 | -70256 | -4194 | -4194 | | delta copy set | 0 | -529 | 54526 | 54526 | -56433 | -56962 | -2097 | -2097 |
-
I understand older versions of PHP would actually make a copy, but that this is no longer the case and it is only copied when it is changed. When I fetch the first set of results, I obviously need to save the content in memory (just realized my typo and forgot the fetchAll). But then when I fetch the second and future data sets, I am reassigning the $bigArray variable to this new data set which "maybe" is effectively changing it. You know, it would be quicker to actually test this.
-
I know I am not known for specific question, but do have one this time. gizmola's response makes me feel that the above will cause PHP to copy the original value. True? Guess I can prevent doing so with the following... $dataHolders[] = new DataHolder($stmt->execute([$id])); //or $bigArray[]=$stmt->execute([$id]); $dataHolders[] = new DataHolder(reset($bigArray));
-
When will modern PHP copy an array by reference only instead of reassigning to memory? For instance, when I execute $bigArray=$stmt->execute([$id]), PHP utilizes memory to store the data. But then when I execute $dataHolders[] = new DataHolder($bigArray), I believe $bigArray is passed by reference and a new copy of $bigArray will not be stored in memory. If in DataHolder::__construct, I executed $data[]='bla', then it is my understanding that PHP would see that the array is being modified and will automatically make a copy, but I am not doing so and just state this to confirm my understanding. The part that I am uncertain about is not the first time data is retrieved but any additional times. When I execute the next $bigArray=$stmt->execute([$id]), will PHP need to first store in memory the array that DataHolder::data references, then release the memory associated with $bigArray, and then store in memory the new $bigArray? <?php class DataHolder { private $data; public function __construct(array $data) { $this->data=$data; //$this->data[]='bla'; <-- I believe this will force PHP to make a new copy of the array but I am not doing so } } $dataHolders=[]; foreach($ids as $id) { $bigArray=$stmt->execute([$id]); $dataHolders[] = new DataHolder($bigArray); }
-
Traits or inheritance for reducing duplicated code?
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
Thanks maxxd. If so, then definitely a valid consideration. -
Traits or inheritance for reducing duplicated code?
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
Just looking for ways to limit cutting and pasting identical code and then making a change to one version and failing to update all the rest. You are likely correct that I am leaving out a key ingredient regarding interfaces and are still trying to better understand their place. I am mixed when it comes to __set and __get. When first learning about them, I used them exclusively, but then found (at least for me) that they often are more trouble than they are worth for when simple setters and getters can be used. -
Traits or inheritance for reducing duplicated code?
NotionCommotion replied to NotionCommotion's topic in PHP Coding Help
Just for copy and past reasons. I am still undecided on whether I prefer inheritance or traits for this scenario. There is no reason why Classes A, B, and C shouldn't have access to the $id and $name property so a trait is better. But then I can just make $id and $name protected so it doesn't matter. But then again using inheritance implies some base functionality and better defines what is additional (i.e. Foo), so maybe inheritance is better. Or maybe it really doesn't matter and I should just be consistent... -
I expect they will not have some sort of reasonable default behavior. If not, then? The answer to the universe? World peace? I was thinking of adding some OtherStuffInterface::getValue(string $name) method but I don't think doing so is really right. Alternatively, I can create interfaces OtherTimeChartStuffInterface and OtherPieChartStuffInterface which extend OtherStuffInterface, but not sure if this really makes sense. I expect you have a viable answer but want me to think it through. If so, mind given another clue?
-
For solely to reduce duplicated code and when injection isn't applicable, should one use inheritance or traits? <?php abstract class BaseClass { private $id, $name; public function __construct(int $id, string $name) { $this->id=$id; $this->name=$name; } public function getId():int { return $this->id; } public function getName():string { return $this->name; } } <?php class A extends BaseClass{} class B extends BaseClass{} class C extends BaseClass { private $foo; public function __construct(int $id, string $name, Foo $foo) { parent::__construct($id, $name); $this->foo=$foo; } public function getFoo():Foo { return $this->foo; } } <?php trait MyTrait { private $id, $name; public function __construct(int $id, string $name) { $this->id=$id; $this->name=$name; } public function getId():int { return $this->id; } public function getName():string { return $this->name; } } <?php class A { use MyTrait; } class B { use MyTrait; } class C { use MyTrait; private $foo; public function __construct(int $id, string $name, Foo $foo) { $this->id=$id; $this->name=$name; $this->foo=$foo; } public function getFoo():Foo { return $this->foo; } }
-
Yes, key phrase is "so far". This seems to be a common occurrence for me. I go down some path and then later find I need some other data for a given implementation and need to go back and change my interfaces which is rather a pain. Are you suggesting some grab bag which anything extra can go in or something else? I don't think so since doing so wouldn't require the pie and time charts to work with their extra things. interface ChartInterface { public function addSeries(int $id, string $name, ?OtherStuffInterface $otherStuff); }