Skip to content

Commit c9f95f6

Browse files
authored
Merge pull request #9 from adrigar94/develop
new release 0.2.2
2 parents 533db73 + 3b6b24a commit c9f95f6

File tree

4 files changed

+37
-14
lines changed

4 files changed

+37
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ All notable changes to the "php-skeleton-generator" extension will be documented
55
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
66

77

8+
## [unreleased]
9+
- fix return type for equals() method on skeleton for class
10+
811
## [0.2.1]
912

1013
### Added

README.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,42 @@
11
# php-skeleton-generator Extension for Visual Studio Code
22

3-
![php-skeleton-generator Logo](images/logo.png)
3+
<img src="images/logo.png" width="150" style="display: block; margin: 0 auto 10px">
44

55
Looking for an easy and quick way to generate PHP code skeletons? Check out our "PHP Skeleton Generator" extension! With just a few steps, you can create PHP classes, interfaces, traits, and enums with all the properties and methods you need. Our assistant guides you through the process, asking you for the options you need and generating the code for you. Save time and effort when creating your PHP projects with "PHP Skeleton Generator"!
66

77
## Features
88

9-
- Run `php-skeleton-generate` command from the command palette to generate a skeleton for a PHP files [class, interface, enum and trait]
9+
- Run `php-skeleton-generate` command from the command palette to generate a skeleton for a PHP files
10+
- Class
11+
- Interface
12+
- Enum
13+
- Trait
14+
15+
## Usage
16+
17+
1. Press `Ctrl+Shift+P` to open the command palette
18+
2. Type `php-skeleton-generate` and press Enter
19+
3. Chose a type of skeleton
20+
3. Enter the name of your file and press Enter
21+
4. Use the wizard to enrich your skeleton
22+
5. The skeleton for the PHP class will be generated
23+
24+
### New Class
25+
26+
### New Interface
27+
28+
### New Enum
29+
30+
### New Trait
1031

1132
## Planned Features
1233

34+
- compatibility with other PHP versions
35+
1336
## Requirements
1437

1538
- [Visual Studio Code](https://code.visualstudio.com/)
16-
17-
## Usage
18-
19-
1. Press `Ctrl+Shift+P` to open the command palette
20-
2. Type `php-skeleton-generate` and press Enter
21-
3. Enter the name of your class and press Enter
22-
4. The skeleton for the PHP class will be generated
39+
- [PHP 8](https://www.php.net/releases/8.0)
2340

2441

2542
## Credits

src/utils/files.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,28 @@ function getPsr4(): { [key: string]: string } {
6262
return autoload['psr-4'];
6363
}
6464

65-
export function generateNamespace(folder: vscode.Uri, fileName: string): string {
65+
export function generateNamespace(folder: vscode.Uri): string {
6666
let folderPath = folder.fsPath;
6767
const psr4 = getPsr4();
6868

6969
const rootPath = getRootPath();
7070
folderPath = folderPath.replace(rootPath??'', '');
7171
folderPath = folderPath.replace(/\/|\\/g, '\\').replace(/\\/, '');
7272

73+
74+
7375
for (const prefix of Object.keys(psr4)) {
7476
const basePath = psr4[prefix].replace(/\/|\\/g, '\\\\');
7577
const prefixRegex = new RegExp(`^${basePath}`);
7678

7779
if (prefixRegex.test(folderPath)) {
7880
const relativePath = folderPath.replace(prefixRegex, '');
7981
const namespace = prefix + relativePath;
80-
vscode.window.showInformationMessage("in1");
8182
return namespace;
8283
}
84+
else if(basePath === folderPath.concat('\\\\')){
85+
return prefix.replace(/\\/, '');
86+
}
8387
}
84-
vscode.window.showInformationMessage("out");
8588
return folderPath;
8689
}

src/wizardPhpSkeletons.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export async function wizardGeneratePhpSkeleton() {
88
const type = await wizardFileType();
99
const fileName = await wizardFileName(type);
1010

11-
const namespace = generateNamespace(folder, fileName);
11+
const namespace = generateNamespace(folder);
1212

1313
const classSkeleton = await generatePhpSkeleton(type, fileName, namespace);
1414

@@ -112,7 +112,7 @@ async function generatePhpClassSkeleton(className: string, namespace: string): P
112112

113113

114114
const equalsMethod = equalsCondition.length ? `
115-
public function equals(self $toCompare): boolean
115+
public function equals(self $toCompare): bool
116116
{
117117
return ${equalsCondition.join('\n AND ')};
118118
}

0 commit comments

Comments
 (0)