Detection of design patterns in PHP code

Overview

Pattern Detector for PHP

Detects design pattern in your code

License Build Status

## Installation

git clone https://github.com/Halleck45/DesignPatternDetector.git
cd DesignPatternDetector
composer install

## Usage

./bin/design-pattern 
   

   

You'll get something like:

screenshot

## Why ?

Just for fun. This tool is only a proof of concept. But contributions are welcome :)

## Detected patterns

Today this tool is able to detect following patterns :

  • Micro
    • Structure
  • Structural
    • Bridge
    • Decorator
    • Proxy
  • Creational
    • Singleton
    • Abstract Factory
  • Behavior
  • Anti-patterns
    • GodObject / Blob

## License

See LICENSE file

You might also like...
Design Pattern Examples in PHP

Design Patterns in PHP This repository is part of the Refactoring.Guru project. It contains PHP examples for all classic GoF design patterns. Each pat

Last Wishes is a PHP application written following Domain-Driven Design approach

Last Wishes is a PHP application written following Domain-Driven Design approach. It's one of the sample applications where you can check the concepts explained in the Domain-Driven Design in PHP book.

Simple WHOIS script with beautiful design.
Simple WHOIS script with beautiful design.

Simple PHP Whois It is ideal in terms of design and has easy operation. / Tasarım açısından idealdir ve kullanımı kolaydır. It has a simple interface.

PHP_Depend is an adaptation of the established Java development tool JDepend. This tool shows you the quality of your design in terms of extensibility, reusability and maintainability.

PHP Depend Documentation PHP Depend for enterprise Available as part of the Tidelift Subscription. The maintainers of PHP Depend and thousands of othe

 Enterprise Modular SAAS Framework, Design from the growndup to grow vertically.
Enterprise Modular SAAS Framework, Design from the growndup to grow vertically.

Kwerio Enterprise Modular SAAS Framework, Design from the growndup to grow vertically. Explore the docs » View Demo · Report Bug · Request Feature Tab

A study of the design, implementation, and management of enterprise information systems.

Enterprise-Architecture A study of the design, implementation, and management of enterprise information systems. Organization: University of North Ala

Drupal / Eleventy Docs Site for the Design System

Drupal / Eleventy Docs Site for the Design System

Result of our code-along meetup writing PHP 8.1 code

PHP 8.1 Demo Code This code demonstrates various PHP 8.0 and 8.1 features in a realistic, functional (but incomplete) codebase. The code is part of so

Dead Code Detector (DCD) for PHP code.

This project is no longer maintained and its repository is only kept for archival purposes. PHP Dead Code Detector (PHPDCD) phpdcd is a Dead Code Dete

Comments
  • Code was not executing as expected

    Code was not executing as expected

    Execution of code not result in proper output, details below.

    cmd used: ./bin/design-pattern ../laravel/vendor

    Output with error: Design pattern detector by Jean-François Lépine https://twitter.com/Halleck45

    PHP Fatal error: Uncaught TypeError: Argument 1 passed to Hal\Component\File\Finder::__construct() must be of the type array, string given, called in /var/www/DesignPatternDetector/src/Hal/Application/Command/RunPatternCommand.php on line 74 and defined in /var/www/DesignPatternDetector/vendor/halleck45/phpmetrics/src/Hal/Component/File/Finder.php:53 Stack trace: #0 /var/www/DesignPatternDetector/src/Hal/Application/Command/RunPatternCommand.php(74): Hal\Component\File\Finder->__construct() #1 /var/www/DesignPatternDetector/vendor/symfony/console/Command/Command.php(245): Hal\Application\Command\RunPatternCommand->execute() #2 /var/www/DesignPatternDetector/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run() #3 /var/www/DesignPatternDetector/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand() #4 /var/www/DesignPatternDetector/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun() #5 /var/www/DesignPatt in /var/www/DesignPatternDetector/vendor/halleck45/phpmetrics/src/Hal/Component/File/Finder.php on line 53

    opened by tharun777 0
  • Issue running script

    Issue running script

    PHP Fatal error: Uncaught TypeError: Argument 1 passed to Hal\Component\File\Finder::__construct() must be of the type array, string given, called in /srv/http/codeCheckers/DesignPatternDetector/src/Hal/Application/Command/RunPatternCommand.php on line 74 and defined in /srv/http/codeCheckers/DesignPatternDetector/vendor/halleck45/phpmetrics/src/Hal/Component/File/Finder.php:55

    opened by maxprihodko8 1
  • Fix part of #5 - Finder parameter must be an array

    Fix part of #5 - Finder parameter must be an array

    With old composer.json latest phpmetrics was installed and it has the constructor with different parameters. We have to convert accepting argument and options in CLI command from string to array.

    1. I have upgraded libs to the latest
    2. converted CLI params to be array instead of string
    • Hal/Component/Finder has changed constructor and now accepts array - require options for include and exclude to be arrays
    • Finder has removed method and introduced instead - required CLI argument for the path to be changed in the array.

    Small note:

    • This part is solved, but due to removed Tokenizer from phpmetrics a new bug show up. I hope that that new bug is not a constraint for this pull request.
    opened by vukanac 0
  • When I run the script it errors out

    When I run the script it errors out

    PHP Fatal error: Uncaught Error: Call to a member function getType() on string in DesignPatternDetector/vendor/phpmetrics/phpmetrics/src/Hal/Component/OOP/Extractor/Extractor.php:89

    opened by tonywallen 5
Owner
Jean-François Lépine
Jean-François Lépine
Sample code for several design patterns in PHP 8

DesignPatternsPHP Read the Docs of DesignPatternsPHP or Download as PDF/Epub This is a collection of known design patterns and some sample codes on ho

null 21k Jan 5, 2023
Examples of some common design patterns implemented in php

What is a Design Pattern? Design patterns are typical solutions to common problems in software design. Each pattern is like a blueprint that you can c

Bakhtiyor Bahritidinov 4 Feb 11, 2022
Repo do vídeo do youtube de Design Patterns - Decorator

DesignPatternsPHP-Decorator Repo do vídeo do Youtube de Design Patterns - Decorator Link do vídeo Decorator em PHP 8 Imagem de exemplo Link do cadastr

Leonardo Tumadjian 10 Aug 18, 2022
Learning design patterns by implementing them in various programming languages.

design-patterns Learning design patterns by implementing them in various programming languages. Creational design patterns Creational design patterns

Paweł Tryfon 1 Dec 13, 2021
php-dry – Clone Detection for PHP

php-dry – Clone Detection for PHP php-dry detects duplicated behaviour in your application, even if the duplicated passages are implemented completely

Leo Viezens 15 Oct 28, 2022
Detection of execution by command (Terminal) or web environment.

WEB-CLI-Detector Detection of execution by command (Terminal) or web environment. Acronym: [WEB-CLI-Detector]. Name: WEB-CLI-Detector. Dependencies: S

Walter Nuñez 4 Jul 13, 2022
PHP Library that implements several messaging patterns for RabbitMQ

Thumper Thumper is a PHP library that aims to abstract several messaging patterns that can be implemented over RabbitMQ. Inside the examples folder yo

php-amqplib 276 Nov 20, 2022
The easiest way to match data structures like JSON/PlainText/XML against readable patterns. Sandbox:

PHP Matcher Library created for testing all kinds of JSON/XML/TXT/Scalar values against patterns. API: PHPMatcher::match($value = '{"foo": "bar"}', $p

Coduo 774 Dec 31, 2022
CDK patterns for serverless container with AWS Fargate

cdk-fargate-patterns CDK patterns for serverless container with AWS Fargate DualAlbFargateService Inspired by Vijay Menon from the AWS blog post intro

Pahud Hsieh 48 Sep 1, 2021
the examples of head first object oriented analysis & design - in PHP

Head First object oriented analysis & design in (PHP) after cloning the repository, you have to install the project's dependancies by running the foll

Muhammed ElFeqy 3 Oct 16, 2021