note 125065 added to reflectionparameter.getclass

From: Date: Mon, 01 Jun 2020 09:33:49 +0000
Subject: note 125065 added to reflectionparameter.getclass
Groups: php.notes 
Request: Send a blank email to php-notes+get-214703@lists.php.net to get a copy of this message
Example of how to use getClass() in conjunction with getConstructor() to build the dependencies of a class. private function buildDependencies(ReflectionClass $reflection) { $constructor = $reflection->getConstructor(); if (!$constructor) { return []; } $params = $constructor->getParameters(); return array_map(function ($param) { $className = $param->getClass(); if (!$className) { throw new Exception(); } $className = $param->getClass()->getName(); return $this->make($className); }, $params); } ---- Server IP: 45.112.84.4 Probable Submitter: 103.51.166.36 (proxied: 37.24.107.95) ---- Manual Page -- http://php.net/manual/en/reflectionparameter.getclass.php Edit -- https://master.php.net/note/edit/125065 Del: integrated -- https://master.php.net/note/delete/125065/integrated Del: useless -- https://master.php.net/note/delete/125065/useless Del: bad code -- https://master.php.net/note/delete/125065/bad+code Del: spam -- https://master.php.net/note/delete/125065/spam Del: non-english -- https://master.php.net/note/delete/125065/non-english Del: in docs -- https://master.php.net/note/delete/125065/in+docs Del: other reasons-- https://master.php.net/note/delete/125065 Reject -- https://master.php.net/note/reject/125065 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#214703) next »