Skip to content

Commit

Permalink
Merge pull request #3713 from phpDocumentor/fix/3706
Browse files Browse the repository at this point in the history
Fix issue with inheritance order
  • Loading branch information
jaapio committed May 7, 2024
2 parents 4175400 + 7519394 commit 1dd4b2a
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 41 deletions.
6 changes: 3 additions & 3 deletions Makefile
Expand Up @@ -112,13 +112,13 @@ unit-test integration-test functional-test:

.PHONY: e2e-test
e2e-test: node_modules/.bin/cypress build/default/index.html build/clean/index.html
docker run -it --rm -eCYPRESS_CACHE_FOLDER="/e2e/var/cache/.cypress" -v ${CURDIR}:/e2e -w /e2e cypress/included:10.3.0
docker run -it --rm -eCYPRESS_CACHE_FOLDER="/e2e/var/cache/.cypress" -v ${CURDIR}:/e2e -w /e2e cypress/included:13.8.1

cypress/integration/default/%.spec.js: node_modules/.bin/cypress build/default/index.html .RUN_ALWAYS
docker run -it --rm -eCYPRESS_CACHE_FOLDER="/e2e/var/cache/.cypress" -v ${CURDIR}:/e2e -w /e2e cypress/included:10.3.0 -s $@
docker run -it --rm -eCYPRESS_CACHE_FOLDER="/e2e/var/cache/.cypress" -v ${CURDIR}:/e2e -w /e2e cypress/included:13.8.1 -s $@

cypress/integration/clean/%.spec.js: node_modules/.bin/cypress build/clean/index.html .RUN_ALWAYS
docker run -it --rm -eCYPRESS_CACHE_FOLDER="/e2e/var/cache/.cypress" -v ${CURDIR}:/e2e -w /e2e cypress/included:10.3.0 -s $@
docker run -it --rm -eCYPRESS_CACHE_FOLDER="/e2e/var/cache/.cypress" -v ${CURDIR}:/e2e -w /e2e cypress/included:13.8.1 -s $@

.PHONY: composer-require-checker
composer-require-checker:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -45,7 +45,7 @@
"league/uri": "^6.7",
"league/uri-interfaces": "^2.0",
"monolog/monolog": "^2.9",
"nikic/php-parser": "^4.19",
"nikic/php-parser": "^5.0",
"phar-io/manifest": "^2.0",
"phar-io/version": "^3.2",
"phpdocumentor/flyfinder": "^1.0",
Expand Down
41 changes: 21 additions & 20 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cypress.config.js
Expand Up @@ -6,7 +6,6 @@ module.exports = defineConfig({
supportFile: false,
specPattern: "**/*.spec.js",
retries: 2,
videoUploadOnPasses: false,
defaultCommandTimeout: 10000
}
})
43 changes: 43 additions & 0 deletions cypress/integration/default/methods.spec.js
Expand Up @@ -319,3 +319,46 @@ describe('Showing methods for an interface', function() {
})
});
});

describe('Showing methods for class with parent', function() {
beforeEach(function () {
cy.visit('build/default/classes/Marios-Pizza-Toppings-Pepperoni.html');
});

describe('Synopsis', function() {
it('Show the name', function () {
getElementWithName('method', 'publiclyAvailable()')
.should('be.visible');
});

it('Show the file name where the method points to parent class', function () {
getElementWithName('method', 'availableToAll()')
.find('.phpdocumentor-element-found-in__file')
.contains('a', 'Topping.php')
.find('abbr')
.should('have.attr', 'title', 'src/Pizza/Topping.php');
});

it('Links to the file documentation wherein the method points to parrent class', function () {
getElementWithName('method', 'availableToAll()')
.find('.phpdocumentor-element-found-in__file')
.contains('a', 'Topping.php')
.should('have.attr', 'href', 'files/src-pizza-topping.html');
});

it('Show the file name where the method points to current class', function () {
getElementWithName('method', 'publiclyAvailable()')
.find('.phpdocumentor-element-found-in__file')
.contains('a', 'Pepperoni.php')
.find('abbr')
.should('have.attr', 'title', 'src/Pizza/Toppings/Pepperoni.php');
});

it('Links to the file documentation wherein the method points to current class', function () {
getElementWithName('method', 'publiclyAvailable()')
.find('.phpdocumentor-element-found-in__file')
.contains('a', 'Pepperoni.php')
.should('have.attr', 'href', 'files/src-pizza-toppings-pepperoni.html');
});
});
});
3 changes: 3 additions & 0 deletions data/examples/MariosPizzeria/src/Pizza/Toppings/Pepperoni.php
Expand Up @@ -8,5 +8,8 @@

final class Pepperoni extends Topping
{
public function publiclyAvailable()
{

}
}
32 changes: 16 additions & 16 deletions src/phpDocumentor/Transformer/Writer/Twig/Extension.php
Expand Up @@ -245,16 +245,16 @@ static function (DescriptorAbstract $baseNode): array {
'methods',
static function (DescriptorAbstract $descriptor): Collection {
$methods = new Collection();
if (method_exists($descriptor, 'getInheritedMethods')) {
$methods = $methods->merge($descriptor->getInheritedMethods());
if (method_exists($descriptor, 'getMethods')) {
$methods = $methods->merge($descriptor->getMethods());
}

if (method_exists($descriptor, 'getMagicMethods')) {
$methods = $methods->merge($descriptor->getMagicMethods());
}

if (method_exists($descriptor, 'getMethods')) {
$methods = $methods->merge($descriptor->getMethods());
if (method_exists($descriptor, 'getInheritedMethods')) {
$methods = $methods->merge($descriptor->getInheritedMethods());
}

return $methods;
Expand All @@ -264,16 +264,16 @@ static function (DescriptorAbstract $descriptor): Collection {
'properties',
static function (DescriptorAbstract $descriptor): Collection {
$properties = new Collection();
if (method_exists($descriptor, 'getInheritedProperties')) {
$properties = $properties->merge($descriptor->getInheritedProperties());
if (method_exists($descriptor, 'getProperties')) {
$properties = $properties->merge($descriptor->getProperties());
}

if (method_exists($descriptor, 'getMagicProperties')) {
$properties = $properties->merge($descriptor->getMagicProperties());
}

if (method_exists($descriptor, 'getProperties')) {
$properties = $properties->merge($descriptor->getProperties());
if (method_exists($descriptor, 'getInheritedProperties')) {
$properties = $properties->merge($descriptor->getInheritedProperties());
}

return $properties;
Expand All @@ -283,16 +283,16 @@ static function (DescriptorAbstract $descriptor): Collection {
'constants',
static function (DescriptorAbstract $descriptor): Collection {
$constants = new Collection();
if (method_exists($descriptor, 'getInheritedConstants')) {
$constants = $constants->merge($descriptor->getInheritedConstants());
if (method_exists($descriptor, 'getConstants')) {
$constants = $constants->merge($descriptor->getConstants());
}

if (method_exists($descriptor, 'getMagicConstants')) {
$constants = $constants->merge($descriptor->getMagicConstants());
}

if (method_exists($descriptor, 'getConstants')) {
$constants = $constants->merge($descriptor->getConstants());
if (method_exists($descriptor, 'getInheritedConstants')) {
$constants = $constants->merge($descriptor->getInheritedConstants());
}

return $constants;
Expand All @@ -312,14 +312,14 @@ static function (DescriptorAbstract $descriptor): Collection {
'attributes',
static function (DescriptorAbstract $descriptor): Collection {
$attributes = new Collection();
if (method_exists($descriptor, 'getInheritedAttributes')) {
$attributes = $attributes->merge($descriptor->getInheritedAttributes());
}

if (method_exists($descriptor, 'getAttributes')) {
$attributes = $attributes->merge($descriptor->getAttributes());
}

if (method_exists($descriptor, 'getInheritedAttributes')) {
$attributes = $attributes->merge($descriptor->getInheritedAttributes());
}

return $attributes;
},
),
Expand Down

0 comments on commit 1dd4b2a

Please sign in to comment.