Skip to content

Commit

Permalink
Fix DynamicProperties php 8.2 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Sep 10, 2025
1 parent 73eb1b2 commit ed03dd0
Show file tree
Hide file tree
Showing 25 changed files with 153 additions and 154 deletions.
40 changes: 20 additions & 20 deletions app/src/Controller/ApiV2Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function initialize(): void {

// requested model = models
$reqModel = $this->request->getParam('model');
// $this->name = Models
/** var string $modelsName */
// We override $this->name (which is ApiV2) to make it match to the expected
// behavior for UI calls (which is Models, eg "Cous"). We need to do this
// before RegistryAuthComponent runs.
Expand All @@ -76,10 +76,10 @@ public function initialize(): void {
*/

public function add() {
// $this->name = Models
$modelsName = $this->name;
// $table = the actual table object
$table = $this->$modelsName;
/** var string $modelsName */
$modelsName = $this->getName();
/** var Cake\ORM\Table $table */
$table = $this->fetchTable($modelsName);
// $tableName = models
$tableName = $this->tableName;

Expand Down Expand Up @@ -180,10 +180,10 @@ public function calculateRequestedCOID(): ?int {
*/

public function delete($id) {
// $this->name = Models (ie: from ModelsTable)
$modelsName = $this->name;
// $table = the actual table object
$table = $this->$modelsName;
/** var string $modelsName */
$modelsName = $this->getName();
/** var Cake\ORM\Table $table */
$table = $this->fetchTable($modelsName);
// $tableName = models
$tableName = $table->getTable();

Expand Down Expand Up @@ -232,9 +232,9 @@ protected function dispatchIndex(string $mode = 'default') {
}

// $modelsName = Models
$modelsName = $this->name;
// $table = the actual table object
$table = $this->$modelsName;
$modelsName = $this->getName();
/** var Cake\ORM\Table $table */
$table = $this->fetchTable($modelsName);

$reqParameters = [...$this->request->getQuery()];
$pickerMode = ($mode === 'picker');
Expand Down Expand Up @@ -265,10 +265,10 @@ protected function dispatchIndex(string $mode = 'default') {
*/

public function edit($id) {
// $this->name = Models (ie: from ModelsTable)
$modelsName = $this->name;
// $table = the actual table object
$table = $this->$modelsName;
/** var string $modelsName */
$modelsName = $this->getName();
/** var Cake\ORM\Table $table */
$table = $this->fetchTable($modelsName);
// $tableName = models
$tableName = $table->getTable();

Expand Down Expand Up @@ -387,10 +387,10 @@ public function index() {
*/

public function view($id = null) {
// $this->name = Models
$modelsName = $this->name;
// $table = the actual table object
$table = $this->$modelsName;
/** var string $modelsName */
$modelsName = $this->getName();
/** var Cake\ORM\Table $table */
$table = $this->fetchTable($modelsName);
// $tableName = models
$tableName = $table->getTable();

Expand Down
41 changes: 20 additions & 21 deletions app/src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
* @property \Cake\Controller\Component\FlashComponent $Flash
* @property \Cake\Controller\Component\FormProtectionComponent $FormProtection
*/
#[\AllowDynamicProperties]
class AppController extends Controller {
use \App\Lib\Traits\LabeledLogTrait;

Expand Down Expand Up @@ -221,8 +220,8 @@ public function beforeFilter(\Cake\Event\EventInterface $event) {
*/

public function beforeRender(\Cake\Event\EventInterface $event) {
// $this->name = Models
$modelsName = $this->name;
/** var string $modelsName */
$modelsName = $this->getName();

// Views can also inspect the request object to determine the current
// controller and action, but it seems slightly easier to do it once here.
Expand Down Expand Up @@ -278,8 +277,8 @@ public function getCOID(): ?int {

protected function primaryLinkOnGet(string $potentialPrimaryLink): Object|bool
{
// $this->name = Models
$modelsName = $this->name;
/** var string $modelsName */
$modelsName = $this->getName();

// If this action allows unkeyed, asserted primary link IDs, check the query
// string (e.g.: 'add' or 'index' allow matchgrid_id to be passed in)
Expand Down Expand Up @@ -312,8 +311,8 @@ protected function primaryLinkOnGet(string $potentialPrimaryLink): Object|bool

protected function primaryLinkOnPost(string $potentialPrimaryLink): Object|bool
{
// $this->name = Models
$modelsName = $this->name;
/** var string $modelsName */
$modelsName = $this->getName();

// Post = add, where we can have a list of objects and nothing in /objects/{id}
// We don't support different primary links across objects, so we throw an error
Expand Down Expand Up @@ -345,8 +344,8 @@ protected function primaryLinkOnPost(string $potentialPrimaryLink): Object|bool

protected function primaryLinkOnPut(): Object|bool
{
// $this->name = Models
$modelsName = $this->name;
/** var string $modelsName */
$modelsName = $this->getName();
$param = (int)$this->request->getParam('pass.0');

// Put = edit, so we should look up the parent ID via the object itself
Expand All @@ -368,8 +367,8 @@ protected function primaryLinkOnPut(): Object|bool
*/
protected function populatedPrimaryLink(string $potentialPrimaryLink): Object
{
// $this->name = Models
$modelsName = $this->name;
/** var string $modelsName */
$modelsName = $this->getName();
// $potentialPrimaryLink will be something like 'attribute_collector_id'
// $potentialPrimaryLinkTable will be something like 'CoreEnroller.AttributeCollectors'
$potentialPrimaryLinkTable = $this->$modelsName->getPrimaryLinkTableName($potentialPrimaryLink);
Expand Down Expand Up @@ -406,8 +405,8 @@ protected function populatedPrimaryLink(string $potentialPrimaryLink): Object

protected function primaryLinkLookup(): void
{
// $this->name = Models
$modelsName = $this->name;
/** var string $modelsName */
$modelsName = $this->getName();
$availablePrimaryLinks = $this->$modelsName->getPrimaryLinks();

// Iterate over all the potential primary links and pick the appropriate one
Expand Down Expand Up @@ -478,8 +477,8 @@ public function getPrimaryLink(bool $lookup=false): Object
return $this->cur_pl;
}

// $this->name = Models
$modelsName = $this->name;
/** var string $modelsName */
$modelsName = $this->getName();

$this->cur_pl = new \stdClass();

Expand Down Expand Up @@ -540,8 +539,8 @@ public function getPrimaryLink(bool $lookup=false): Object
*/

protected function getRedirectGoal(string $action): ?string {
// $this->name = Models
$modelsName = $this->name;
/** var string $modelsName */
$modelsName = $this->getName();

// PrimaryLinkTrait
if(method_exists($this->$modelsName, "getRedirectGoal")) {
Expand Down Expand Up @@ -663,8 +662,8 @@ protected function setCO() {
}

if(!$coid) {
// $this->name = Models, unless we're in an API call
$modelsName = $this->name;
/** var string $modelsName */
$modelsName = $this->getName();

$attrs = $this->request->getAttributes();

Expand Down Expand Up @@ -773,8 +772,8 @@ protected function setCO() {
*/

protected function setTZ() {
// $this->name = Models
$modelsName = $this->name;
/** var string $modelsName */
$modelsName = $this->getName();

// See if we've collected it from the browser in a previous page load. Otherwise,
// use the system default. If the user set a preferred timezone, we'll catch that below.
Expand Down
4 changes: 2 additions & 2 deletions app/src/Controller/Component/RegistryAuthComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ protected function calculatePermissions(?int $id=null): array {
// This will need to be prefixed to the model, if set
$pluginName = $controller->getPlugin();

// $this->name = Models (ie: from ModelsTable)
/** var string $modelsName */
$modelsName = ($pluginName ? "$pluginName." : "") . $controller->getName();
// $table = the actual table object
/** var Cake\ORM\Table $table */
$table = $controller->getTableLocator()->get($modelsName);

// Do we have an authenticated user?
Expand Down
8 changes: 4 additions & 4 deletions app/src/Controller/MVEAController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class MVEAController extends StandardController {
*/

public function beforeFilter(\Cake\Event\EventInterface $event) {
// $this->name = Models
$modelsName = $this->name;
/** var string $modelsName */
$modelsName = $this->getName();

if(!$this->request->is('restful') && $this->request->getParam('action') != 'deleted') {
// Provide additional hints to BreadcrumbsComponent. This needs to be here
Expand Down Expand Up @@ -138,8 +138,8 @@ public function beforeFilter(\Cake\Event\EventInterface $event) {
*/

public function beforeRender(\Cake\Event\EventInterface $event) {
// $this->name = Models
$modelsName = $this->name;
/** var string $modelsName */
$modelsName = $this->getName();
// field = model (or model_name)
$fieldName = Inflector::underscore(Inflector::singularize($modelsName));

Expand Down
20 changes: 10 additions & 10 deletions app/src/Controller/MultipleAuthenticatorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class MultipleAuthenticatorController extends StandardPluginController {

public function beforeFilter(\Cake\Event\EventInterface $event) {
// $modelsName = Models (eg: SshKeys)
$modelsName = $this->name;
$modelsName = $this->getName();
// $authModelName = eg SshKeyAuthenticators
$authModelsName = Inflector::singularize($modelsName) . "Authenticators";
// $table = the actual table object
/** var Cake\ORM\Table $table */
$Table = $this->$modelsName;
// $authFK = eg ssh_key_authenticator_id
$authFK = StringUtilities::classNameToForeignKey($authModelsName);
Expand Down Expand Up @@ -98,10 +98,10 @@ public function beforeRender(\Cake\Event\EventInterface $event) {

public function generateRedirect($entity) {
// $modelsName = Models (eg: SshKeys)
$modelsName = $this->name;
$modelsName = $this->getName();
// $authModelName = eg SshKeyAuthenticators
$authModelsName = Inflector::singularize($modelsName) . "Authenticators";
// $table = the actual table object
/** var Cake\ORM\Table $table */
$Table = $this->$modelsName;
// $authFK = eg ssh_key_authenticator_id
$authFK = StringUtilities::classNameToForeignKey($authModelsName);
Expand Down Expand Up @@ -132,10 +132,10 @@ public function generateRedirect($entity) {
*/

public function index() {
// $this->name = Models
$modelsName = $this->name;
// $table = the actual table object
$table = $this->$modelsName;
/** var string $modelsName */
$modelsName = $this->getName();
/** var Cake\ORM\Table $table */
$table = $this->fetchTable($modelsName);
// $tableName = models
$tableName = $table->getTable();
// Construct the Query
Expand Down Expand Up @@ -181,10 +181,10 @@ public function index() {

public function willHandleAuth(\Cake\Event\EventInterface $event): string {
// $modelsName = Models (eg: SshKeys)
$modelsName = $this->name;
$modelsName = $this->getName();
// $authModelName = eg SshKeyAuthenticators
$authModelsName = Inflector::singularize($modelsName) . "Authenticators";
// $table = the actual table object
/** var Cake\ORM\Table $table */
$Table = $this->$modelsName;
// $authFK = eg ssh_key_authenticator_id
$authFK = StringUtilities::classNameToForeignKey($authModelsName);
Expand Down
4 changes: 2 additions & 2 deletions app/src/Controller/SingleAuthenticatorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class SingleAuthenticatorController extends StandardPluginController {

public function manage() {
// $modelsName = Models (eg: Passwords)
$modelsName = $this->name;
$modelsName = $this->getName();
// $authModelName = eg PasswordAuthenticators
$authModelsName = Inflector::singularize($modelsName) . "Authenticators";
// $table = the actual table object
/** var Cake\ORM\Table $table */
$Table = $this->$modelsName;
// $authFK = eg password_authenticator_id
$authFK = StringUtilities::classNameToForeignKey($authModelsName);
Expand Down
Loading

0 comments on commit ed03dd0

Please sign in to comment.