Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPDocs for eZPersistentObject #138

Merged
merged 51 commits into from Nov 24, 2011
Merged

PHPDocs for eZPersistentObject #138

merged 51 commits into from Nov 24, 2011

Conversation

jeromegamez
Copy link
Contributor

To start a better support for our IDEs, I added PHPDocs to the eZPersistentObject class (and if this passes your acceptance tests, continue with other classes inheriting from it).

There are some very small modifications to the code, too, where I made sure that a return value has always the same type, but besides there should be no critical issues rising from these changes.

Originally, I wanted to make the class abstract (because classes inheriting from eZPersistetnObject have to implement the method fetch(), but @lolautruche convinced me that this would be not the best idea.

Best

  • Jérôme

eZPersistentObject calls $this->fetch() in the constructor, so this function has to exist in all inherited classes. Perfect case for an abstract.

I also thought about adding an interface, but I think that would be too much at this point.
Declared the method as protected because it is used only by eZPersistentObject::__construct().

Added return values

Added error logging when required information is missing.

Extracted function call from foreach statement into own line.
* </code>
*
* @package eZKernel
* @method fetch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is that for ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mean @method:

The line $row = $this->fetch( $row, false ); can be found in the constructor of eZPersistentObject, but the method eZPersistentObject::fetch() is not defined. Normally, we would solve that by defining an abstract method and by declaring the class as abstract, but we discussed that.

The @method makes sure that PHPDoc validation passes and that IDEs don't mark the missing method as an error.

* @param array $rows
* @param string $class_name
* @param bool $asObject If true then objects will be created, if not it just returns $rows as it is.
* @return array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@return eZPersistentObject[]|array

@@ -925,28 +993,33 @@ class eZPersistentObject
$cond_text = eZPersistentObject::conditionText( $conditions );
$rows = $db->arrayQuery( "SELECT MAX($orderField) AS $orderField FROM $table $cond_text" );
if ( count( $rows ) > 0 and isset( $rows[0][$orderField] ) )
return $rows[0][$orderField] + 1;
return (int) ( $rows[0][$orderField] + 1 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say instead :

<?php
return (int)$rows[0][$orderField] + 1;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good point :)

* Returns the attributes for this object, taken from the definition fields
* and function attributes.
*
* @return array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add:

@see eZPersistentObject::definition()

@jeromegamez
Copy link
Contributor Author

Any news on this one? This is almost completely about PHPDocs, with just a few code changes concerning unused variables. As soon as this one is accepted, I will continue with the PHPDocs of another class :).

@jeromegamez
Copy link
Contributor Author

This last commit is the same as done in #215 - so if this pull request could be accepted, that one over there could be closed.

@andrerom
Copy link
Contributor

Nice that you moved code changes out of this pull request, but there is quite a few other code changes left in here.
The cleanest way would be to revert any code changing commits from jeromegamez:ezpersistentobject and put them in separate pull requests, this will also make it easier to accept this pull request.

@jeromegamez
Copy link
Contributor Author

Okay, I have reverted all code changes (except the preposition of public in front of the functions), and the move of the variable $PersistentDataDirty from the bottom of the file to the top.

Do you still see things that shouldn't be there?

@andrerom
Copy link
Contributor

Looks good!
@lolautruche Could you have a look as well?

@lolautruche
Copy link
Contributor

Looks good to me too ! Merging :)
Thanks Jérôme !

lolautruche added a commit that referenced this pull request Nov 24, 2011
@lolautruche lolautruche merged commit 70de6bd into ezsystems:master Nov 24, 2011
peterkeung pushed a commit to peterkeung/ezpublish that referenced this pull request Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants